こんな感じでCodeCommitのエンドポイント設定すると思うのですが、

        self.vpc.add_interface_endpoint("CodeCommitGitEndpointForPrivate",
            service=ec2.InterfaceVpcEndpointAwsService.CODECOMMIT_GIT,
            subnets=ec2.SubnetSelection(subnet_type=ec2.SubnetType.PRIVATE_WITH_NAT),
        )

これで作られるエンドポイントのENIのセキュリティグループってデフォだと

HTTPSしか許可してないっぽい?

どうなんでしょ。SSHはダメってことなのかしら?

とりあえず、

        sg_code_commit.add_ingress_rule(ec2.Peer.ipv4('10.0.0.0/16'), ec2.Port.tcp(22), "allow ssh access from the VPC")
        self.vpc.add_interface_endpoint("CodeCommitGitEndpointForPrivate",
            service=ec2.InterfaceVpcEndpointAwsService.CODECOMMIT_GIT,
            subnets=ec2.SubnetSelection(subnet_type=ec2.SubnetType.PRIVATE_WITH_NAT),
            security_groups=[sg_code_commit]
        )

って感じにすれば、22と443両方OKになるセキュリティグループにしてくれるっぽいけども。

いちをSSHでの接続も出来た。

デフォでSSH許可してないのは何か理由あるのかしら?

タグ :
#AWS
#CDK
#CodeCommit
#SSH