hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.77k stars 9.13k forks source link

It failed to create AppConfig Deployment if `deployment_duration_in_minutes` is over 20 #20279

Closed suzuki-shunsuke closed 3 years ago

suzuki-shunsuke commented 3 years ago

Community Note

Terraform CLI and Terraform AWS Provider Version

$ terraform -v
Terraform v1.0.3
on darwin_amd64
+ provider registry.terraform.io/hashicorp/aws v3.51.0

Affected Resource(s)

Terraform Configuration Files

Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.

It is important that aws_appconfig_deployment_strategy's deployment_duration_in_minutes is over 20.

resource "aws_appconfig_deployment_strategy" "test" {
  name                           = "test-3"
  deployment_duration_in_minutes = 25
# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file. For
# security, you can also encrypt the files using our GPG public key: https://keybase.io/hashicorp
terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "3.51.0"
    }
  }
}

provider "aws" {
  region = "ap-northeast-1"
}

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

resource "aws_appconfig_hosted_configuration_version" "test" {
  application_id           = aws_appconfig_application.test.id
  configuration_profile_id = aws_appconfig_configuration_profile.test.configuration_profile_id
  content_type             = "application/json"

  content = jsonencode({
    foo = "foo"
  })
}

resource "aws_appconfig_deployment" "test" {
  application_id           = aws_appconfig_application.test.id
  configuration_profile_id = aws_appconfig_configuration_profile.test.configuration_profile_id
  configuration_version    = aws_appconfig_hosted_configuration_version.test.version_number
  deployment_strategy_id   = aws_appconfig_deployment_strategy.test.id
  description              = "My test deployment"
  environment_id           = aws_appconfig_environment.test.environment_id
  tags = {
    Env = "test"
  }
}

resource "aws_appconfig_deployment_strategy" "test" {
  name                           = "test-3"
  deployment_duration_in_minutes = 25
  final_bake_time_in_minutes     = 0
  growth_factor                  = 1.0
  replicate_to                   = "NONE"
}

resource "aws_appconfig_configuration_profile" "test" {
  application_id = aws_appconfig_application.test.id
  name           = "test"
  location_uri   = "hosted"
}

resource "aws_appconfig_application" "test" {
  name = "test-3"
}

Debug Output

Panic Output

Expected Behavior

It succeeds to run terraform apply.

Actual Behavior

It failed to run terraform apply due to the timeout.

aws_appconfig_deployment.test: Still creating... [19m50s elapsed]
aws_appconfig_deployment.test: Still creating... [20m0s elapsed]
β•·
β”‚ Error: error waiting for AppConfig Deployment (xxx/xxx/2) creation: timeout while waiting for state to become 'COMPLETE' (last state: 'DEPLOYING', timeout: 20m0s)
β”‚ 
β”‚   with aws_appconfig_deployment.test,
β”‚   on main.tf line 29, in resource "aws_appconfig_deployment" "test":
β”‚   29: resource "aws_appconfig_deployment" "test" {
β”‚ 

Steps to Reproduce

  1. terraform apply

Important Factoids

References


DeploymentCreatedTimeout is hardcoded to 20 minutes.

const DeploymentCreatedTimeout = 20 * time.Minute

So when it takes over 20 minutes to complete the deployment, it fails to create the Deployment.

suzuki-shunsuke commented 3 years ago

The simple solution is to remove waiting for the completion in the create function.

https://github.com/hashicorp/terraform-provider-aws/blob/v3.51.0/aws/resource_aws_appconfig_deployment.go#L113-L115

If you will create the new Deployment before the latest Deployment has been completed, it would fail to create the new Deployment due to ConflictException, but I think it is better to return the error immediately than to wait for the completion.

suzuki-shunsuke commented 3 years ago

Due to the waiter, terraform apply isn't completed until the Deployment is completed. It isn't desirable for some reasons.

github-actions[bot] commented 3 years ago

This functionality has been released in v3.55.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!

github-actions[bot] commented 3 years ago

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.