-
Notifications
You must be signed in to change notification settings - Fork 4k
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
chore(ecs): allow selecting Bottlerocket via machineImage
#16038
Conversation
Previously, Bottlerocket had to be explicitly (and only) selected via setting `machineImageType`, which would pick an appropriate `machineImage`. Setting `machineImage` to `new BottleRocketImage()` would not be sufficient, since the feature also requires configuring additional UserData commands which are only added if `machineImageType` was set. This method of configuration does not allow customization of the AMI, such as introduced in #16021. Instead, we reverse the logic: `machineImageType` may still be necessary to autoconfigure UserData if we can't know what the machineImage is (for example in case of a preconfigured AutoScalingGroup), but otherwise is derived from what `machineImage` is being used.
// Do 2-way defaulting here: if the machineImageType is BOTTLEROCKET, pick the right AMI. | ||
// Otherwise, determine the machineImageType from the given AMI. | ||
const machineImage = options.machineImage ?? | ||
(options.machineImageType === MachineImageType.BOTTLEROCKET ? new BottleRocketImage() : new EcsOptimizedAmi()); |
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.
What happens now if both machineImage
and machineType
are specified but they don't match?
Also, given the type below in line 303, should we use EcsOptimizedImage.amazonLinux2()
, instead, to make the connection between the two more explicit?
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.
What happens now if both machineImage and machineType are specified but they don't match?
User's responsibility. I think we need this flexibility in case people have MyCustomBottleRocketImage
for which the instanceof
check would fail.
Also, given the type below in line 303, should we use EcsOptimizedImage.amazonLinux2(), instead, to make the connection between the two more explicit?
Maybe. I think the code is the way it is because we're afraid of breaking existing templates. Not inclined to change anything there, honestly.
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
As introduced in aws#10097, Bottlerocket had to be explicitly (and only) selected via setting `machineImageType`, which would pick an appropriate `machineImage`. Setting `machineImage` to `new BottleRocketImage()` would not be sufficient, since the feature also requires configuring additional UserData commands which are only added if `machineImageType` was set. This method of configuration does not allow customization of the AMI, such as introduced in aws#16021. Instead, we reverse the logic: `machineImageType` may still be necessary to autoconfigure UserData if we can't know what the machineImage is (for example in case of a preconfigured AutoScalingGroup), but otherwise is derived from what `machineImage` is being used. We allow configuring both fields at the same time for the case when the autodetection fails. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
As introduced in aws#10097, Bottlerocket had to be explicitly (and only) selected via setting `machineImageType`, which would pick an appropriate `machineImage`. Setting `machineImage` to `new BottleRocketImage()` would not be sufficient, since the feature also requires configuring additional UserData commands which are only added if `machineImageType` was set. This method of configuration does not allow customization of the AMI, such as introduced in aws#16021. Instead, we reverse the logic: `machineImageType` may still be necessary to autoconfigure UserData if we can't know what the machineImage is (for example in case of a preconfigured AutoScalingGroup), but otherwise is derived from what `machineImage` is being used. We allow configuring both fields at the same time for the case when the autodetection fails. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
As introduced in aws#10097, Bottlerocket had to be explicitly (and only) selected via setting `machineImageType`, which would pick an appropriate `machineImage`. Setting `machineImage` to `new BottleRocketImage()` would not be sufficient, since the feature also requires configuring additional UserData commands which are only added if `machineImageType` was set. This method of configuration does not allow customization of the AMI, such as introduced in aws#16021. Instead, we reverse the logic: `machineImageType` may still be necessary to autoconfigure UserData if we can't know what the machineImage is (for example in case of a preconfigured AutoScalingGroup), but otherwise is derived from what `machineImage` is being used. We allow configuring both fields at the same time for the case when the autodetection fails. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
As introduced in #10097, Bottlerocket had to be explicitly (and only) selected
via setting
machineImageType
, which would pick an appropriatemachineImage
.Setting
machineImage
tonew BottleRocketImage()
would not besufficient, since the feature also requires configuring additional
UserData commands which are only added if
machineImageType
was set.This method of configuration does not allow customization of the AMI,
such as introduced in #16021.
Instead, we reverse the logic:
machineImageType
may still be necessaryto autoconfigure UserData if we can't know what the machineImage is
(for example in case of a preconfigured AutoScalingGroup), but otherwise
is derived from what
machineImage
is being used.We allow configuring both fields at the same time for the case when the
autodetection fails.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license