-
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
feat(autoscaling): add support for InstanceRequirements
property
#28464
Conversation
InstanceRequirements
/** | ||
* The instance requirements. Amazon EC2 Auto Scaling uses your specified requirements to identify instance types. | ||
* Then, it uses your On-Demand and Spot allocation strategies to launch instances from these instance types. | ||
* You can specify up to four separate sets of instance requirements per Auto Scaling group. | ||
* This is useful for provisioning instances from different Amazon Machine Images (AMIs) in the same Auto Scaling group. | ||
* To do this, create the AMIs and create a new launch template for each AMI. | ||
* Then, create a compatible set of instance requirements for each launch template. | ||
* | ||
* If you specify InstanceRequirements, you can't specify InstanceType. | ||
* | ||
* @default - Do not override instance type | ||
*/ |
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.
if (override.instanceType && override.instanceRequirements) { | ||
throw new Error('\'InstanceRequirements\' can\'t be specified with \'InstanceType\''); | ||
} |
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.
If you specify InstanceRequirements, you can't specify InstanceType.
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.
The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.
A comment requesting an exemption should contain the text Exemption Request
. Additionally, if clarification is needed add Clarification Request
to a comment.
InstanceRequirements
InstanceRequirements
property
Exemption Request
I add doc comment for
I add test at |
Exemption Request I add doc comment for instanceRequirements property |
Exemption Request: I add doc comment for instanceRequirements property / I add test at auto-scaling-group.test.ts |
@wafuwafu13 please add an integration test or update an existing one |
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.
Thanks for starting this.
This is still a work in progress as the property needs to be implemented in the L2 construct directly.
Also, the related documentation, unit, and integration tests are required as this is a new feature.
* | ||
* @default - Do not override instance type | ||
*/ | ||
readonly instanceRequirements?: CfnAutoScalingGroup.InstanceRequirementsProperty |
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.
We'll need to implement the interface in the L2 construct and not make use of the existing one from L1.
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.
Do you mean I should define instanceRequirements
in another place?
If so, I would be grateful if you could tell me where to define it.
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.
Nevermind, I got it wrong.
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
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.
Thanks 👍
I think we should require one of instanceType
or instanceRequirements
to be specified, feel free to comment if you think otherwise.
* | ||
* @default - Do not override instance type | ||
*/ | ||
readonly instanceRequirements?: CfnAutoScalingGroup.InstanceRequirementsProperty |
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.
Nevermind, I got it wrong.
@@ -1810,11 +1824,15 @@ export class AutoScalingGroup extends AutoScalingGroupBase implements | |||
if (override.weightedCapacity && Math.floor(override.weightedCapacity) !== override.weightedCapacity) { | |||
throw new Error('Weight must be an integer'); | |||
} | |||
if (override.instanceType && override.instanceRequirements) { | |||
throw new Error('\'InstanceRequirements\' can\'t be specified with \'InstanceType\''); |
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.
throw new Error('\'InstanceRequirements\' can\'t be specified with \'InstanceType\''); | |
throw new Error('You can specify either \'instanceRequirements\' or \'instanceType\', not both.'); |
Message formatting.
@@ -91,6 +91,29 @@ new autoscaling.AutoScalingGroup(this, 'ASG', { | |||
}); | |||
``` | |||
|
|||
You can specify instance requirements in `InstanceRequirements`: |
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.
You can specify instance requirements in `InstanceRequirements`: | |
You can specify instances requirements with the `instanceRequirements ` property: |
* To do this, create the AMIs and create a new launch template for each AMI. | ||
* Then, create a compatible set of instance requirements for each launch template. | ||
* | ||
* If you specify InstanceRequirements, you can't specify InstanceType. |
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.
* If you specify InstanceRequirements, you can't specify InstanceType. | |
* You must specify one of instanceRequirements or instanceType. |
Thank you for reviewing! I fixed. |
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). |
@Mergifyio update |
❌ Mergify doesn't have permission to updateFor security reasons, Mergify can't update this pull request. Try updating locally. |
Pull request has been modified.
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
…ws#28464) Closes aws#28393 > Basically [LaunchTemplateOverrides](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_autoscaling.LaunchTemplateOverrides.html) for L2 construct is missing the [InstanceRequirements](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-autoscaling-autoscalinggroup-launchtemplateoverrides.html#cfn-autoscaling-autoscalinggroup-launchtemplateoverrides-instancerequirements) attribute. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --------- Co-authored-by: Sumu Pitchayan <35242245+sumupitchayan@users.noreply.github.com>
Closes #28393
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license