File tree Expand file tree Collapse file tree 4 files changed +123
-107
lines changed Expand file tree Collapse file tree 4 files changed +123
-107
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ Note that this example may create resources which can cost money (AWS Elastic IP
42
42
43
43
| Name | Type |
44
44
| ------| ------|
45
+ | [ aws_security_group.vpc_tls] ( https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group ) | resource |
45
46
| [ aws_iam_policy_document.dynamodb_endpoint_policy] ( https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document ) | data source |
46
47
| [ aws_iam_policy_document.generic_endpoint_policy] ( https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document ) | data source |
47
48
| [ aws_security_group.default] ( https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/security_group ) | data source |
Original file line number Diff line number Diff line change @@ -102,6 +102,7 @@ module "vpc_endpoints" {
102
102
service = " ssm"
103
103
private_dns_enabled = true
104
104
subnet_ids = module.vpc.private_subnets
105
+ security_group_ids = [aws_security_group.vpc_tls.id]
105
106
},
106
107
ssmmessages = {
107
108
service = " ssmmessages"
@@ -127,6 +128,7 @@ module "vpc_endpoints" {
127
128
service = " ec2"
128
129
private_dns_enabled = true
129
130
subnet_ids = module.vpc.private_subnets
131
+ security_group_ids = [aws_security_group.vpc_tls.id]
130
132
},
131
133
ec2messages = {
132
134
service = " ec2messages"
@@ -149,6 +151,7 @@ module "vpc_endpoints" {
149
151
service = " kms"
150
152
private_dns_enabled = true
151
153
subnet_ids = module.vpc.private_subnets
154
+ security_group_ids = [aws_security_group.vpc_tls.id]
152
155
},
153
156
codedeploy = {
154
157
service = " codedeploy"
@@ -232,3 +235,19 @@ data "aws_iam_policy_document" "generic_endpoint_policy" {
232
235
}
233
236
}
234
237
}
238
+
239
+ resource "aws_security_group" "vpc_tls" {
240
+ name_prefix = " ${ local . name } -vpc_tls"
241
+ description = " Allow TLS inbound traffic"
242
+ vpc_id = module. vpc . vpc_id
243
+
244
+ ingress {
245
+ description = " TLS from VPC"
246
+ from_port = 443
247
+ to_port = 443
248
+ protocol = " tcp"
249
+ cidr_blocks = [module . vpc . vpc_cidr_block ]
250
+ }
251
+
252
+ tags = local. tags
253
+ }
Original file line number Diff line number Diff line change 1
- locals {
2
- endpoints = var. create ? var. endpoints : tomap ({})
3
- }
4
-
5
1
# ###############################################################################
6
2
# Endpoint(s)
7
3
# ###############################################################################
8
4
9
5
data "aws_vpc_endpoint_service" "this" {
10
- for_each = local . endpoints
6
+ for_each = { for k , v in var . endpoints : k => v if var . create }
11
7
12
8
service = lookup (each. value , " service" , null )
13
9
service_name = lookup (each. value , " service_name" , null )
@@ -19,7 +15,7 @@ data "aws_vpc_endpoint_service" "this" {
19
15
}
20
16
21
17
resource "aws_vpc_endpoint" "this" {
22
- for_each = local . endpoints
18
+ for_each = { for k , v in var . endpoints : k => v if var . create }
23
19
24
20
vpc_id = var. vpc_id
25
21
service_name = data. aws_vpc_endpoint_service . this [each . key ]. service_name
You can’t perform that action at this time.
0 commit comments