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

feat(ec2): adds persist option to user data on windows instances #21709

Merged
merged 4 commits into from
Oct 12, 2022

Conversation

ddneilson
Copy link
Contributor

To set the UserData for Windows instances to run on every instance start, rather than only the first startup, requires adding "true" to the end of the user data string. Currently, users must use an escape hatch to hack the userdata of
windows instances to add this string. This PR makes it possible to add this text directly on the UserData without using an escape hatch.

Implements: #21708


All Submissions:

Adding new Unconventional Dependencies:

  • This PR adds new unconventional dependencies following the process described here

New Features

  • Have you added the new feature to an integration test?
    • Did you use yarn integ to deploy the infrastructure and generate the snapshot (i.e. yarn integ without --dry-run)?

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@gitpod-io
Copy link

gitpod-io bot commented Aug 22, 2022

@github-actions github-actions bot added the p2 label Aug 22, 2022
@aws-cdk-automation aws-cdk-automation requested a review from a team August 22, 2022 14:26
@ddneilson ddneilson changed the title fix(ec2): adds persist option to user data feat(ec2): adds persist option to user data Aug 22, 2022
@ddneilson
Copy link
Contributor Author

Regarding the PR Linter failure -- not adding an integ test. Does it really make sense to add one for this PR? It's not changing/adding any resources/constructs; it's adding functionality to a helper class.

Copy link
Contributor

@TheRealAmazonKendra TheRealAmazonKendra left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution! I have a couple comments inline. In regard to the integration test, I'd like to see one where this function is called for the construct to show both that the output is what we expect when it's called and also to ensure that this deploys successfully when the function is used (i.e. running the test without using --dry-run).

*
* @param value If true then the userdata is persisted. (Windows only)
*/
public abstract persist(value: boolean): void;
Copy link
Contributor

Choose a reason for hiding this comment

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

Given that half of the locations of this function throw errors when called, I don't think this is the right level of abstraction. I'm also not sure about this contract as a whole. Since this is a function, not a field, calling it implies that the user wants their data to persist. Given that, it seem that the boolean should be unnecessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I completely agree, however the CDK does not export the internal LinuxUserData or WindowsUserData classes. I originally just wanted to add the property to WindowsUserData, but then of course a reference to UserData trying to touch that property fails type checks. Without WindowsUserData being exported it's not even possible to do instance.userData as WindowsUserData

So, we have two options.

  1. Accept that the property is on the base UserData class and only makes sense for one of the options; or
  2. Export at least WindowsUserData so that users can type-cast to be able to set persist on it.

I went with (1), obviously. What would the CDK team prefer?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@TheRealAmazonKendra Before the bot kills this PR. Any response to my question?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@TheRealAmazonKendra Still waiting on your thoughts? Should I just add the integ test to the current PR's form, or switch to exporting WindowsUserData and only having the new persist method on WindowsUserData instead of all UserData classes?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the best option is actually to add this as an option in forWindows. forLinux has an option added it that is only specific to it so I think duplicating that experience makes sense in this context.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The suggestion has been implemented.

@aws-cdk-automation
Copy link
Collaborator

This PR has been in the CHANGES REQUESTED state for 3 weeks, and looks abandoned. To keep this PR from being closed, please continue work on it. If not, it will automatically be closed in a week.

@mergify mergify bot dismissed TheRealAmazonKendra’s stale review September 17, 2022 03:36

Pull request has been modified.

@TheRealAmazonKendra
Copy link
Contributor

Manually merged to reset the bot. I'm being a hypocrite here because I ask people to not do this, but I had missed your questions so the staleness is my fault, not yours.

@TheRealAmazonKendra
Copy link
Contributor

@Mergifyio update

@mergify
Copy link
Contributor

mergify bot commented Oct 2, 2022

update

✅ Branch has been successfully updated

Copy link
Contributor

@TheRealAmazonKendra TheRealAmazonKendra left a comment

Choose a reason for hiding this comment

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

Putting this back in changes requested now that I've provided an answer.

Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

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

The Pull Request Linter fails with the following errors:

❌ Features must contain a change to an integration test file and the resulting snapshot.

PRs must pass status checks before we can provide a meaningful review.

To set the UserData for Windows instances to run on every instance
start, rather than only the first startup, requires adding
"<persist>true</persist>" to the end of the user data string.
Currently, users must use an escape hatch to hack the userdata of
windows instances to add this string. This PR makes it possible to
add this text directly on the UserData without using an escape hatch.
@ddneilson ddneilson force-pushed the ddneilson/userdata_persist branch from 2fe66d7 to 2a55cdb Compare October 3, 2022 01:52
@mergify mergify bot dismissed stale reviews from aws-cdk-automation and TheRealAmazonKendra October 3, 2022 01:52

Pull request has been modified.

@Naumel Naumel added the @aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud label Oct 3, 2022
@TheRealAmazonKendra TheRealAmazonKendra changed the title feat(ec2): adds persist option to user data feat(ec2): adds persist option to user data on windows instances Oct 12, 2022
Copy link
Contributor

@TheRealAmazonKendra TheRealAmazonKendra left a comment

Choose a reason for hiding this comment

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

Looks good! I removed some some extra spacing in a couple places but this looks good to go.

@mergify
Copy link
Contributor

mergify bot commented Oct 12, 2022

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: a638eb3
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit cb1506f into aws:main Oct 12, 2022
@mergify
Copy link
Contributor

mergify bot commented Oct 12, 2022

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@ddneilson ddneilson deleted the ddneilson/userdata_persist branch October 13, 2022 00:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud p2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants