Skip to content

Commit a1f5e18

Browse files
committed
fix: ensure unique names for infrastructure resources
resources updated - fargate, lambda, loadbalancer, vpc, cloudfront, security group relies on - nitrictech/monk#103 which injects the stack_id
1 parent a94da94 commit a1f5e18

8 files changed

Lines changed: 27 additions & 8 deletions

File tree

‎cloudfront/module/main.tf‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ resource "aws_acm_certificate" "cloudfront_cert" {
332332

333333
resource "aws_cloudfront_cache_policy" "default_cache_policy" {
334334
count = var.default_cache_policy_id == null ? 1 : 0
335-
name = "SugaDefaultCachePolicy"
335+
name = "${var.suga.stack_id}-SugaDefaultCachePolicy"
336336
comment = "Default cache policy for CloudFront distribution for Suga Applications"
337337

338338
# Set TTL defaults to respect cache control headers

‎fargate/module/main.tf‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Create an ECR repository
22
resource "aws_ecr_repository" "repo" {
3-
name = var.suga.name
3+
name = "${var.suga.stack_id}-${var.suga.name}"
44
}
55

66
data "aws_ecr_authorization_token" "ecr_auth" {

‎lambda/module/main.tf‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ locals {
2929

3030
# Create an ECR repository
3131
resource "aws_ecr_repository" "repo" {
32-
name = var.suga.name
32+
name = "${var.suga.stack_id}-${var.suga.name}"
3333
image_scanning_configuration {
3434
scan_on_push = var.image_scan_on_push
3535
}

‎loadbalancer/module/main.tf‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
resource "aws_lb" "lb" {
2-
name = var.name
2+
name = "${var.suga.stack_id}-${var.name}"
33
internal = var.internal
44
load_balancer_type = var.load_balancer_type
55
security_groups = var.security_groups

‎loadbalancer/module/variables.tf‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1-
variable "load_balancer_type" {
2-
type = string
3-
default = "application"
1+
variable "suga" {
2+
type = object({
3+
stack_id = string
4+
})
45
}
56

67
variable "name" {
78
type = string
89
}
910

11+
variable "load_balancer_type" {
12+
type = string
13+
default = "application"
14+
}
15+
1016
variable "listener_port" {
1117
type = number
1218
default = 80

‎sgrule/module/variables.tf‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
variable "suga" {
2+
type = object({
3+
stack_id = string
4+
})
5+
}
6+
17
variable "security_group_ids" {
28
type = list(string)
39
description = "List of security group IDs to which the rule will be applied"

‎vpc/module/main.tf‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ locals {
1010
module "vpc" {
1111
source = "terraform-aws-modules/vpc/aws"
1212

13-
name = var.name
13+
name = "${var.suga.stack_id}-${var.name}"
1414
cidr = var.networking.cidr_block
1515

1616
azs = local.azs

‎vpc/module/variables.tf‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1+
variable "suga" {
2+
type = object({
3+
stack_id = string
4+
})
5+
}
6+
17
variable "name" {
28
type = string
39
description = "The name of the VPC"
410
}
11+
512
variable "networking" {
613
type = object({
714
cidr_block = string

0 commit comments

Comments
 (0)