最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

amazon web services - Deployment Not Using Latest SSM Parameter Store Version - Stack Overflow

programmeradmin6浏览0评论

I’m using Terraform to manage AWS AppConfig with configuration stored in SSM Parameter Store. When I update the SSM parameter, a new hosted configuration version is created (e.g., current version is 24), but my AppConfig deployment always uses an older version (e.g., 1, 2, 3, 4) instead of the latest version 24.

Key Details:

  1. SSM Parameter Store: Holds my JSON configuration.
  2. Hosted Configuration Version: Created using the SSM parameter value.
  3. Deployment Issue: Deployment always references an outdated version number, not the new one.
  4. Attempts: Tried triggers, lifecycle modifications, and other dependency tweaks with no success

Question:

How can I modify this configuration so that when the SSM parameter value changes, the deployment always picks up the latest hosted configuration version? What adjustments (if any) are needed in dependencies or resource triggers to ensure the newest version is used?

Any guidance would be greatly appreciated—thanks in advance!

resource "aws_ssm_parameter" "myapp_json" {
  name        = "/config/ecs/myapp"
  type        = "String"
  value       = jsonencode({
    location   = var.location
    entryFee     = var.entryFee
  })
  description = "${var.environment} AppConfig JSON configuration"
}

output "myapp_value" {
  value = aws_ssm_parameter.myapp_json.value
}

resource "aws_appconfig_application" "myapp" {
  name        = var.name_prefix
  description = "AWS AppConfig application for myapp"
}

resource "aws_appconfig_configuration_profile" "myprofile" {
  application_id     = aws_appconfig_application.myapp.id
  name               = "${var.environment}-profile"
  description        = "Dev Configuration profile"
  location_uri       = "ssm-parameter://${aws_ssm_parameter.myapp_json.name}"
  retrieval_role_arn = aws_iam_role.appconfig_role.arn
}

resource "aws_appconfig_environment" "myenv" {
  application_id = aws_appconfig_application.myapp.id
  name           = var.environment
  description    = "Environment for ${var.environment}"
}

resource "aws_appconfig_hosted_configuration_version" "myconfig" {
  depends_on               = [aws_ssm_parameter.myapp_json]
  application_id           = aws_appconfig_application.myapp.id
  configuration_profile_id = aws_appconfig_configuration_profile.myprofile.configuration_profile_id
  description              = "Hosted Configuration Version"
  content_type             = "application/json"
  content                  = aws_ssm_parameter.myapp_json.value

  lifecycle {
    create_before_destroy = true
  }
}

resource "aws_appconfig_deployment_strategy" "mydeploystrategy" {
  name                           = "${var.environment}-deployment-strategy"
  description                    = "Deployment Strategy"
  deployment_duration_in_minutes = 1
  final_bake_time_in_minutes     = 1
  growth_factor                  = 20
  growth_type                    = "LINEAR"
  replicate_to                   = "NONE"
  tags = {
    Type = "${var.environment} AppConfig Deployment Strategy"
  }
}

resource "aws_appconfig_deployment" "mydeployment" {
  depends_on = [aws_appconfig_hosted_configuration_version.myconfig]
  application_id           = aws_appconfig_application.myapp.id
  configuration_profile_id = aws_appconfig_configuration_profile.myprofile.configuration_profile_id
  configuration_version    = aws_appconfig_hosted_configuration_version.myconfig.version_number
  deployment_strategy_id   = aws_appconfig_deployment_strategy.mydeploystrategy.id
  description              = "${var.environment} deployment"
  environment_id           = aws_appconfig_environment.myenv.environment_id
}
发布评论

评论列表(0)

  1. 暂无评论