Skip to content

Commit 366d459

Browse files
authored
feat: Added Codeartifact API/Repo vpc endpoints (#515)
1 parent 22f2097 commit 366d459

File tree

4 files changed

+133
-1
lines changed

4 files changed

+133
-1
lines changed

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ These types of resources are supported:
2121
* Gateway: S3, DynamoDB
2222
* Interface: EC2, SSM, EC2 Messages, SSM Messages, SQS, ECR API, ECR DKR, API Gateway, KMS,
2323
ECS, ECS Agent, ECS Telemetry, SES, SNS, STS, Glue, CloudWatch(Monitoring, Logs, Events),
24-
Elastic Load Balancing, CloudTrail, Secrets Manager, Config, CodeBuild, CodeCommit,
24+
Elastic Load Balancing, CloudTrail, Secrets Manager, Config, Codeartifact(API, Repositories), CodeBuild, CodeCommit,
2525
Git-Codecommit, Textract, Transfer Server, Kinesis Streams, Kinesis Firehose, SageMaker(Notebook, Runtime, API),
2626
CloudFormation, CodePipeline, Storage Gateway, AppMesh, Transfer, Service Catalog, AppStream API, AppStream Streaming,
2727
Athena, Rekognition, Elastic File System (EFS), Cloud Directory, Elastic Beanstalk (+ Health), Elastic Map Reduce(EMR),
@@ -408,6 +408,8 @@ It is possible to integrate this VPC module with [terraform-aws-transit-gateway
408408
| enable\_cloud\_directory\_endpoint | Should be true if you want to provision an Cloud Directory endpoint to the VPC | `bool` | `false` | no |
409409
| enable\_cloudformation\_endpoint | Should be true if you want to provision a Cloudformation endpoint to the VPC | `bool` | `false` | no |
410410
| enable\_cloudtrail\_endpoint | Should be true if you want to provision a CloudTrail endpoint to the VPC | `bool` | `false` | no |
411+
| enable\_codeartifact_api\_endpoint | Should be true if you want to provision an Codeartifact API endpoint to the VPC | `bool` | `false` | no |
412+
| enable\_codeartifact_repositories\_endpoint | Should be true if you want to provision an Codeartifact repositories endpoint to the VPC | `bool` | `false` | no |
411413
| enable\_codebuild\_endpoint | Should be true if you want to provision an Codebuild endpoint to the VPC | `bool` | `false` | no |
412414
| enable\_codecommit\_endpoint | Should be true if you want to provision an Codecommit endpoint to the VPC | `bool` | `false` | no |
413415
| enable\_codedeploy\_commands\_secure\_endpoint | Should be true if you want to provision an CodeDeploy Commands Secure endpoint to the VPC | `bool` | `false` | no |
@@ -761,6 +763,12 @@ It is possible to integrate this VPC module with [terraform-aws-transit-gateway
761763
| vpc\_endpoint\_cloudtrail\_dns\_entry | The DNS entries for the VPC Endpoint for CloudTrail. |
762764
| vpc\_endpoint\_cloudtrail\_id | The ID of VPC endpoint for CloudTrail |
763765
| vpc\_endpoint\_cloudtrail\_network\_interface\_ids | One or more network interfaces for the VPC Endpoint for CloudTrail. |
766+
| vpc\_endpoint\_codeartifact_api\_dns\_entry | The DNS entries for the VPC Endpoint for Codeartifact API. |
767+
| vpc\_endpoint\_codeartifact_api\_id | The ID of VPC endpoint for Codeartifact API |
768+
| vpc\_endpoint\_codeartifact_api\_network\_interface\_ids | One or more network interfaces for the VPC Endpoint for Codeartifact API. |
769+
| vpc\_endpoint\_codeartifact_repositories\_dns\_entry | The DNS entries for the VPC Endpoint for Codeartifact repositories. |
770+
| vpc\_endpoint\_codeartifact_repositories\_id | The ID of VPC endpoint for Codeartifact repositories |
771+
| vpc\_endpoint\_codeartifact_repositories\_network\_interface\_ids | One or more network interfaces for the VPC Endpoint for Codeartifact repositories. |
764772
| vpc\_endpoint\_codebuild\_dns\_entry | The DNS entries for the VPC Endpoint for codebuild. |
765773
| vpc\_endpoint\_codebuild\_id | The ID of VPC endpoint for codebuild |
766774
| vpc\_endpoint\_codebuild\_network\_interface\_ids | One or more network interfaces for the VPC Endpoint for codebuild. |

outputs.tf

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1362,6 +1362,36 @@ output "vpc_endpoint_textract_dns_entry" {
13621362
value = flatten(aws_vpc_endpoint.textract.*.dns_entry)
13631363
}
13641364

1365+
output "vpc_endpoint_codeartifact_api_id" {
1366+
description = "The ID of VPC endpoint for Codeartifact API"
1367+
value = concat(aws_vpc_endpoint.codeartifact_api.*.id, [""])[0]
1368+
}
1369+
1370+
output "vpc_endpoint_codeartifact_api_network_interface_ids" {
1371+
description = "One or more network interfaces for the VPC Endpoint for Codeartifact API."
1372+
value = flatten(aws_vpc_endpoint.codeartifact_api.*.network_interface_ids)
1373+
}
1374+
1375+
output "vpc_endpoint_codeartifact_api_dns_entry" {
1376+
description = "The DNS entries for the VPC Endpoint for Codeartifact API."
1377+
value = flatten(aws_vpc_endpoint.codeartifact_api.*.dns_entry)
1378+
}
1379+
1380+
output "vpc_endpoint_codeartifact_repositories_id" {
1381+
description = "The ID of VPC endpoint for Codeartifact repositories"
1382+
value = concat(aws_vpc_endpoint.codeartifact_repositories.*.id, [""])[0]
1383+
}
1384+
1385+
output "vpc_endpoint_codeartifact_repositories_network_interface_ids" {
1386+
description = "One or more network interfaces for the VPC Endpoint for Codeartifact repositories."
1387+
value = flatten(aws_vpc_endpoint.codeartifact_repositories.*.network_interface_ids)
1388+
}
1389+
1390+
output "vpc_endpoint_codeartifact_repositories_dns_entry" {
1391+
description = "The DNS entries for the VPC Endpoint for Codeartifact repositories."
1392+
value = flatten(aws_vpc_endpoint.codeartifact_repositories.*.dns_entry)
1393+
}
1394+
13651395
# VPC flow log
13661396
output "vpc_flow_log_id" {
13671397
description = "The ID of the Flow Log resource"

variables.tf

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,54 @@ variable "enable_s3_endpoint" {
322322
default = false
323323
}
324324

325+
variable "enable_codeartifact_api_endpoint" {
326+
description = "Should be true if you want to provision an Codeartifact API endpoint to the VPC"
327+
type = bool
328+
default = false
329+
}
330+
331+
variable "codeartifact_api_endpoint_security_group_ids" {
332+
description = "The ID of one or more security groups to associate with the network interface for Codeartifact API endpoint"
333+
type = list(string)
334+
default = []
335+
}
336+
337+
variable "codeartifact_api_endpoint_subnet_ids" {
338+
description = "The ID of one or more subnets in which to create a network interface for Codeartifact API endpoint. Only a single subnet within an AZ is supported. If omitted, private subnets will be used."
339+
type = list(string)
340+
default = []
341+
}
342+
343+
variable "codeartifact_api_endpoint_private_dns_enabled" {
344+
description = "Whether or not to associate a private hosted zone with the specified VPC for Codeartifact API endpoint"
345+
type = bool
346+
default = false
347+
}
348+
349+
variable "enable_codeartifact_repositories_endpoint" {
350+
description = "Should be true if you want to provision an Codeartifact repositories endpoint to the VPC"
351+
type = bool
352+
default = false
353+
}
354+
355+
variable "codeartifact_repositories_endpoint_security_group_ids" {
356+
description = "The ID of one or more security groups to associate with the network interface for Codeartifact repositories endpoint"
357+
type = list(string)
358+
default = []
359+
}
360+
361+
variable "codeartifact_repositories_endpoint_subnet_ids" {
362+
description = "The ID of one or more subnets in which to create a network interface for Codeartifact repositories endpoint. Only a single subnet within an AZ is supported. If omitted, private subnets will be used."
363+
type = list(string)
364+
default = []
365+
}
366+
367+
variable "codeartifact_repositories_endpoint_private_dns_enabled" {
368+
description = "Whether or not to associate a private hosted zone with the specified VPC for Codeartifact repositories endpoint"
369+
type = bool
370+
default = false
371+
}
372+
325373
variable "enable_codebuild_endpoint" {
326374
description = "Should be true if you want to provision an Codebuild endpoint to the VPC"
327375
type = bool

vpc-endpoints.tf

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1462,3 +1462,49 @@ resource "aws_vpc_endpoint" "textract" {
14621462

14631463
tags = local.vpce_tags
14641464
}
1465+
1466+
#############################################
1467+
# VPC Endpoint for Codeartifact API
1468+
#############################################
1469+
data "aws_vpc_endpoint_service" "codeartifact_api" {
1470+
count = var.create_vpc && var.enable_codeartifact_api_endpoint ? 1 : 0
1471+
1472+
service = "codeartifact.api"
1473+
}
1474+
1475+
resource "aws_vpc_endpoint" "codeartifact_api" {
1476+
count = var.create_vpc && var.enable_codeartifact_api_endpoint ? 1 : 0
1477+
1478+
vpc_id = local.vpc_id
1479+
service_name = data.aws_vpc_endpoint_service.codeartifact_api[0].service_name
1480+
vpc_endpoint_type = "Interface"
1481+
1482+
security_group_ids = var.codeartifact_api_endpoint_security_group_ids
1483+
subnet_ids = coalescelist(var.codeartifact_api_endpoint_subnet_ids, aws_subnet.private.*.id)
1484+
private_dns_enabled = var.codeartifact_api_endpoint_private_dns_enabled
1485+
1486+
tags = local.vpce_tags
1487+
}
1488+
1489+
#############################################
1490+
# VPC Endpoint for Codeartifact repositories
1491+
#############################################
1492+
data "aws_vpc_endpoint_service" "codeartifact_repositories" {
1493+
count = var.create_vpc && var.enable_codeartifact_repositories_endpoint ? 1 : 0
1494+
1495+
service = "codeartifact.repositories"
1496+
}
1497+
1498+
resource "aws_vpc_endpoint" "codeartifact_repositories" {
1499+
count = var.create_vpc && var.enable_codeartifact_repositories_endpoint ? 1 : 0
1500+
1501+
vpc_id = local.vpc_id
1502+
service_name = data.aws_vpc_endpoint_service.codeartifact_repositories[0].service_name
1503+
vpc_endpoint_type = "Interface"
1504+
1505+
security_group_ids = var.codeartifact_repositories_endpoint_security_group_ids
1506+
subnet_ids = coalescelist(var.codeartifact_repositories_endpoint_subnet_ids, aws_subnet.private.*.id)
1507+
private_dns_enabled = var.codeartifact_repositories_endpoint_private_dns_enabled
1508+
1509+
tags = local.vpce_tags
1510+
}

0 commit comments

Comments
 (0)