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.71k stars 9.07k forks source link

[Bug]: Applying Removal of "overwrite = true" attribute from aws_ssm_parameter resource fails with "Error: updating SSM Parameter (/parameter/path): ParameterAlreadyExists: The parameter already exists. To overwrite this value, set the overwrite option in the request to true." #31655

Closed chase-replicated closed 1 year ago

chase-replicated commented 1 year ago

Terraform Core Version

1.3.7

AWS Provider Version

5.0.1

Affected Resource(s)

aws_ssm_parameter

Expected Behavior

The state file should be updated to remove "overwrite" attribute from ssm resources & since that attribute is deprecated, its use should not be recommended by the failure message.

Actual Behavior

The terraform apply fails with "Error: updating SSM Parameter (/parameter/path): ParameterAlreadyExists: The parameter already exists. To overwrite this value, set the overwrite option in the request to true."

Relevant Error/Panic Output Snippet

Error: updating SSM Parameter (/parameter/path): ParameterAlreadyExists: The parameter already exists. To overwrite this value, set the overwrite option in the request to true.
│ 
│   with aws_ssm_parameter.parameter,
│   on ../io.tf line 15, in resource "aws_ssm_parameter" "parameter":
│   15: resource "aws_ssm_parameter" "parameter" {

Terraform Configuration Files

4.67.0: https://github.com/chase-replicated/ssm_tf_bug_repro

upgrade to 5.0.1 & removal of overwrite=true: https://github.com/chase-replicated/ssm_tf_bug_repro/tree/upgrade-to-5

Steps to Reproduce

Create ssm parameter in AWS Create that same parameter via aws_ssm_parameter using terraform aws provider version 4.67.0 & set overwrite = true upgrade provider version to 5.0.1 & remove overwrite = true attribute (deprecated) terraform plan:

Terraform will perform the following actions:

  # aws_ssm_parameter.test will be updated in-place
  ~ resource "aws_ssm_parameter" "test" {
        id          = "/test"
        name        = "/test"
      - overwrite   = true -> null
        tags        = {}
        # (8 unchanged attributes hidden)
    }

terraform apply:

> AWS_PROFILE=dev terraform apply ~/tf-plans/aws-test-dev.plan
aws_ssm_parameter.test: Modifying... [id=/test]
╷
│ Error: updating SSM Parameter (/test): ParameterAlreadyExists: The parameter already exists. To overwrite this value, set the overwrite option in the request to true.
│
│   with aws_ssm_parameter.test,
│   on main.tf line 5, in resource "aws_ssm_parameter" "test":
│    5: resource "aws_ssm_parameter" "test" {
│

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

https://registry.terraform.io/providers/hashicorp/aws/latest/docs/guides/version-5-upgrade#resourceaws_ssm_parameter

Would you like to implement a fix?

None

github-actions[bot] commented 1 year ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

GerardSoleCa commented 1 year ago

Hi,

I'm affected too by this. We removed the value and put in-place the lifecycle rule to avoid changes for the overwrite: false case.

Now plan fails because SSM parameters that are created with TF expect an overwrite: true parameter to change/update the value.

How this should work?

feelobot commented 1 year ago

I have the same error:

╷
│ Error: updating SSM Parameter (/sqs/violation-csv-emails.fifo/url): ParameterAlreadyExists: The parameter already exists. To overwrite this value, set the overwrite option in the request to true.
│ 
│   with module.sqs.module.csv-violation-emails.aws_ssm_parameter.queue_url[0],
│   on ../../modules/sqs/main.tf line 59, in resource "aws_ssm_parameter" "queue_url":
│   59: resource "aws_ssm_parameter" "queue_url" {
│ 
╵
➜  dev git:(INFRA-504-upgrade-terraform-aws-provider) ✗ terraform version
Terraform v1.4.6
on darwin_amd64
+ provider registry.terraform.io/hashicorp/aws v5.0.1
+ provider registry.terraform.io/hashicorp/local v2.4.0
+ provider registry.terraform.io/hashicorp/random v3.5.1
➜  dev git:(INFRA-504-upgrade-terraform-aws-provider) ✗ 
feelobot commented 1 year ago

The workaround is to not remove the attribute for now and leave the warning:

╷
│ Warning: Argument is deprecated
│ 
│   with module.cognito.aws_ssm_parameter.webapp-identitypoolid,
│   on ../../globals/cognito/cognito_identity_pool.tf line 30, in resource "aws_ssm_parameter" "webapp-identitypoolid":
│   30:   overwrite = "true"
│ 
│ this attribute has been deprecated
│ 
│ (and 62 more similar warnings elsewhere)
╵

Apply complete! Resources: 0 added, 63 changed, 0 destroyed.
➜  dev git:(INFRA-504-upgrade-terraform-aws-provider) 
bateller commented 1 year ago

Would love to see this get fixed

Still an ongoing issue with v5.4.0

However, ignoring the warning and continuing the apply appears to suppress further warnings on subsequent runs, at least in my limited testing with v5.4.0

apradhan-ctr commented 1 year ago

I have the same error

mnebot commented 1 year ago

Do you have some expected date on the resolution of this issue?

github-actions[bot] commented 1 year 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.