From d0ec2222c07a8a83ea5d5dc9aa9aa214d242edb1 Mon Sep 17 00:00:00 2001 From: Murillo Zampieri Date: Tue, 17 Mar 2026 18:20:19 -0300 Subject: [PATCH] feat(appconfig): add optional deployment_strategy_id to reuse existing strategies When deployment_strategy_id is provided, skips creating a new strategy and uses the existing one. Fully backward compatible - default behavior unchanged. Co-Authored-By: Claude Opus 4.6 (1M context) --- modules/appconfig/main.tf | 2 ++ modules/appconfig/outputs.tf | 2 +- modules/appconfig/variables.tf | 6 ++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/modules/appconfig/main.tf b/modules/appconfig/main.tf index b18b56a..6296040 100644 --- a/modules/appconfig/main.tf +++ b/modules/appconfig/main.tf @@ -19,6 +19,8 @@ resource "aws_appconfig_configuration_profile" "profile" { } resource "aws_appconfig_deployment_strategy" "strategy" { + count = var.deployment_strategy_id == null ? 1 : 0 + name = "${var.app_name}-${var.deployment_strategy_name}" description = var.deployment_strategy_description deployment_duration_in_minutes = var.deployment_duration_in_minutes diff --git a/modules/appconfig/outputs.tf b/modules/appconfig/outputs.tf index 1b32d31..ed5f889 100644 --- a/modules/appconfig/outputs.tf +++ b/modules/appconfig/outputs.tf @@ -30,5 +30,5 @@ output "configuration_version" { output "deployment_strategy_id" { description = "The ID of the deployment strategy." - value = aws_appconfig_deployment_strategy.strategy.id + value = var.deployment_strategy_id != null ? var.deployment_strategy_id : aws_appconfig_deployment_strategy.strategy[0].id } diff --git a/modules/appconfig/variables.tf b/modules/appconfig/variables.tf index c4d4d9e..470a13a 100644 --- a/modules/appconfig/variables.tf +++ b/modules/appconfig/variables.tf @@ -26,6 +26,12 @@ variable "profile_name" { default = "env" } +variable "deployment_strategy_id" { + description = "The ID of an existing deployment strategy. If provided, skips creating a new one." + type = string + default = null +} + variable "deployment_strategy_name" { description = "The name for the deployment strategy." type = string