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

aws_ssm_parameter does not support changing type from SecureString => String #9843

Closed
christek91 opened this issue Aug 21, 2019 · 6 comments · Fixed by #10819
Closed

aws_ssm_parameter does not support changing type from SecureString => String #9843

christek91 opened this issue Aug 21, 2019 · 6 comments · Fixed by #10819
Labels
bug Addresses a defect in current functionality. service/ssm Issues and PRs that pertain to the ssm service.
Milestone

Comments

@christek91
Copy link
Contributor

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

Terraform v0.11.13

  • provider.aws v2.7.0

Affected Resource(s)

  • aws_ssm_parameter

Terraform Configuration Files

This is the original TF code that generated the resource to begin with.

# Original Resource Code
resource "aws_ssm_parameter" "my_param" {
  name        = "my_param"
  description = "This is not really a secret."
  type        = "SecureString"
  value       = "SomeValue"
  overwrite   = true
}

The issue comes up when I update that code to be the following:

# Updated Resource Code
resource "aws_ssm_parameter" "my_param" {
  name        = "my_param"
  description = "This is not really a secret."
  type        = "String"
  value       = "SomeValue"
  overwrite   = true
}

The only change is the type.

Debug Output

I'm going to skip the debug output here, unless requested. The root cause is
relatively plain to see, and the incidence of this I'm working with locally
contains secret values.

Panic Output

Expected Behavior

I would expect that the SSM parameter type would be updated to the String type,
as supported by the SSM put-parameter API.

Actual Behavior

The provider forwards along the original key_id value originally set by TF
(alias/aws/ssm by default). However, that value should not be included in the
API request for a String type, only SecureString. So the AWS API complains,
and does not update the parameter.

The result is the error seen here:

* aws_ssm_parameter.my_param: 1 error(s) occurred:

* aws_ssm_parameter.my_param: error creating SSM parameter: ValidationException: KeyId is required for SecureString type parameter only.
    status code: 400, request id: d0b01305-01a9-478e-8e7f-e94cedd27541

Steps to Reproduce

  1. terraform apply of original resource code above.
  2. Update original code to the Updated snippet provided.
  3. terraform apply again.

Important Factoids

I think that the fix for this may be as simple as modifying this conditional:
https://github.com/terraform-providers/terraform-provider-aws/blob/master/aws/resource_aws_ssm_parameter.go#L214

I think it should only set the keyID on the request If, and only If, the Type
on the request is SecureString.

The PutParameter API call does support updating the type from SecureString to
String, but it will always complain if key_id is set in the request but the
type is not SecureString.

References

  • #0000
@ghost ghost added the service/ssm Issues and PRs that pertain to the ssm service. label Aug 21, 2019
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Aug 21, 2019
@chroju
Copy link
Contributor

chroju commented Nov 9, 2019

Hi. I have created a pull request because I was bothered by the same thing. Thanks.

@jurajseffer
Copy link
Contributor

This also happens when you do specify the key_id originally for the SecureString type.

@bgvladedivac
Copy link

Faced the same issue, would be happy to have this on board.

@bflad bflad added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Jan 24, 2020
bflad pushed a commit that referenced this issue Jan 24, 2020
…o String (#9843) (#10819)

Output from acceptance testing:

```
--- PASS: TestAccAWSSSMParameter_disappears (14.20s)
--- PASS: TestAccAWSSSMParameter_fullPath (20.62s)
--- PASS: TestAccAWSSSMParameter_secure (21.53s)
--- PASS: TestAccAWSSSMParameter_basic (21.98s)
--- PASS: TestAccAWSSSMParameter_updateDescription (34.06s)
--- PASS: TestAccAWSSSMParameter_changeNameForcesNew (34.44s)
--- PASS: TestAccAWSSSMParameter_updateType (35.23s)
--- PASS: TestAccAWSSSMParameter_overwrite (36.26s)
--- PASS: TestAccAWSSSMParameter_Tier (46.00s)
--- PASS: TestAccAWSSSMParameter_tags (48.53s)
--- PASS: TestAccAWSSSMParameter_secure_with_key (51.77s)
--- PASS: TestAccAWSSSMParameter_secure_keyUpdate (69.76s)
```
@bflad bflad added this to the v2.47.0 milestone Jan 24, 2020
@bflad
Copy link
Contributor

bflad commented Jan 24, 2020

The fix for this has been merged and will release with version 2.47.0 of the Terraform AWS Provider, Thursday next week. Thanks to @chroju for the implementation. 👍

@ghost
Copy link

ghost commented Jan 30, 2020

This has been released in version 2.47.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 for triage. Thanks!

@ghost
Copy link

ghost commented Mar 27, 2020

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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Mar 27, 2020
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/ssm Issues and PRs that pertain to the ssm service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants