From 4ffd07c27e3d886e350850fe6da7adc4e80bfeca Mon Sep 17 00:00:00 2001 From: Tim Holm Date: Fri, 13 Dec 2024 11:59:46 +1100 Subject: [PATCH] fix(awstf): add random id for secrets --- cloud/aws/deploytf/.nitric/modules/secret/main.tf | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/cloud/aws/deploytf/.nitric/modules/secret/main.tf b/cloud/aws/deploytf/.nitric/modules/secret/main.tf index 8f40237fc..0da609b06 100644 --- a/cloud/aws/deploytf/.nitric/modules/secret/main.tf +++ b/cloud/aws/deploytf/.nitric/modules/secret/main.tf @@ -1,7 +1,18 @@ + +resource "random_id" "secret_id" { + byte_length = 4 + + prefix = "${var.secret_name}-" + keepers = { + # Generate a new id each time we switch to a new AMI id + secret_name = var.secret_name + } +} + # Create a new AWS secret manager secret resource "aws_secretsmanager_secret" "secret" { - name = var.secret_name + name = random_id.secret_id.hex tags = { "x-nitric-${var.stack_id}-name" = var.secret_name "x-nitric-${var.stack_id}-type" = "secret"