terraform-provider-aws icon indicating copy to clipboard operation
terraform-provider-aws copied to clipboard

[Bug]: SSM paramaters: When there is a change in `data_type` terraform plan shows an in-place update, but apply fails

Open dchittibala opened this issue 1 year ago • 1 comments

Terraform Core Version

v1.5.7

AWS Provider Version

5.38.0

Affected Resource(s)

aws_ssm_parameter

Expected Behavior

  • When an SSM parameter is created with a data_type: text and is changed to data_type: aws:ec2:image and vice versa, the provider tries to perform an in-place replacement instead of force replacement where it needs to destroy the SSM parameter and recreate it with correct data_type

Actual Behavior

  • When an SSM parameter is created with a data_type: text and is changed to data_type: aws:ec2:image and vice versa, the provider tries to perform an in-place replacement instead of force replacement.

An example plan and apply.

➜ terraform plan
aws_ssm_parameter.foo: Refreshing state... [id=foo]

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_ssm_parameter.foo will be updated in-place
  ~ resource "aws_ssm_parameter" "foo" {
      ~ data_type = "text" -> "aws:ec2:image"
        id        = "foo"
        name      = "foo"
        tags      = {}
        # (6 unchanged attributes hidden)
    }

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

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

Note: You didn't use the -out option to save this plan, so Terraform can't guarantee to take exactly these actions if you
run "terraform apply" now.

When performed an apply

➜ terraform apply
aws_ssm_parameter.foo: Refreshing state... [id=foo]

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_ssm_parameter.foo will be updated in-place
  ~ resource "aws_ssm_parameter" "foo" {
      ~ data_type = "text" -> "aws:ec2:image"
        id        = "foo"
        name      = "foo"
        tags      = {}
        # (6 unchanged attributes hidden)
    }

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

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

aws_ssm_parameter.foo: Modifying... [id=foo]
╷
│ Error: error updating SSM parameter (foo): ValidationException: You can’t change a parameter’s data type.
│ 	status code: 400, request id: 010242c7-bfb6-44be-91b9-c01ea706fd5a
│
│   with aws_ssm_parameter.foo,
│   on main.tf line 1, in resource "aws_ssm_parameter" "foo":
│    1: resource "aws_ssm_parameter" "foo" {
│
╵

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

  1. main.tf
resource "aws_ssm_parameter" "foo" {
  name  = "foo"
  type  = "String"
  value = "ami-xxxxxxxxxxxxxxxxxxx"
#  data_type = "aws:ec2:image"
  data_type = "text"
}
  1. provider.tf
terraform {
    required_providers {
    aws = {
        source  = "hashicorp/aws"
    }
}
}
# Configuring the AWS provider in Terraform configuration file.
provider "aws" {
    region = "us-west-2"
}

Steps to Reproduce

  1. Create a SSM parameter via terraform and set the data_type=text
  2. Run terraform init;terraform plan; terraform apply
  3. Once it is created, change the data_type=aws:ec2:image on main.tf
  4. Run terraform init;terraform plan; terraform apply

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

Yes

dchittibala avatar Feb 23 '24 20:02 dchittibala

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[bot] avatar Feb 23 '24 20:02 github-actions[bot]

@justinretzolk do we know when this can get prioritized?

dchittibala avatar Mar 08 '24 16:03 dchittibala

[!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[bot] avatar Mar 26 '24 01:03 github-actions[bot]

This functionality has been released in v5.43.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] avatar Mar 28 '24 21:03 github-actions[bot]

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[bot] avatar Apr 28 '24 02:04 github-actions[bot]