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

Store terraform launchtemplate userdata in plaintext rather than b64 #9340

Merged
merged 3 commits into from
Jun 17, 2020

Conversation

rifelpet
Copy link
Member

AWS launch templates require their userdata be submitted in base64. terraform has a filebase64 function for this purpose, in fact their aws_launch_template example uses it. Using it allows us to store the userdata contents in plaintext and terraform performs the encoding, rather than storing it encoded. This makes it easier to grok the userdata contents and any changes.

I'm not super happy with changing the AddFile function signature and updating every reference to it in cloudup.

WIP while I think of better alternatives (feedback welcome)

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jun 11, 2020
@k8s-ci-robot k8s-ci-robot added the area/provider/aws Issues or PRs related to aws provider label Jun 11, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rifelpet

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 11, 2020
@rifelpet
Copy link
Member Author

make verify-terraform failed because filebase64 isnt in terraform 0.11, so this may need to wait until we drop 0.11 support or we make it handle both cases :(

@hakman
Copy link
Member

hakman commented Jun 16, 2020

When is the plan to drop terraform 0.11?
I kind of like this more 😄

@rifelpet
Copy link
Member Author

I'd love for us to drop terraform 0.11 support asap, but we should probably add deprecation warnings and announce it according to our deprecation policy. Perhaps another office hours topic?

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 16, 2020
if b64d != "" {
b64UserDataResource := fi.WrapResource(fi.NewStringResource(b64d))
if d != nil {
userDataResource := fi.WrapResource(fi.NewBytesResource(d))
Copy link
Member Author

Choose a reason for hiding this comment

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

I suppose i could check the value of the terraform feature flag here and conditionally encode the userdata contents, but that feels ugly. any other ideas?

Copy link
Member Author

Choose a reason for hiding this comment

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

or add a new target.AddBase64File function that wraps target.AddFile

Copy link
Member

Choose a reason for hiding this comment

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

Seems like it's in the nature of the feature flag to be ugly. A nice reminder that has to go away soon. 😄
I would go with the flag.

Copy link
Member Author

Choose a reason for hiding this comment

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

done 👍 hack/verify-terraform.sh passes too. I'm not sure why there isnt a prow job for it, i'll look into creating one.

Copy link
Member

Choose a reason for hiding this comment

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

LGTM, but still WIP and also the new job will need some work to pass.

@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 16, 2020
@hakman
Copy link
Member

hakman commented Jun 17, 2020

/test pull-kops-verify-terraform

@rifelpet
Copy link
Member Author

/test pull-kops-verify-terraform

@@ -36,7 +36,7 @@ while IFS= read -r -d '' -u 3 test_dir; do
cluster=$(basename "${test_dir}")
kube::util::array_contains "${cluster}" "${CLUSTERS_0_11[@]}" && tag=$TAG_0_11 || tag=$TAG_0_12

docker run --rm -it -v "${test_dir}":"${test_dir}" -w "${test_dir}" --entrypoint=sh hashicorp/terraform:$tag -c '/bin/terraform init >/dev/null && /bin/terraform validate' || RC=$?
docker run --rm -v "${test_dir}":"${test_dir}" -w "${test_dir}" --entrypoint=sh hashicorp/terraform:$tag -c '/bin/terraform init >/dev/null && /bin/terraform validate' || RC=$?
Copy link
Member

Choose a reason for hiding this comment

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

Any reason the tag also contains patch version?
For 0.11 I not much will change and for 0.12 I think we want to know if something breaks.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hashicorp doesn't have major.minor tags: https://hub.docker.com/r/hashicorp/terraform/tags

I suppose we could keep the 0.11.14 tag and use latest for 0.12+ ? I may address that in a followup PR though.

Copy link
Member

Choose a reason for hiding this comment

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

👍

@rifelpet rifelpet changed the title [WIP] Store terraform launchtemplate userdata in plaintext rather than b64 Store terraform launchtemplate userdata in plaintext rather than b64 Jun 17, 2020
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 17, 2020
@hakman
Copy link
Member

hakman commented Jun 17, 2020

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 17, 2020
@k8s-ci-robot k8s-ci-robot merged commit 8c3b4e4 into kubernetes:master Jun 17, 2020
@k8s-ci-robot k8s-ci-robot added this to the v1.19 milestone Jun 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/provider/aws Issues or PRs related to aws provider cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants