Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tags to VPC Endpoints - terraform 0.11.x #293

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ Sometimes it is handy to have public access to Redshift clusters (for example if
| ssmmessages\_endpoint\_security\_group\_ids | The ID of one or more security groups to associate with the network interface for SSMMESSAGES endpoint | list | `[]` | no |
| ssmmessages\_endpoint\_subnet\_ids | The ID of one or more subnets in which to create a network interface for SSMMESSAGES endpoint. Only a single subnet within an AZ is supported. If omitted, private subnets will be used. | list | `[]` | no |
| tags | A map of tags to add to all resources | map | `{}` | no |
| vpc\_endpoint\_tags | Additional tags for the VPC Endpoints | map | `{}` | no |
| vpc\_tags | Additional tags for the VPC | map | `{}` | no |
| vpn\_gateway\_id | ID of VPN Gateway to attach to the VPC | string | `""` | no |
| vpn\_gateway\_tags | Additional tags for the VPN gateway | map | `{}` | no |
Expand Down
43 changes: 42 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ locals {
nat_gateway_count = "${var.single_nat_gateway ? 1 : (var.one_nat_gateway_per_az ? length(var.azs) : local.max_subnet_length)}"

# Use `local.vpc_id` to give a hint to Terraform that subnets should be deleted before secondary CIDR blocks can be free!
vpc_id = "${element(concat(aws_vpc_ipv4_cidr_block_association.this.*.vpc_id, aws_vpc.this.*.id, list("")), 0)}"
vpc_id = "${element(concat(aws_vpc_ipv4_cidr_block_association.this.*.vpc_id, aws_vpc.this.*.id, list("")), 0)}"
vpce_tags = "${merge(var.tags, var.vpc_endpoint_tags)}"
}

######
Expand Down Expand Up @@ -602,6 +603,8 @@ resource "aws_vpc_endpoint" "s3" {

vpc_id = "${local.vpc_id}"
service_name = "${data.aws_vpc_endpoint_service.s3.service_name}"

tags = "${local.vpce_tags}"
}

resource "aws_vpc_endpoint_route_table_association" "private_s3" {
Expand Down Expand Up @@ -639,6 +642,8 @@ resource "aws_vpc_endpoint" "dynamodb" {

vpc_id = "${local.vpc_id}"
service_name = "${data.aws_vpc_endpoint_service.dynamodb.service_name}"

tags = "${local.vpce_tags}"
}

resource "aws_vpc_endpoint_route_table_association" "private_dynamodb" {
Expand Down Expand Up @@ -681,6 +686,8 @@ resource "aws_vpc_endpoint" "sqs" {
security_group_ids = ["${var.sqs_endpoint_security_group_ids}"]
subnet_ids = ["${coalescelist(var.sqs_endpoint_subnet_ids, aws_subnet.private.*.id)}"]
private_dns_enabled = "${var.sqs_endpoint_private_dns_enabled}"

tags = "${local.vpce_tags}"
}

#######################
Expand All @@ -702,6 +709,8 @@ resource "aws_vpc_endpoint" "ssm" {
security_group_ids = ["${var.ssm_endpoint_security_group_ids}"]
subnet_ids = ["${coalescelist(var.ssm_endpoint_subnet_ids, aws_subnet.private.*.id)}"]
private_dns_enabled = "${var.ssm_endpoint_private_dns_enabled}"

tags = "${local.vpce_tags}"
}

###############################
Expand All @@ -723,6 +732,8 @@ resource "aws_vpc_endpoint" "ssmmessages" {
security_group_ids = ["${var.ssmmessages_endpoint_security_group_ids}"]
subnet_ids = ["${coalescelist(var.ssmmessages_endpoint_subnet_ids, aws_subnet.private.*.id)}"]
private_dns_enabled = "${var.ssmmessages_endpoint_private_dns_enabled}"

tags = "${local.vpce_tags}"
}

#######################
Expand All @@ -744,6 +755,8 @@ resource "aws_vpc_endpoint" "ec2" {
security_group_ids = ["${var.ec2_endpoint_security_group_ids}"]
subnet_ids = ["${coalescelist(var.ec2_endpoint_subnet_ids, aws_subnet.private.*.id)}"]
private_dns_enabled = "${var.ec2_endpoint_private_dns_enabled}"

tags = "${local.vpce_tags}"
}

###############################
Expand All @@ -765,6 +778,8 @@ resource "aws_vpc_endpoint" "ec2messages" {
security_group_ids = ["${var.ec2messages_endpoint_security_group_ids}"]
subnet_ids = ["${coalescelist(var.ec2messages_endpoint_subnet_ids, aws_subnet.private.*.id)}"]
private_dns_enabled = "${var.ec2messages_endpoint_private_dns_enabled}"

tags = "${local.vpce_tags}"
}

###########################
Expand All @@ -786,6 +801,8 @@ resource "aws_vpc_endpoint" "ecr_api" {
security_group_ids = ["${var.ecr_api_endpoint_security_group_ids}"]
subnet_ids = ["${coalescelist(var.ecr_api_endpoint_subnet_ids, aws_subnet.private.*.id)}"]
private_dns_enabled = "${var.ecr_api_endpoint_private_dns_enabled}"

tags = "${local.vpce_tags}"
}

###########################
Expand All @@ -807,6 +824,8 @@ resource "aws_vpc_endpoint" "ecr_dkr" {
security_group_ids = ["${var.ecr_dkr_endpoint_security_group_ids}"]
subnet_ids = ["${coalescelist(var.ecr_dkr_endpoint_subnet_ids, aws_subnet.private.*.id)}"]
private_dns_enabled = "${var.ecr_dkr_endpoint_private_dns_enabled}"

tags = "${local.vpce_tags}"
}

#######################
Expand All @@ -828,6 +847,8 @@ resource "aws_vpc_endpoint" "apigw" {
security_group_ids = ["${var.apigw_endpoint_security_group_ids}"]
subnet_ids = ["${coalescelist(var.apigw_endpoint_subnet_ids, aws_subnet.private.*.id)}"]
private_dns_enabled = "${var.apigw_endpoint_private_dns_enabled}"

tags = "${local.vpce_tags}"
}

#######################
Expand All @@ -849,6 +870,8 @@ resource "aws_vpc_endpoint" "kms" {
security_group_ids = ["${var.kms_endpoint_security_group_ids}"]
subnet_ids = ["${coalescelist(var.kms_endpoint_subnet_ids, aws_subnet.private.*.id)}"]
private_dns_enabled = "${var.kms_endpoint_private_dns_enabled}"

tags = "${local.vpce_tags}"
}

#######################
Expand All @@ -870,6 +893,8 @@ resource "aws_vpc_endpoint" "ecs" {
security_group_ids = ["${var.ecs_endpoint_security_group_ids}"]
subnet_ids = ["${coalescelist(var.ecs_endpoint_subnet_ids, aws_subnet.private.*.id)}"]
private_dns_enabled = "${var.ecs_endpoint_private_dns_enabled}"

tags = "${local.vpce_tags}"
}

#######################
Expand All @@ -891,6 +916,8 @@ resource "aws_vpc_endpoint" "ecs_agent" {
security_group_ids = ["${var.ecs_agent_endpoint_security_group_ids}"]
subnet_ids = ["${coalescelist(var.ecs_agent_endpoint_subnet_ids, aws_subnet.private.*.id)}"]
private_dns_enabled = "${var.ecs_agent_endpoint_private_dns_enabled}"

tags = "${local.vpce_tags}"
}

#######################
Expand All @@ -912,6 +939,8 @@ resource "aws_vpc_endpoint" "ecs_telemetry" {
security_group_ids = ["${var.ecs_telemetry_endpoint_security_group_ids}"]
subnet_ids = ["${coalescelist(var.ecs_telemetry_endpoint_subnet_ids, aws_subnet.private.*.id)}"]
private_dns_enabled = "${var.ecs_telemetry_endpoint_private_dns_enabled}"

tags = "${local.vpce_tags}"
}

#######################
Expand All @@ -933,6 +962,8 @@ resource "aws_vpc_endpoint" "elasticloadbalancing" {
security_group_ids = ["${var.elasticloadbalancing_endpoint_security_group_ids}"]
subnet_ids = ["${coalescelist(var.elasticloadbalancing_endpoint_subnet_ids, aws_subnet.private.*.id)}"]
private_dns_enabled = "${var.elasticloadbalancing_endpoint_private_dns_enabled}"

tags = "${local.vpce_tags}"
}

#######################
Expand All @@ -954,6 +985,8 @@ resource "aws_vpc_endpoint" "sns" {
security_group_ids = ["${var.sns_endpoint_security_group_ids}"]
subnet_ids = ["${coalescelist(var.sns_endpoint_subnet_ids, aws_subnet.private.*.id)}"]
private_dns_enabled = "${var.sns_endpoint_private_dns_enabled}"

tags = "${local.vpce_tags}"
}

#######################
Expand All @@ -975,6 +1008,8 @@ resource "aws_vpc_endpoint" "logs" {
security_group_ids = ["${var.logs_endpoint_security_group_ids}"]
subnet_ids = ["${coalescelist(var.logs_endpoint_subnet_ids, aws_subnet.private.*.id)}"]
private_dns_enabled = "${var.logs_endpoint_private_dns_enabled}"

tags = "${local.vpce_tags}"
}

#######################
Expand All @@ -996,6 +1031,8 @@ resource "aws_vpc_endpoint" "cloudtrail" {
security_group_ids = ["${var.cloudtrail_endpoint_security_group_ids}"]
subnet_ids = ["${coalescelist(var.cloudtrail_endpoint_subnet_ids, aws_subnet.private.*.id)}"]
private_dns_enabled = "${var.cloudtrail_endpoint_private_dns_enabled}"

tags = "${local.vpce_tags}"
}

#######################
Expand All @@ -1017,6 +1054,8 @@ resource "aws_vpc_endpoint" "monitoring" {
security_group_ids = ["${var.monitoring_endpoint_security_group_ids}"]
subnet_ids = ["${coalescelist(var.monitoring_endpoint_subnet_ids, aws_subnet.private.*.id)}"]
private_dns_enabled = "${var.monitoring_endpoint_private_dns_enabled}"

tags = "${local.vpce_tags}"
}

#######################
Expand All @@ -1038,6 +1077,8 @@ resource "aws_vpc_endpoint" "events" {
security_group_ids = ["${var.events_endpoint_security_group_ids}"]
subnet_ids = ["${coalescelist(var.events_endpoint_subnet_ids, aws_subnet.private.*.id)}"]
private_dns_enabled = "${var.events_endpoint_private_dns_enabled}"

tags = "${local.vpce_tags}"
}

##########################
Expand Down
5 changes: 5 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,11 @@ variable "vpn_gateway_tags" {
default = {}
}

variable "vpc_endpoint_tags" {
description = "Additional tags for the VPC Endpoints"
default = {}
}

variable "enable_dhcp_options" {
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"
default = false
Expand Down