Skip to content
Closed
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
14 changes: 10 additions & 4 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
locals {
# VPC - existing or new?
vpc_id = var.vpc_id == "" ? module.vpc.vpc_id : var.vpc_id
private_subnet_ids = coalescelist(module.vpc.private_subnets, var.private_subnet_ids, [""])
public_subnet_ids = coalescelist(module.vpc.public_subnets, var.public_subnet_ids, [""])
vpc_id = var.vpc_id == "" ? module.vpc.vpc_id : var.vpc_id
efs_sg_ingress_cidr = [ var.cidr == "" ? data.aws_vpc.this.cidr : var.cidr ]
private_subnet_ids = coalescelist(module.vpc.private_subnets, var.private_subnet_ids, [""])
public_subnet_ids = coalescelist(module.vpc.public_subnets, var.public_subnet_ids, [""])

# Atlantis
atlantis_image = var.atlantis_image == "" ? "ghcr.io/runatlantis/atlantis:${var.atlantis_version}" : var.atlantis_image
Expand Down Expand Up @@ -137,6 +138,10 @@ data "aws_route53_zone" "this" {
private_zone = var.route53_private_zone
}

data "aws_vpc" "this" {
id = local.vpc_id
}

################################################################################
# Secret for webhook
################################################################################
Expand Down Expand Up @@ -383,7 +388,8 @@ module "efs_sg" {
vpc_id = local.vpc_id
description = "Security group allowing access to the EFS storage"

ingress_cidr_blocks = [var.cidr]
ingress_cidr_blocks = local.efs_sg_ingress_cidr
Copy link
Member

Choose a reason for hiding this comment

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

Looking at this whole security group makes me think that you don't need to allow ingress to the EFS volume from the entire VPC. Instead we can just rely on https://github.com/terraform-aws-modules/terraform-aws-atlantis/blob/master/main.tf#L387-L390, which already allows nfs-tcp from the Atlantis security group.


ingress_with_source_security_group_id = [{
rule = "nfs-tcp",
source_security_group_id = module.atlantis_sg.security_group_id
Expand Down