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(autoscaling): add support for InstanceRequirements property #28464

Merged
merged 6 commits into from Dec 28, 2023

Conversation

wafuwafu13
Copy link
Contributor

Closes #28393

Basically LaunchTemplateOverrides for L2 construct is missing the InstanceRequirements attribute.


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

@aws-cdk-automation aws-cdk-automation requested a review from a team December 22, 2023 11:07
@github-actions github-actions bot added effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2 repeat-contributor [Pilot] contributed between 3-5 PRs to the CDK labels Dec 22, 2023
@wafuwafu13 wafuwafu13 changed the title feat(autoscaling/LaunchTemplateOverrides): add support for InstanceRequirements feat(autoscaling/LaunchTemplateOverrides): add support for InstanceRequirements Dec 22, 2023
Comment on lines 553 to 564
/**
* 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
*/
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines 1827 to 1829
if (override.instanceType && override.instanceRequirements) {
throw new Error('\'InstanceRequirements\' can\'t be specified with \'InstanceType\'');
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

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 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.

@wafuwafu13 wafuwafu13 changed the title feat(autoscaling/LaunchTemplateOverrides): add support for InstanceRequirements feat(autoscaling): add support for InstanceRequirements property Dec 22, 2023
@wafuwafu13
Copy link
Contributor Author

Exemption Request

❌ Features must contain a change to a README file.

I add doc comment for instanceRequirements property

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

I add test at auto-scaling-group.test.ts

@aws-cdk-automation aws-cdk-automation added the pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback. label Dec 22, 2023
@wafuwafu13
Copy link
Contributor Author

Exemption Request

I add doc comment for instanceRequirements property
I add test at auto-scaling-group.test.ts

@aws-cdk-automation aws-cdk-automation added pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. and removed pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback. pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. labels Dec 22, 2023
@wafuwafu13
Copy link
Contributor Author

Exemption Request: I add doc comment for instanceRequirements property / I add test at auto-scaling-group.test.ts

@aws-cdk-automation aws-cdk-automation added pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback. pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. labels Dec 22, 2023
@sumupitchayan
Copy link
Contributor

@wafuwafu13 please add an integration test or update an existing one

Copy link
Contributor

@lpizzinidev lpizzinidev left a 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
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Dec 22, 2023
@aws-cdk-automation aws-cdk-automation dismissed their stale review December 23, 2023 03:51

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

Copy link
Contributor

@lpizzinidev lpizzinidev left a 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
Copy link
Contributor

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\'');
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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`:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* If you specify InstanceRequirements, you can't specify InstanceType.
* You must specify one of instanceRequirements or instanceType.

@wafuwafu13
Copy link
Contributor Author

Thank you for reviewing! I fixed.

sumupitchayan
sumupitchayan previously approved these changes Dec 28, 2023
Copy link
Contributor

mergify bot commented Dec 28, 2023

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).

@sumupitchayan
Copy link
Contributor

@Mergifyio update

Copy link
Contributor

mergify bot commented Dec 28, 2023

update

❌ Mergify doesn't have permission to update

For security reasons, Mergify can't update this pull request. Try updating locally.
GitHub response: refusing to allow a GitHub App to create or update workflow .github/workflows/close-stale-prs.yml without workflows permission

@mergify mergify bot dismissed sumupitchayan’s stale review December 28, 2023 15:14

Pull request has been modified.

@sumupitchayan sumupitchayan merged commit 276e3a6 into aws:main Dec 28, 2023
9 checks passed
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

paulhcsun pushed a commit to paulhcsun/aws-cdk that referenced this pull request Jan 5, 2024
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2 pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback. repeat-contributor [Pilot] contributed between 3-5 PRs to the CDK
Projects
None yet
4 participants