Skip to content

feat: Make userdata gzipped in case the user provided userdata is long #1956

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

Closed
wants to merge 5 commits into from

Conversation

Makeshift
Copy link
Contributor

@Makeshift Makeshift commented Apr 21, 2022

I provide big userdata, aws_launch_template bombs out because user_data is simply base64ified and not gzipped, making it larger than 16kb.

This PR should fix that issue. I'm testing on my infrastructure now so will let you know if it works :)

Appears to work fine, though note I am editing out the exec descriptor stuff (#1959) in the fork I'm running on my infrastructure (Makeshift@16d4c04)

@Makeshift
Copy link
Contributor Author

Amusingly, I've since modified my userdata to be less than 16kb when base64'd, but I still think this is a beneficial change.

@npalm npalm changed the title [Feature] Make userdata gzipped in case the user provided userdata is long feat: Make userdata gzipped in case the user provided userdata is long Apr 25, 2022
@npalm
Copy link
Member

npalm commented Apr 25, 2022

Amusingly, I've since modified my userdata to be less than 16kb when base64'd, but I still think this is a beneficial change.

Agree, but still need to test. Was also thinking should we provide it configurable. With defaults set to zipped

@ScottGuymer
Copy link
Contributor

I have not tried this myself yet but reading the docs/issues I'm not sure this will work for a launch template.

I came across this hashicorp/terraform-provider-aws#497

On an instance you have user_data and user_data_base64. The former explicitly states not to pass gzipped data to it, the latter accepts it.

There is no such distinction on a launch template and no matching gzip accepting variant of user_data.

@Makeshift
Copy link
Contributor Author

I have not tried this myself yet but reading the docs/issues I'm not sure this will work for a launch template.

I also thought this, as I vaguely remembered that launch templates didn't support compressed base64 (in one of my commits I even remove the gzip because I thought it wasn't supported, then I realised it worked and put it back), but it absolutely does work in my environment (eu-west-2), so it may have been a recent change to cloudinit?

@Makeshift
Copy link
Contributor Author

Makeshift commented May 14, 2022

Is anybody able to attempt this in another region to see if it's consistently supported, or are we considering it unsupported (because the docs say it should be) and I should therefore close this PR?

It's known working in eu-west-2 only at the moment.

@npalm
Copy link
Member

npalm commented May 16, 2022

I will run a test as well today.

@npalm
Copy link
Member

npalm commented May 17, 2022

I will run a test as well today.

Just tried to test the PR, the cloud-init provide is not available for darwin_arm64. So not able to test. Checking the provicer learned also that they release wise not active. So doubt to make the module depended on the provdier.

@ScottGuymer
Copy link
Contributor

There is a terraform function for base64gzip that we could use.

https://www.terraform.io/language/functions/base64gzip

@github-actions
Copy link
Contributor

This pull request has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the Stale label Jun 20, 2022
@github-actions github-actions bot closed this Jun 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants