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]: elasticbeanstalk environment update issue #31575

Closed
gabrielepostorino opened this issue May 25, 2023 · 6 comments · Fixed by #36074
Closed

[Bug]: elasticbeanstalk environment update issue #31575

gabrielepostorino opened this issue May 25, 2023 · 6 comments · Fixed by #36074
Labels
bug Addresses a defect in current functionality. service/elasticbeanstalk Issues and PRs that pertain to the elasticbeanstalk service.
Milestone

Comments

@gabrielepostorino
Copy link

gabrielepostorino commented May 25, 2023

Terraform Core Version

1.4.6

AWS Provider Version

4.67.0

Affected Resource(s)

aws_elastic_beanstalk_environment

Expected Behavior

When updating environment settings and environment tags in the same plan, two API actions are called:

  • UpdateTagsForResource
  • UpdateEnvironment

The expected behavior is that the two changes should be applied to the existing environment sequentially.

Actual Behavior

When the plan is applied, these two calls are made at the same time and UpdateEnvironment errors out consistently because the environment is being modified by UpdateTagsForResource.

It worked in version 4.62.0 and stopped working from 4.63.0 onwards.

Relevant Error/Panic Output Snippet

$ terraform plan -out plan -var="bucket=XXXXXXX" -var="env-ver=1.1"                                                                    
data.aws_elastic_beanstalk_solution_stack.Nodejs: Reading...
aws_iam_instance_profile.elasticbeanstalk-instance-profile: Refreshing state... [id=elasticbeanstalk-instance-profile]
aws_elastic_beanstalk_application.tftest: Refreshing state... [id=tf-test-name]
aws_s3_bucket.default: Refreshing state... [id=XXXXXXX]
aws_s3_object.default: Refreshing state... [id=beanstalk/nodejs.zip]
data.aws_elastic_beanstalk_solution_stack.Nodejs: Read complete after 1s [id=64bit Amazon Linux 2 v5.8.1 running Node.js 18]
aws_elastic_beanstalk_application_version.default: Refreshing state... [id=tf-test-version]
aws_elastic_beanstalk_environment.env: Refreshing state... [id=e-xxxxxx]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # aws_elastic_beanstalk_environment.env will be updated in-place
  ~ resource "aws_elastic_beanstalk_environment" "env" {
        id                     = "e-xxxxxx"
        name                   = "Environment"
      ~ tags                   = {
          ~ "version" = "1.0" -> "1.1"
        }
      ~ tags_all               = {
          ~ "version" = "1.0" -> "1.1"
        }
        # (15 unchanged attributes hidden)

      - setting {
          - name      = "DeploymentPolicy" -> null
          - namespace = "aws:elasticbeanstalk:command" -> null
          - value     = "Immutable" -> null
        }
      - setting {
          - name      = "IamInstanceProfile" -> null
          - namespace = "aws:autoscaling:launchconfiguration" -> null
          - value     = "elasticbeanstalk-instance-profile" -> null
        }
      - setting {
          - name      = "RollingUpdateType" -> null
          - namespace = "aws:autoscaling:updatepolicy:rollingupdate" -> null
          - value     = "Immutable" -> null
        }
      - setting {
          - name      = "VERSION" -> null
          - namespace = "aws:elasticbeanstalk:application:environment" -> null
          - value     = "1.0" -> null
        }
      + setting {
          + name      = "DeploymentPolicy"
          + namespace = "aws:elasticbeanstalk:command"
          + value     = "Immutable"
        }
      + setting {
          + name      = "IamInstanceProfile"
          + namespace = "aws:autoscaling:launchconfiguration"
          + value     = "elasticbeanstalk-instance-profile"
        }
      + setting {
          + name      = "RollingUpdateType"
          + namespace = "aws:autoscaling:updatepolicy:rollingupdate"
          + value     = "Immutable"
        }
      + setting {
          + name      = "VERSION"
          + namespace = "aws:elasticbeanstalk:application:environment"
          + value     = "1.1"
        }
    }

Plan: 0 to add, 1 to change, 0 to destroy.

────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Saved the plan to: plan

To perform exactly these actions, run the following command to apply:
    terraform apply "plan"


$ terraform apply plan                                                                                                                          
aws_elastic_beanstalk_environment.env: Modifying... [id=e-xxxxxx]
╷
│ Error: updating Elastic Beanstalk Environment (e-xxxxxxxxxxxx): InvalidParameterValue: Environment named Environment is in an invalid state for this operation. Must be Ready.
│ 	status code: 400, request id: xxxxxxxxxxxxxxxxxxxx
│ 
│   with aws_elastic_beanstalk_environment.env,
│   on environment.tf line 49, in resource "aws_elastic_beanstalk_environment" "env":
│   49: resource "aws_elastic_beanstalk_environment" "env" {
│ 
╵

Terraform Configuration Files

Archive.zip

Steps to Reproduce

Unzip the Archive.zip file.

  • terraform plan -out plan -var="bucket=change-me" -var="env-ver=1.0"
  • terraform apply plan
  • terraform plan -out plan -var="bucket=change-me" -var="env-ver=1.1"
  • terraform apply plan

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

Cloudtrail Events:
UpdateTagsForResource

{
    "eventVersion": "1.08",
    "userIdentity": {
        "type": "AssumedRole",
        "principalId": "REMOVED",
        "arn": "REMOVED",
        "accountId": "REMOVED",
        "accessKeyId": "REMOVED",
        "sessionContext": {
            "sessionIssuer": {
                "type": "Role",
                "principalId": "REMOVED",
                "arn": "arn:aws:iam::REMOVED:role/REMOVED",
                "accountId": "REMOVED",
                "userName": "REMOVED"
            },
            "webIdFederationData": {},
            "attributes": {
                "creationDate": "2023-05-25T08:01:21Z",
                "mfaAuthenticated": "false"
            }
        }
    },
    "eventTime": "2023-05-25T14:13:17Z",
    "eventSource": "elasticbeanstalk.amazonaws.com",
    "eventName": "UpdateTagsForResource",
    "awsRegion": "eu-west-1",
    "sourceIPAddress": "REMOVED",
    "userAgent": "APN/1.0 HashiCorp/1.0 Terraform/1.4.6 (+https://www.terraform.io) terraform-provider-aws/4.63.0 (+https://registry.terraform.io/providers/hashicorp/aws) aws-sdk-go/1.44.242 (go1.19.7; darwin; arm64)",
    "requestParameters": {
        "resourceArn": "arn:aws:elasticbeanstalk:eu-west-1:REMOVED:environment/tf-test-name/Environment",
        "tagsToAdd": [
            {
                "key": "version",
                "value": "1.1"
            }
        ]
    },
    "responseElements": null,
    "requestID": "REMOVED",
    "eventID": "REMOVED",
    "readOnly": false,
    "eventType": "AwsApiCall",
    "managementEvent": true,
    "recipientAccountId": "REMOVED",
    "eventCategory": "Management",
    "tlsDetails": {
        "clientProvidedHostHeader": "elasticbeanstalk.eu-west-1.amazonaws.com"
    }
}

UpdateEnvironment

{
    "eventVersion": "1.08",
    "userIdentity": {
        "type": "AssumedRole",
        "principalId": "REMOVED",
        "arn": "REMOVED",
        "accountId": "REMOVED",
        "accessKeyId": "REMOVED",
        "sessionContext": {
            "sessionIssuer": {
                "type": "Role",
                "principalId": "REMOVED",
                "arn": "arn:aws:iam::REMOVED:role/REMOVED",
                "accountId": "REMOVED",
                "userName": "REMOVED"
            },
            "webIdFederationData": {},
            "attributes": {
                "creationDate": "2023-05-25T08:01:21Z",
                "mfaAuthenticated": "false"
            }
        }
    },
    "eventTime": "2023-05-25T14:13:17Z",
    "eventSource": "elasticbeanstalk.amazonaws.com",
    "eventName": "UpdateEnvironment",
    "awsRegion": "eu-west-1",
    "sourceIPAddress": "REMOVED",
    "userAgent": "APN/1.0 HashiCorp/1.0 Terraform/1.4.6 (+https://www.terraform.io) terraform-provider-aws/4.63.0 (+https://registry.terraform.io/providers/hashicorp/aws) aws-sdk-go/1.44.242 (go1.19.7; darwin; arm64)",
    "errorCode": "InvalidParameterValueException",
    "errorMessage": "An unknown error occurred",
    "requestParameters": {
        "environmentId": "e-REMOVED",
        "optionSettings": [
            {
                "namespace": "aws:elasticbeanstalk:application:environment",
                "optionName": "VERSION",
                "value": "<sensitiveDataRemoved>"
            }
        ]
    },
    "responseElements": null,
    "requestID": "REMOVED",
    "eventID": "REMOVED",
    "readOnly": false,
    "eventType": "AwsApiCall",
    "managementEvent": true,
    "recipientAccountId": "REMOVED",
    "eventCategory": "Management",
    "tlsDetails": {
        "clientProvidedHostHeader": "elasticbeanstalk.eu-west-1.amazonaws.com"
    }
}

Would you like to implement a fix?

No

@gabrielepostorino gabrielepostorino added bug Addresses a defect in current functionality. needs-triage Waiting for first response or review from a maintainer. labels May 25, 2023
@github-actions
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/elasticbeanstalk Issues and PRs that pertain to the elasticbeanstalk service. label May 25, 2023
@justinretzolk justinretzolk removed the needs-triage Waiting for first response or review from a maintainer. label May 25, 2023
@akashpadwal
Copy link

akashpadwal commented May 26, 2023

I’ve worked with the customer to root cause and observed that there are two API calls i.e.
UpdateTagsForResource - 2023-05-25T14:13:17Z
UpdateEnvironment - 2023-05-25T14:13:17Z
which is leading to the below error:


Error: updating Elastic Beanstalk Environment (e-xxxxxxxxxxxx): InvalidParameterValue: Environment named Environment is in an invalid state for this operation. Must be Ready.

@gabrielepostorino gabrielepostorino changed the title [Bug]: 1. [Bug]: elasticbeanstalk environment update issue May 26, 2023
@Omerlustig
Copy link

hi,
is there an estimation for a fix?

@zemer-sh
Copy link

Also reproduce here

Terraform version: 1.5.1
aws terraform provider version: 5.5.0

This bug is a live more then few month - and it seems I can not degrade the provider version.

is this being handled?

Copy link

github-actions bot commented Mar 7, 2024

This functionality has been released in v5.40.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

github-actions bot commented Apr 7, 2024

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 Apr 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/elasticbeanstalk Issues and PRs that pertain to the elasticbeanstalk service.
Projects
None yet
5 participants