Skip to content

Commit 5326d93

Browse files
authored
feat: Add ability to create CodeDeploy endpoint to VPC (#501)
1 parent b336961 commit 5326d93

File tree

4 files changed

+112
-5
lines changed

4 files changed

+112
-5
lines changed

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Git-Codecommit, Transfer Server, Kinesis Streams, Kinesis Firehose, SageMaker(No
2626
CloudFormation, CodePipeline, Storage Gateway, AppMesh, Transfer, Service Catalog, AppStream,
2727
Athena, Rekognition, Elastic File System (EFS), Cloud Directory, Elastic Beanstalk (+ Health), Elastic Map Reduce(EMR),
2828
DataSync, EBS, SMS, Elastic Inference Runtime, QLDB Session, Step Functions, Access Analyzer, Auto Scaling Plans,
29-
Application Auto Scaling, Workspaces, ACM PCA, RDS.
29+
Application Auto Scaling, Workspaces, ACM PCA, RDS, CodeDeploy, CodeDeploy Commands Secure
3030

3131
* [RDS DB Subnet Group](https://www.terraform.io/docs/providers/aws/r/db_subnet_group.html)
3232
* [ElastiCache Subnet Group](https://www.terraform.io/docs/providers/aws/r/elasticache_subnet_group.html)
@@ -277,6 +277,12 @@ It is possible to integrate this VPC module with [terraform-aws-transit-gateway
277277
| codecommit\_endpoint\_private\_dns\_enabled | Whether or not to associate a private hosted zone with the specified VPC for Codecommit endpoint | `bool` | `false` | no |
278278
| codecommit\_endpoint\_security\_group\_ids | The ID of one or more security groups to associate with the network interface for Codecommit endpoint | `list` | `[]` | no |
279279
| codecommit\_endpoint\_subnet\_ids | The ID of one or more subnets in which to create a network interface for Codecommit endpoint. Only a single subnet within an AZ is supported. If omitted, private subnets will be used. | `list` | `[]` | no |
280+
| codedeploy\_commands\_secure\_endpoint\_private\_dns\_enabled | Whether or not to associate a private hosted zone with the specified VPC for CodeDeploy Commands Secure endpoint | `bool` | `false` | no |
281+
| codedeploy\_commands\_secure\_endpoint\_security\_group\_ids | The ID of one or more security groups to associate with the network interface for CodeDeploy Commands Secure endpoint | `list(string)` | `[]` | no |
282+
| codedeploy\_commands\_secure\_endpoint\_subnet\_ids | The ID of one or more subnets in which to create a network interface for CodeDeploy Commands Secure endpoint. Only a single subnet within an AZ is supported. If omitted, private subnets will be used. | `list(string)` | `[]` | no |
283+
| codedeploy\_endpoint\_private\_dns\_enabled | Whether or not to associate a private hosted zone with the specified VPC for CodeDeploy endpoint | `bool` | `false` | no |
284+
| codedeploy\_endpoint\_security\_group\_ids | The ID of one or more security groups to associate with the network interface for CodeDeploy endpoint | `list(string)` | `[]` | no |
285+
| codedeploy\_endpoint\_subnet\_ids | The ID of one or more subnets in which to create a network interface for CodeDeploy endpoint. Only a single subnet within an AZ is supported. If omitted, private subnets will be used. | `list(string)` | `[]` | no |
280286
| codepipeline\_endpoint\_private\_dns\_enabled | Whether or not to associate a private hosted zone with the specified VPC for CodePipeline endpoint | `bool` | `false` | no |
281287
| codepipeline\_endpoint\_security\_group\_ids | The ID of one or more security groups to associate with the network interface for CodePipeline endpoint | `list(string)` | `[]` | no |
282288
| codepipeline\_endpoint\_subnet\_ids | The ID of one or more subnets in which to create a network interface for CodePipeline endpoint. Only a single subnet within an AZ is supported. If omitted, private subnets will be used. | `list(string)` | `[]` | no |
@@ -400,6 +406,8 @@ It is possible to integrate this VPC module with [terraform-aws-transit-gateway
400406
| enable\_cloudtrail\_endpoint | Should be true if you want to provision a CloudTrail endpoint to the VPC | `bool` | `false` | no |
401407
| enable\_codebuild\_endpoint | Should be true if you want to provision an Codebuild endpoint to the VPC | `bool` | `false` | no |
402408
| enable\_codecommit\_endpoint | Should be true if you want to provision an Codecommit endpoint to the VPC | `bool` | `false` | no |
409+
| enable\_codedeploy\_commands\_secure\_endpoint | Should be true if you want to provision an CodeDeploy Commands Secure endpoint to the VPC | `bool` | `false` | no |
410+
| enable\_codedeploy\_endpoint | Should be true if you want to provision an CodeDeploy endpoint to the VPC | `bool` | `false` | no |
403411
| enable\_codepipeline\_endpoint | Should be true if you want to provision a CodePipeline endpoint to the VPC | `bool` | `false` | no |
404412
| enable\_config\_endpoint | Should be true if you want to provision an config endpoint to the VPC | `bool` | `false` | no |
405413
| enable\_datasync\_endpoint | Should be true if you want to provision an Data Sync endpoint to the VPC | `bool` | `false` | no |

examples/complete-vpc/main.tf

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,15 @@ module "vpc" {
101101
ecs_telemetry_endpoint_private_dns_enabled = true
102102
ecs_telemetry_endpoint_security_group_ids = [data.aws_security_group.default.id]
103103

104-
# VPC endpoint for SQS
105-
enable_sqs_endpoint = true
106-
sqs_endpoint_private_dns_enabled = true
107-
sqs_endpoint_security_group_ids = [data.aws_security_group.default.id]
104+
# VPC endpoint for CodeDeploy
105+
enable_codedeploy_endpoint = true
106+
codedeploy_endpoint_private_dns_enabled = true
107+
codedeploy_endpoint_security_group_ids = [data.aws_security_group.default.id]
108+
109+
# VPC endpoint for CodeDeploy Commands Secure
110+
enable_codedeploy_commands_secure_endpoint = true
111+
codedeploy_commands_secure_endpoint_private_dns_enabled = true
112+
codedeploy_commands_secure_endpoint_security_group_ids = [data.aws_security_group.default.id]
108113

109114
# Default security group - ingress/egress rules cleared to deny all
110115
manage_default_security_group = true

variables.tf

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1670,6 +1670,54 @@ variable "rds_endpoint_private_dns_enabled" {
16701670
default = false
16711671
}
16721672

1673+
variable "enable_codedeploy_endpoint" {
1674+
description = "Should be true if you want to provision an CodeDeploy endpoint to the VPC"
1675+
type = bool
1676+
default = false
1677+
}
1678+
1679+
variable "codedeploy_endpoint_security_group_ids" {
1680+
description = "The ID of one or more security groups to associate with the network interface for CodeDeploy endpoint"
1681+
type = list(string)
1682+
default = []
1683+
}
1684+
1685+
variable "codedeploy_endpoint_subnet_ids" {
1686+
description = "The ID of one or more subnets in which to create a network interface for CodeDeploy endpoint. Only a single subnet within an AZ is supported. If omitted, private subnets will be used."
1687+
type = list(string)
1688+
default = []
1689+
}
1690+
1691+
variable "codedeploy_endpoint_private_dns_enabled" {
1692+
description = "Whether or not to associate a private hosted zone with the specified VPC for CodeDeploy endpoint"
1693+
type = bool
1694+
default = false
1695+
}
1696+
1697+
variable "enable_codedeploy_commands_secure_endpoint" {
1698+
description = "Should be true if you want to provision an CodeDeploy Commands Secure endpoint to the VPC"
1699+
type = bool
1700+
default = false
1701+
}
1702+
1703+
variable "codedeploy_commands_secure_endpoint_security_group_ids" {
1704+
description = "The ID of one or more security groups to associate with the network interface for CodeDeploy Commands Secure endpoint"
1705+
type = list(string)
1706+
default = []
1707+
}
1708+
1709+
variable "codedeploy_commands_secure_endpoint_subnet_ids" {
1710+
description = "The ID of one or more subnets in which to create a network interface for CodeDeploy Commands Secure endpoint. Only a single subnet within an AZ is supported. If omitted, private subnets will be used."
1711+
type = list(string)
1712+
default = []
1713+
}
1714+
1715+
variable "codedeploy_commands_secure_endpoint_private_dns_enabled" {
1716+
description = "Whether or not to associate a private hosted zone with the specified VPC for CodeDeploy Commands Secure endpoint"
1717+
type = bool
1718+
default = false
1719+
}
1720+
16731721
variable "acm_pca_endpoint_security_group_ids" {
16741722
description = "The ID of one or more security groups to associate with the network interface for ACM PCA endpoint"
16751723
default = []

vpc-endpoints.tf

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,3 +1371,49 @@ resource "aws_vpc_endpoint" "rds" {
13711371

13721372
tags = local.vpce_tags
13731373
}
1374+
1375+
#############################
1376+
# VPC Endpoint for CodeDeploy
1377+
#############################
1378+
data "aws_vpc_endpoint_service" "codedeploy" {
1379+
count = var.create_vpc && var.enable_codedeploy_endpoint ? 1 : 0
1380+
1381+
service = "codedeploy"
1382+
}
1383+
1384+
resource "aws_vpc_endpoint" "codedeploy" {
1385+
count = var.create_vpc && var.enable_codedeploy_endpoint ? 1 : 0
1386+
1387+
vpc_id = local.vpc_id
1388+
service_name = data.aws_vpc_endpoint_service.codedeploy[0].service_name
1389+
vpc_endpoint_type = "Interface"
1390+
1391+
security_group_ids = var.codedeploy_endpoint_security_group_ids
1392+
subnet_ids = coalescelist(var.codedeploy_endpoint_subnet_ids, aws_subnet.private.*.id)
1393+
private_dns_enabled = var.codedeploy_endpoint_private_dns_enabled
1394+
1395+
tags = local.vpce_tags
1396+
}
1397+
1398+
#############################################
1399+
# VPC Endpoint for CodeDeploy Commands Secure
1400+
#############################################
1401+
data "aws_vpc_endpoint_service" "codedeploy_commands_secure" {
1402+
count = var.create_vpc && var.enable_codedeploy_commands_secure_endpoint ? 1 : 0
1403+
1404+
service = "codedeploy-commands-secure"
1405+
}
1406+
1407+
resource "aws_vpc_endpoint" "codedeploy_commands_secure" {
1408+
count = var.create_vpc && var.enable_codedeploy_commands_secure_endpoint ? 1 : 0
1409+
1410+
vpc_id = local.vpc_id
1411+
service_name = data.aws_vpc_endpoint_service.codedeploy_commands_secure[0].service_name
1412+
vpc_endpoint_type = "Interface"
1413+
1414+
security_group_ids = var.codedeploy_commands_secure_endpoint_security_group_ids
1415+
subnet_ids = coalescelist(var.codedeploy_commands_secure_endpoint_subnet_ids, aws_subnet.private.*.id)
1416+
private_dns_enabled = var.codedeploy_commands_secure_endpoint_private_dns_enabled
1417+
1418+
tags = local.vpce_tags
1419+
}

0 commit comments

Comments
 (0)