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_instance: allow providing user data as base64 #850

Merged
merged 2 commits into from
Aug 8, 2017

Conversation

apparentlymart
Copy link
Contributor

Providing base64 directly is convenient when it must be set to something that isn't valid UTF-8, such as the gzipped payloads often passed to cloud-init for more complex setups.

Passing binary data directly via Terraform attributes is not safe because only UTF-8 strings can be stored in the state file. This is therefore intended for use in conjunction with the base64 encoding mode of template_cloudinit_config to enable gzip data to be passed safely to the EC2 data without corruption as it passes through Terraform.

For more information, see the discussion at hashicorp/terraform#14314, which was later migrated to #754.

This first change deals only with aws_instance. Similar changes will be needed for aws_launch_configuration and aws_lightsail_instance later, for the same reasons.

@apparentlymart apparentlymart added the enhancement Requests to existing resources that expand the functionality or scope. label Jun 14, 2017
Copy link
Member

@radeksimko radeksimko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Except one nitpick in tests this LGTM.


// We repeat the exact same test so that we can be sure
// that the handling of the user_data and user_data_base64
// distinction doesn't cause diff weirdness.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this happens by default for every single test, so the second step is redundant:
https://github.com/hashicorp/terraform/blob/master/helper/resource/testing_config.go#L92-L105

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh yes, of course. This was something I inherited and tweaked from another nearby test, but I forgot that it's not necessary here. (The other test was doing it specifically to test some of the weird behavior we do to prevent double-base64-encoding, which isn't true here.)

Providing base64 directly is convenient when it must be set to something
that isn't valid UTF-8, such as the gzipped payloads often passed to
cloud-init for more complex setups.

Passing binary data directly via Terraform attributes is not safe because
only UTF-8 strings can be stored in the state file. This is therefore
intended for use in conjunction with the base64 encoding mode of
template_cloudinit_config to enable gzip data to be passed safely to the
EC2 data without corruption as it passes through Terraform.
These typos were preventing this test from being included when filtering
tests by prefix.
@ghost
Copy link

ghost commented Apr 11, 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 Apr 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants