Skip to content

Commit

Permalink
ECS に必要となる VPC エンドポイントを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
kobayashi-m42 committed Jan 31, 2023
1 parent a35c50f commit 890b7e5
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
35 changes: 35 additions & 0 deletions modules/aws/vpc/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,38 @@ resource "aws_vpc_endpoint_route_table_association" "example" {
vpc_endpoint_id = aws_vpc_endpoint.s3.id
route_table_id = aws_route_table.public.id
}

resource "aws_vpc_endpoint" "ecr_api" {
vpc_id = aws_vpc.this.id
service_name = "com.amazonaws.ap-northeast-1.ecr.api"
vpc_endpoint_type = "Interface"
subnet_ids = aws_subnet.public[*].id
security_group_ids = [aws_security_group.vpc_endpoint.id]
private_dns_enabled = true
}

resource "aws_vpc_endpoint" "ecr_dkr" {
vpc_id = aws_vpc.this.id
service_name = "com.amazonaws.ap-northeast-1.ecr.dkr"
vpc_endpoint_type = "Interface"
subnet_ids = aws_subnet.public[*].id
security_group_ids = [aws_security_group.vpc_endpoint.id]
private_dns_enabled = true
}
resource "aws_vpc_endpoint" "ssm" {
vpc_id = aws_vpc.this.id
service_name = "com.amazonaws.ap-northeast-1.ssm"
vpc_endpoint_type = "Interface"
subnet_ids = aws_subnet.public[*].id
security_group_ids = [aws_security_group.vpc_endpoint.id]
private_dns_enabled = true
}

resource "aws_vpc_endpoint" "logs" {
vpc_id = aws_vpc.this.id
service_name = "com.amazonaws.ap-northeast-1.logs"
vpc_endpoint_type = "Interface"
subnet_ids = aws_subnet.public[*].id
security_group_ids = [aws_security_group.vpc_endpoint.id]
private_dns_enabled = true
}
22 changes: 22 additions & 0 deletions modules/aws/vpc/security-group.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
resource "aws_security_group" "vpc_endpoint" {
name = "vpc-endpoint"
vpc_id = aws_vpc.this.id
}

resource "aws_security_group_rule" "vpc_endpoint_egress" {
type = "egress"
from_port = 443
to_port = 443
protocol = "tcp"
cidr_blocks = [aws_vpc.this.cidr_block]
security_group_id = aws_security_group.vpc_endpoint.id
}

resource "aws_security_group_rule" "vpc_endpoint_ingress" {
type = "ingress"
from_port = 443
to_port = 443
protocol = "tcp"
cidr_blocks = [aws_vpc.this.cidr_block]
security_group_id = aws_security_group.vpc_endpoint.id
}

0 comments on commit 890b7e5

Please sign in to comment.