Skip to content

Commit 3c7a103

Browse files
DrFaust92antonbabenko
authored andcommitted
Added tags to VPC Endpoints (terraform-aws-modules#292)
* Add tags to VPC Endpoints * Update variables.tf add new line between variables * centralize vpce tag param * fix s3 tags * Updated README * Updated README * Updated README
1 parent b38034a commit 3c7a103

File tree

5 files changed

+48
-0
lines changed

5 files changed

+48
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,7 @@ Sometimes it is handy to have public access to Redshift clusters (for example if
437437
| transferserver\_endpoint\_private\_dns\_enabled | Whether or not to associate a private hosted zone with the specified VPC for Transfer Server endpoint | bool | `"false"` | no |
438438
| transferserver\_endpoint\_security\_group\_ids | The ID of one or more security groups to associate with the network interface for Transfer Server endpoint | list(string) | `[]` | no |
439439
| transferserver\_endpoint\_subnet\_ids | The ID of one or more subnets in which to create a network interface for Transfer Server endpoint. Only a single subnet within an AZ is supported. If omitted, private subnets will be used. | list(string) | `[]` | no |
440+
| vpc\_endpoint\_tags | Additional tags for the VPC Endpoints | map(string) | `{}` | no |
440441
| vpc\_tags | Additional tags for the VPC | map(string) | `{}` | no |
441442
| vpn\_gateway\_id | ID of VPN Gateway to attach to the VPC | string | `""` | no |
442443
| vpn\_gateway\_tags | Additional tags for the VPN gateway | map(string) | `{}` | no |

examples/complete-vpc/main.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,5 +97,10 @@ module "vpc" {
9797
Environment = "staging"
9898
Name = "complete"
9999
}
100+
101+
vpc_endpoint_tags = {
102+
Project = "Secret"
103+
Endpoint = "true"
104+
}
100105
}
101106

main.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ locals {
1616
),
1717
0,
1818
)
19+
20+
vpce_tags = merge(
21+
var.tags,
22+
var.vpc_endpoint_tags,
23+
)
1924
}
2025

2126
######

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,6 +1177,12 @@ variable "vpn_gateway_tags" {
11771177
default = {}
11781178
}
11791179

1180+
variable "vpc_endpoint_tags" {
1181+
description = "Additional tags for the VPC Endpoints"
1182+
type = map(string)
1183+
default = {}
1184+
}
1185+
11801186
variable "enable_dhcp_options" {
11811187
description = "Should be true if you want to specify a DHCP options set with a custom domain name, DNS servers, NTP servers, netbios servers, and/or netbios server type"
11821188
type = bool

vpc-endpoints.tf

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ resource "aws_vpc_endpoint" "s3" {
1212

1313
vpc_id = local.vpc_id
1414
service_name = data.aws_vpc_endpoint_service.s3[0].service_name
15+
tags = local.vpce_tags
1516
}
1617

1718
resource "aws_vpc_endpoint_route_table_association" "private_s3" {
@@ -49,6 +50,7 @@ resource "aws_vpc_endpoint" "dynamodb" {
4950

5051
vpc_id = local.vpc_id
5152
service_name = data.aws_vpc_endpoint_service.dynamodb[0].service_name
53+
tags = local.vpce_tags
5254
}
5355

5456
resource "aws_vpc_endpoint_route_table_association" "private_dynamodb" {
@@ -92,6 +94,7 @@ resource "aws_vpc_endpoint" "codebuild" {
9294
security_group_ids = var.codebuild_endpoint_security_group_ids
9395
subnet_ids = coalescelist(var.codebuild_endpoint_subnet_ids, aws_subnet.private.*.id)
9496
private_dns_enabled = var.codebuild_endpoint_private_dns_enabled
97+
tags = local.vpce_tags
9598
}
9699

97100
###############################
@@ -113,6 +116,7 @@ resource "aws_vpc_endpoint" "codecommit" {
113116
security_group_ids = var.codecommit_endpoint_security_group_ids
114117
subnet_ids = coalescelist(var.codecommit_endpoint_subnet_ids, aws_subnet.private.*.id)
115118
private_dns_enabled = var.codecommit_endpoint_private_dns_enabled
119+
tags = local.vpce_tags
116120
}
117121

118122
###################################
@@ -134,6 +138,7 @@ resource "aws_vpc_endpoint" "git_codecommit" {
134138
security_group_ids = var.git_codecommit_endpoint_security_group_ids
135139
subnet_ids = coalescelist(var.git_codecommit_endpoint_subnet_ids, aws_subnet.private.*.id)
136140
private_dns_enabled = var.git_codecommit_endpoint_private_dns_enabled
141+
tags = local.vpce_tags
137142
}
138143

139144
##########################
@@ -155,6 +160,7 @@ resource "aws_vpc_endpoint" "config" {
155160
security_group_ids = var.config_endpoint_security_group_ids
156161
subnet_ids = coalescelist(var.config_endpoint_subnet_ids, aws_subnet.private.*.id)
157162
private_dns_enabled = var.config_endpoint_private_dns_enabled
163+
tags = local.vpce_tags
158164
}
159165

160166
#######################
@@ -176,6 +182,7 @@ resource "aws_vpc_endpoint" "sqs" {
176182
security_group_ids = var.sqs_endpoint_security_group_ids
177183
subnet_ids = coalescelist(var.sqs_endpoint_subnet_ids, aws_subnet.private.*.id)
178184
private_dns_enabled = var.sqs_endpoint_private_dns_enabled
185+
tags = local.vpce_tags
179186
}
180187

181188
###################################
@@ -197,6 +204,7 @@ resource "aws_vpc_endpoint" "secretsmanager" {
197204
security_group_ids = var.secretsmanager_endpoint_security_group_ids
198205
subnet_ids = coalescelist(var.secretsmanager_endpoint_subnet_ids, aws_subnet.private.*.id)
199206
private_dns_enabled = var.secretsmanager_endpoint_private_dns_enabled
207+
tags = local.vpce_tags
200208
}
201209

202210
#######################
@@ -218,6 +226,7 @@ resource "aws_vpc_endpoint" "ssm" {
218226
security_group_ids = var.ssm_endpoint_security_group_ids
219227
subnet_ids = coalescelist(var.ssm_endpoint_subnet_ids, aws_subnet.private.*.id)
220228
private_dns_enabled = var.ssm_endpoint_private_dns_enabled
229+
tags = local.vpce_tags
221230
}
222231

223232
###############################
@@ -239,6 +248,7 @@ resource "aws_vpc_endpoint" "ssmmessages" {
239248
security_group_ids = var.ssmmessages_endpoint_security_group_ids
240249
subnet_ids = coalescelist(var.ssmmessages_endpoint_subnet_ids, aws_subnet.private.*.id)
241250
private_dns_enabled = var.ssmmessages_endpoint_private_dns_enabled
251+
tags = local.vpce_tags
242252
}
243253

244254
#######################
@@ -260,6 +270,7 @@ resource "aws_vpc_endpoint" "ec2" {
260270
security_group_ids = var.ec2_endpoint_security_group_ids
261271
subnet_ids = coalescelist(var.ec2_endpoint_subnet_ids, aws_subnet.private.*.id)
262272
private_dns_enabled = var.ec2_endpoint_private_dns_enabled
273+
tags = local.vpce_tags
263274
}
264275

265276
###############################
@@ -281,6 +292,7 @@ resource "aws_vpc_endpoint" "ec2messages" {
281292
security_group_ids = var.ec2messages_endpoint_security_group_ids
282293
subnet_ids = coalescelist(var.ec2messages_endpoint_subnet_ids, aws_subnet.private.*.id)
283294
private_dns_enabled = var.ec2messages_endpoint_private_dns_enabled
295+
tags = local.vpce_tags
284296
}
285297

286298
###################################
@@ -302,6 +314,7 @@ resource "aws_vpc_endpoint" "transferserver" {
302314
security_group_ids = var.transferserver_endpoint_security_group_ids
303315
subnet_ids = coalescelist(var.transferserver_endpoint_subnet_ids, aws_subnet.private.*.id)
304316
private_dns_enabled = var.transferserver_endpoint_private_dns_enabled
317+
tags = local.vpce_tags
305318
}
306319

307320
###########################
@@ -323,6 +336,7 @@ resource "aws_vpc_endpoint" "ecr_api" {
323336
security_group_ids = var.ecr_api_endpoint_security_group_ids
324337
subnet_ids = coalescelist(var.ecr_api_endpoint_subnet_ids, aws_subnet.private.*.id)
325338
private_dns_enabled = var.ecr_api_endpoint_private_dns_enabled
339+
tags = local.vpce_tags
326340
}
327341

328342
###########################
@@ -344,6 +358,7 @@ resource "aws_vpc_endpoint" "ecr_dkr" {
344358
security_group_ids = var.ecr_dkr_endpoint_security_group_ids
345359
subnet_ids = coalescelist(var.ecr_dkr_endpoint_subnet_ids, aws_subnet.private.*.id)
346360
private_dns_enabled = var.ecr_dkr_endpoint_private_dns_enabled
361+
tags = local.vpce_tags
347362
}
348363

349364
#######################
@@ -365,6 +380,7 @@ resource "aws_vpc_endpoint" "apigw" {
365380
security_group_ids = var.apigw_endpoint_security_group_ids
366381
subnet_ids = coalescelist(var.apigw_endpoint_subnet_ids, aws_subnet.private.*.id)
367382
private_dns_enabled = var.apigw_endpoint_private_dns_enabled
383+
tags = local.vpce_tags
368384
}
369385

370386
#######################
@@ -386,6 +402,7 @@ resource "aws_vpc_endpoint" "kms" {
386402
security_group_ids = var.kms_endpoint_security_group_ids
387403
subnet_ids = coalescelist(var.kms_endpoint_subnet_ids, aws_subnet.private.*.id)
388404
private_dns_enabled = var.kms_endpoint_private_dns_enabled
405+
tags = local.vpce_tags
389406
}
390407

391408
#######################
@@ -407,6 +424,7 @@ resource "aws_vpc_endpoint" "ecs" {
407424
security_group_ids = var.ecs_endpoint_security_group_ids
408425
subnet_ids = coalescelist(var.ecs_endpoint_subnet_ids, aws_subnet.private.*.id)
409426
private_dns_enabled = var.ecs_endpoint_private_dns_enabled
427+
tags = local.vpce_tags
410428
}
411429

412430

@@ -429,6 +447,7 @@ resource "aws_vpc_endpoint" "ecs_agent" {
429447
security_group_ids = var.ecs_agent_endpoint_security_group_ids
430448
subnet_ids = coalescelist(var.ecs_agent_endpoint_subnet_ids, aws_subnet.private.*.id)
431449
private_dns_enabled = var.ecs_agent_endpoint_private_dns_enabled
450+
tags = local.vpce_tags
432451
}
433452

434453

@@ -451,6 +470,7 @@ resource "aws_vpc_endpoint" "ecs_telemetry" {
451470
security_group_ids = var.ecs_telemetry_endpoint_security_group_ids
452471
subnet_ids = coalescelist(var.ecs_telemetry_endpoint_subnet_ids, aws_subnet.private.*.id)
453472
private_dns_enabled = var.ecs_telemetry_endpoint_private_dns_enabled
473+
tags = local.vpce_tags
454474
}
455475

456476

@@ -473,6 +493,7 @@ resource "aws_vpc_endpoint" "sns" {
473493
security_group_ids = var.sns_endpoint_security_group_ids
474494
subnet_ids = coalescelist(var.sns_endpoint_subnet_ids, aws_subnet.private.*.id)
475495
private_dns_enabled = var.sns_endpoint_private_dns_enabled
496+
tags = local.vpce_tags
476497
}
477498

478499

@@ -495,6 +516,7 @@ resource "aws_vpc_endpoint" "monitoring" {
495516
security_group_ids = var.monitoring_endpoint_security_group_ids
496517
subnet_ids = coalescelist(var.monitoring_endpoint_subnet_ids, aws_subnet.private.*.id)
497518
private_dns_enabled = var.monitoring_endpoint_private_dns_enabled
519+
tags = local.vpce_tags
498520
}
499521

500522

@@ -517,6 +539,7 @@ resource "aws_vpc_endpoint" "logs" {
517539
security_group_ids = var.logs_endpoint_security_group_ids
518540
subnet_ids = coalescelist(var.logs_endpoint_subnet_ids, aws_subnet.private.*.id)
519541
private_dns_enabled = var.logs_endpoint_private_dns_enabled
542+
tags = local.vpce_tags
520543
}
521544

522545

@@ -539,6 +562,7 @@ resource "aws_vpc_endpoint" "events" {
539562
security_group_ids = var.events_endpoint_security_group_ids
540563
subnet_ids = coalescelist(var.events_endpoint_subnet_ids, aws_subnet.private.*.id)
541564
private_dns_enabled = var.events_endpoint_private_dns_enabled
565+
tags = local.vpce_tags
542566
}
543567

544568

@@ -561,6 +585,7 @@ resource "aws_vpc_endpoint" "elasticloadbalancing" {
561585
security_group_ids = var.elasticloadbalancing_endpoint_security_group_ids
562586
subnet_ids = coalescelist(var.elasticloadbalancing_endpoint_subnet_ids, aws_subnet.private.*.id)
563587
private_dns_enabled = var.elasticloadbalancing_endpoint_private_dns_enabled
588+
tags = local.vpce_tags
564589
}
565590

566591

@@ -583,6 +608,7 @@ resource "aws_vpc_endpoint" "cloudtrail" {
583608
security_group_ids = var.cloudtrail_endpoint_security_group_ids
584609
subnet_ids = coalescelist(var.cloudtrail_endpoint_subnet_ids, aws_subnet.private.*.id)
585610
private_dns_enabled = var.cloudtrail_endpoint_private_dns_enabled
611+
tags = local.vpce_tags
586612
}
587613

588614

@@ -605,6 +631,7 @@ resource "aws_vpc_endpoint" "kinesis_streams" {
605631
security_group_ids = var.kinesis_streams_endpoint_security_group_ids
606632
subnet_ids = coalescelist(var.kinesis_streams_endpoint_subnet_ids, aws_subnet.private.*.id)
607633
private_dns_enabled = var.kinesis_streams_endpoint_private_dns_enabled
634+
tags = local.vpce_tags
608635
}
609636

610637

@@ -627,6 +654,7 @@ resource "aws_vpc_endpoint" "kinesis_firehose" {
627654
security_group_ids = var.kinesis_firehose_endpoint_security_group_ids
628655
subnet_ids = coalescelist(var.kinesis_firehose_endpoint_subnet_ids, aws_subnet.private.*.id)
629656
private_dns_enabled = var.kinesis_firehose_endpoint_private_dns_enabled
657+
tags = local.vpce_tags
630658
}
631659

632660
#######################
@@ -648,6 +676,7 @@ resource "aws_vpc_endpoint" "glue" {
648676
security_group_ids = var.glue_endpoint_security_group_ids
649677
subnet_ids = coalescelist(var.glue_endpoint_subnet_ids, aws_subnet.private.*.id)
650678
private_dns_enabled = var.glue_endpoint_private_dns_enabled
679+
tags = local.vpce_tags
651680
}
652681

653682
######################################
@@ -669,6 +698,7 @@ resource "aws_vpc_endpoint" "sagemaker_notebook" {
669698
security_group_ids = var.sagemaker_notebook_endpoint_security_group_ids
670699
subnet_ids = coalescelist(var.sagemaker_notebook_endpoint_subnet_ids, aws_subnet.private.*.id)
671700
private_dns_enabled = var.sagemaker_notebook_endpoint_private_dns_enabled
701+
tags = local.vpce_tags
672702
}
673703

674704
#######################
@@ -690,4 +720,5 @@ resource "aws_vpc_endpoint" "sts" {
690720
security_group_ids = var.sts_endpoint_security_group_ids
691721
subnet_ids = coalescelist(var.sts_endpoint_subnet_ids, aws_subnet.private.*.id)
692722
private_dns_enabled = var.sts_endpoint_private_dns_enabled
723+
tags = local.vpce_tags
693724
}

0 commit comments

Comments
 (0)