Skip to content

DT-523 add vpc s3 endpoint resource #28

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

Merged
merged 8 commits into from
May 28, 2025
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
8 changes: 7 additions & 1 deletion .terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module "comet_vpc" {
source = "./modules/comet_vpc"
count = var.enable_vpc ? 1 : 0
environment = var.environment
region = var.region

eks_enabled = var.enable_eks
single_nat_gateway = var.single_nat_gateway
Expand Down
11 changes: 11 additions & 0 deletions modules/comet_vpc/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,15 @@ module "vpc" {
private_subnet_tags = var.eks_enabled ? { "kubernetes.io/role/internal-elb" = 1 } : null

tags = local.tags
}

resource "aws_vpc_endpoint" "s3" {
vpc_id = module.vpc.vpc_id
service_name = "com.amazonaws.${var.region}.s3"
Copy link
Preview

Copilot AI May 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoding the partition as com.amazonaws may break in GovCloud or China partitions—use the data.aws_partition source to build the service name dynamically.

Copilot uses AI. Check for mistakes.

vpc_endpoint_type = "Gateway"
route_table_ids = concat(module.vpc.private_route_table_ids, module.vpc.public_route_table_ids)
tags = merge(
local.tags,
{ Name = "${local.resource_name}-s3-endpoint" }
)
}
5 changes: 5 additions & 0 deletions modules/comet_vpc/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,9 @@ variable "eks_enabled" {
variable "single_nat_gateway" {
description = "Controls whether single NAT gateway used for all public subnets"
type = bool
}

variable "region" {
description = "AWS region to provision resources in"
type = string
Copy link
Preview

Copilot AI May 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider adding a validation block to the region variable to enforce only supported AWS region identifiers (e.g., us-east-1, eu-west-1).

Suggested change
type = string
type = string
validation {
condition = can(regex("^([a-z]{2}-[a-z]+-[0-9]{1})$", var.region))
error_message = "The region must be a valid AWS region identifier, e.g., 'us-east-1', 'eu-west-1'."
}

Copilot uses AI. Check for mistakes.

}
4 changes: 2 additions & 2 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ variable "elasticache_engine" {
variable "elasticache_engine_version" {
description = "Version number for ElastiCache engine"
type = string
default = "7.1.0"
default = "7.1"
}

variable "elasticache_instance_type" {
Expand All @@ -270,7 +270,7 @@ variable "elasticache_instance_type" {
variable "elasticache_param_group_name" {
description = "Name for the ElastiCache cluster parameter group"
type = string
default = "default.redis5.0"
default = "default.redis7"
}

variable "elasticache_num_cache_nodes" {
Expand Down