@@ -106,4 +106,64 @@ resource "aws_route_table_association" "private_subnet_route_associations" {
106
106
count = length (var. private_subnet_cidrs )
107
107
subnet_id = aws_subnet. private_subnets [count . index ]. id
108
108
route_table_id = aws_route_table. private_route_tables [count . index ]. id
109
+ }
110
+
111
+ # ## vpc endpoint
112
+ resource "aws_security_group" "vpc_endpoint_sg" {
113
+ ingress = [{
114
+ cidr_blocks = [aws_vpc.vpc.cidr_block]
115
+ description = " same vpc allow"
116
+ from_port = 443
117
+ to_port = 443
118
+ protocol = " tcp"
119
+ ipv6_cidr_blocks = []
120
+ prefix_list_ids = []
121
+ security_groups = []
122
+ self = false
123
+ }]
124
+
125
+ egress = [{
126
+ cidr_blocks = [" 0.0.0.0/0" ]
127
+ description = " alow all outbound"
128
+ from_port = 0
129
+ to_port = 0
130
+ protocol = " -1"
131
+ ipv6_cidr_blocks = []
132
+ prefix_list_ids = []
133
+ security_groups = []
134
+ self = false
135
+ }]
136
+ vpc_id = aws_vpc. vpc . id
137
+
138
+ tags = {
139
+ " Name" = " ${ var . vpc_name } -vpc-endpoint-sg"
140
+ }
141
+ }
142
+
143
+ resource "aws_vpc_endpoint" "ecr-api" {
144
+ vpc_id = aws_vpc. vpc . id
145
+ service_name = " com.amazonaws.${ var . current_region } .ecr.api"
146
+ vpc_endpoint_type = " Interface"
147
+
148
+ security_group_ids = [
149
+ aws_security_group . vpc_endpoint_sg . id ,
150
+ ]
151
+
152
+ subnet_ids = tolist (aws_subnet. private_subnets [* ]. id )
153
+
154
+ private_dns_enabled = true
155
+ }
156
+
157
+ resource "aws_vpc_endpoint" "ecr-dkr" {
158
+ vpc_id = aws_vpc. vpc . id
159
+ service_name = " com.amazonaws.${ var . current_region } .ecr.dkr"
160
+ vpc_endpoint_type = " Interface"
161
+
162
+ security_group_ids = [
163
+ aws_security_group . vpc_endpoint_sg . id ,
164
+ ]
165
+
166
+ subnet_ids = tolist (aws_subnet. private_subnets [* ]. id )
167
+
168
+ private_dns_enabled = true
109
169
}
0 commit comments