Skip to content

Commit

Permalink
AWS: Add Service endpoints to VPC
Browse files Browse the repository at this point in the history
Add service endpoints for AWS Services used in kops-ci account.

Signed-off-by: Arnaud Meukam <ameukam@gmail.com>
  • Loading branch information
ameukam committed Dec 4, 2023
1 parent d829056 commit 339b564
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions infra/aws/terraform/kops-infra-ci/vpc.tf
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,51 @@ module "vpc" {
"region" = "${data.aws_region.current.name}"
})
}

################################################################################
# VPC Endpoints
################################################################################

module "vpc_endpoints" {
providers = {
aws = aws.kops-infra-ci
}

source = "terraform-aws-modules/vpc/aws//modules/vpc-endpoints"
version = "~> 5.2"

vpc_id = module.vpc.vpc_id

# Security group
create_security_group = true
security_group_name_prefix = "${local.prefix}-vpc-endpoints-"
security_group_description = "VPC endpoint security group"
security_group_rules = {
ingress_https = {
description = "HTTPS from VPC"
cidr_blocks = [module.vpc.vpc_cidr_block]
}
}

endpoints = merge({
s3 = {
service = "s3"
service_type = "Gateway"
route_table_ids = module.vpc.private_route_table_ids
tags = {
Name = "${local.prefix}-s3"
}
}
},
{ for service in toset(["autoscaling", "ecr.api", "ecr.dkr", "ec2", "ec2messages", "eks-auth", "elasticloadbalancing", "events", "sts", "kms", "logs", "sqs", "ssm", "ssmmessages"]) :
replace(service, ".", "_") =>
{
service = service
subnet_ids = module.vpc.private_subnets
private_dns_enabled = true
tags = { Name = "${local.prefix}-${service}" }
}
})

tags = var.tags
}

0 comments on commit 339b564

Please sign in to comment.