-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
r/aws_launch_template: Multiple fixes #4344
Conversation
@@ -112,7 +112,7 @@ The following arguments are supported: | |||
`vpc_security_group_ids` instead. | |||
* `vpc_security_group_ids` - A list of security group IDs to associate with. | |||
* `tag_specifications` - The tags to apply to the resources during launch. See [Tags](#tags) below for more details. | |||
* `user_data` - The user data to provide when launching the instance. | |||
* `user_data` - The Base64-encoded user data to provide when launching the instance. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does EC2 Base64 decode this automatically?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep. It even shows plain text in AWS console
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting -- we've needed to implement this as a separate attribute (user_data_base64
) for it to work in other places. Usually Terraform shows a difference due to the API returning it differently depending on whether its Base64 or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An easy way to verify this is with https://www.terraform.io/docs/providers/template/d/cloudinit_config.html with gzip
and base64_encode
enabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, from docs https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_RequestLaunchTemplateData.html launch template accepts only base64 . So you will need to use base64encode interpolation when providing it. I can probably add this to examples
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great find! 👍
Fixed some additional issues. After this I was finally able to launch ASG with template created by this resource. New Fixed:
Plus some additional checks in acc tests. New test results:
|
@bflad i'll remove my commits that overlap with others. |
Aaand done. Now this one includes stuff that were only present in my PR:
@bflad if you want me to split this into different PRs i can do this tomorrow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's get this in -- thanks @gordonbondon! 🚀
6 tests passed (all tests)
=== RUN TestAccAWSLaunchTemplate_data
--- PASS: TestAccAWSLaunchTemplate_data (7.05s)
=== RUN TestAccAWSLaunchTemplate_basic
--- PASS: TestAccAWSLaunchTemplate_basic (7.45s)
=== RUN TestAccAWSLaunchTemplate_importData
--- PASS: TestAccAWSLaunchTemplate_importData (8.05s)
=== RUN TestAccAWSLaunchTemplate_importBasic
--- PASS: TestAccAWSLaunchTemplate_importBasic (9.42s)
=== RUN TestAccAWSLaunchTemplate_update
--- PASS: TestAccAWSLaunchTemplate_update (12.38s)
=== RUN TestAccAWSLaunchTemplate_BlockDeviceMappings_EBS
--- PASS: TestAccAWSLaunchTemplate_BlockDeviceMappings_EBS (14.46s)
Optional: true, | ||
Type: schema.TypeString, | ||
Optional: true, | ||
ValidateFunc: validateArn, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been released in version 1.18.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. |
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! |
Commits fix various stuff i've encountered while using this resource:
security_group_names
andvpc_security_group_ids
. Docs say thatYou cannot specify both a security group ID and security name in the same request.
and you can get this error when trying to launch instance from template in non-default VPC:Tests: