Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: AWS API ConflictException when creating multiple aws_appconfig_deployment resources #36975

Closed
demosito opened this issue Apr 18, 2024 · 6 comments · Fixed by #36980
Closed
Labels
aws-sdk-go-migration Issues that are related to the providers migration to AWS SDK for Go v2. bug Addresses a defect in current functionality. service/appconfig Issues and PRs that pertain to the appconfig service.
Milestone

Comments

@demosito
Copy link

Terraform Core Version

1.4.2

AWS Provider Version

5.44.0+

Affected Resource(s)

aws_appconfig_deployment

Expected Behavior

I have configuration that deploys multiple AWS Config configurations from a local list. See full main.tf in the configuration files field, here is the relevant piece:

locals {
  app_configs = {
    "conf1" = "content1"
    "conf2" = "content2"
    "conf3" = "content3"
  }
}

...

resource "aws_appconfig_deployment" "appconfig_deployment" {
  for_each                 = toset(keys(local.app_configs))
  application_id           = aws_appconfig_application.main.id
  configuration_profile_id = aws_appconfig_configuration_profile.profiles[each.key].configuration_profile_id
  configuration_version    = aws_appconfig_hosted_configuration_version.conf_version[each.key].version_number
  deployment_strategy_id   = aws_appconfig_deployment_strategy.instant.id
  environment_id           = aws_appconfig_environment.main.environment_id
}

This works just fine on TF1.2+ and AWS provider 5 until 5.44.0. v5.44 and 5.45 give the following error during apply:

│ Error: starting AppConfig Deployment: operation error AppConfig: StartDeployment, https response error StatusCode: 409, RequestID: 43e844da-818b-458e-aae2-553960ccc4d6, ConflictException: Deployment number 1 already exists
│
│   with aws_appconfig_deployment.appconfig_deployment["conf1"],
│   on main.tf line 56, in resource "aws_appconfig_deployment" "appconfig_deployment":
│   56: resource "aws_appconfig_deployment" "appconfig_deployment" {

Actual Behavior

AWS API error 409

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

terraform {                                                                                                                                                                 
required_version = "~> 1.0"
  required_providers {
    aws    = "= 5.44.0"
  }
}

provider "aws" {
  region = "eu-central-1"
}

locals {
  app_configs = {
    "conf1" = "content1"
    "conf2" = "content2"
    "conf3" = "content3"
  }
}

resource "aws_appconfig_application" "main" {
  name        = "test-appconfig"
  description = "Test"
}

resource "aws_appconfig_environment" "main" {
  name           = "test"
  application_id = aws_appconfig_application.main.id
}

resource "aws_appconfig_configuration_profile" "profiles" {
  for_each       = toset(keys(local.app_configs))
  application_id = aws_appconfig_application.main.id
  name           = format("%s_config", each.key)
  description    = format("%s config", title(each.key))
  location_uri   = "hosted"
}

resource "aws_appconfig_hosted_configuration_version" "conf_version" {
  for_each                 = toset(keys(local.app_configs))
  application_id           = aws_appconfig_application.main.id
  configuration_profile_id = aws_appconfig_configuration_profile.profiles[each.key].configuration_profile_id
  content_type             = "application/json"
  content                  = jsonencode(local.app_configs[each.key])
}

resource "aws_appconfig_deployment_strategy" "instant" {
  name                           = "Conf.Instant.Test"
  description                    = "Test Instant Deployment Strategy"
  deployment_duration_in_minutes = 0
  final_bake_time_in_minutes     = 0
  growth_factor                  = 100
  growth_type                    = "LINEAR"
  replicate_to                   = "NONE"
}

resource "aws_appconfig_deployment" "appconfig_deployment" {
  for_each                 = toset(keys(local.app_configs))
  application_id           = aws_appconfig_application.main.id
  configuration_profile_id = aws_appconfig_configuration_profile.profiles[each.key].configuration_profile_id
  configuration_version    = aws_appconfig_hosted_configuration_version.conf_version[each.key].version_number
  deployment_strategy_id   = aws_appconfig_deployment_strategy.instant.id
  environment_id           = aws_appconfig_environment.main.environment_id
}

Steps to Reproduce

Run terraform apploy with the configuration above.

Debug Output

tf_debug_log.txt

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

@demosito demosito added the bug Addresses a defect in current functionality. label Apr 18, 2024
Copy link

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@github-actions github-actions bot added the service/appconfig Issues and PRs that pertain to the appconfig service. label Apr 18, 2024
@terraform-aws-provider terraform-aws-provider bot added the needs-triage Waiting for first response or review from a maintainer. label Apr 18, 2024
@ewbankkit ewbankkit removed the needs-triage Waiting for first response or review from a maintainer. label Apr 18, 2024
@ewbankkit
Copy link
Contributor

Relates #36542.

@ewbankkit
Copy link
Contributor

I can reproduce this with a new acceptance test case:

% make testacc TESTARGS='-run=TestAccAppConfigDeployment_multiple' PKG=appconfig
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.21.8 test ./internal/service/appconfig/... -v -count 1 -parallel 20  -run=TestAccAppConfigDeployment_multiple -timeout 360m
=== RUN   TestAccAppConfigDeployment_multiple
=== PAUSE TestAccAppConfigDeployment_multiple
=== CONT  TestAccAppConfigDeployment_multiple
    deployment_test.go:186: Step 1/1 error: Error running apply: exit status 1
        
        Error: starting AppConfig Deployment: operation error AppConfig: StartDeployment, https response error StatusCode: 409, RequestID: a12558ca-6139-48bf-adfb-36e10010b401, ConflictException: Deployment number 1 already exists
        
          with aws_appconfig_deployment.test[1],
          on terraform_plugin_test.tf line 50, in resource "aws_appconfig_deployment" "test":
          50: resource "aws_appconfig_deployment" "test"{
        
        
        Error: starting AppConfig Deployment: operation error AppConfig: StartDeployment, https response error StatusCode: 409, RequestID: 567e9658-844d-44fe-9015-dd91c1af1530, ConflictException: Deployment number 1 already exists
        
          with aws_appconfig_deployment.test[0],
          on terraform_plugin_test.tf line 50, in resource "aws_appconfig_deployment" "test":
          50: resource "aws_appconfig_deployment" "test"{
        
--- FAIL: TestAccAppConfigDeployment_multiple (12.00s)
FAIL
FAIL	github.com/hashicorp/terraform-provider-aws/internal/service/appconfig	23.814s
FAIL
make: *** [testacc] Error 1

@ewbankkit ewbankkit added the aws-sdk-go-migration Issues that are related to the providers migration to AWS SDK for Go v2. label Apr 18, 2024
ewbankkit added a commit that referenced this issue Apr 18, 2024
Copy link

Warning

This issue has been closed, meaning that any additional comments are hard for our team to see. Please assume that the maintainers will not see them.

Ongoing conversations amongst community members are welcome, however, the issue will be locked after 30 days. Moving conversations to another venue, such as the AWS Provider forum, is recommended. If you have additional concerns, please open a new issue, referencing this one where needed.

@github-actions github-actions bot added this to the v5.46.0 milestone Apr 18, 2024
Copy link

This functionality has been released in v5.46.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
aws-sdk-go-migration Issues that are related to the providers migration to AWS SDK for Go v2. bug Addresses a defect in current functionality. service/appconfig Issues and PRs that pertain to the appconfig service.
Projects
None yet
2 participants