-
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 availabilityZoneDistribution
property to an AutoScalingGroup
#32100
feat(autoscaling): add availabilityZoneDistribution
property to an AutoScalingGroup
#32100
Conversation
availabilityZoneDistribution
property to a AutoScalingGroupavailabilityZoneDistribution
property to a AutoScalingGroup
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.
availabilityZoneDistribution
property to a AutoScalingGroupavailabilityZoneDistribution
property to a AutoScalingGroup
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
…vailability-zone-distribution
availabilityZoneDistribution
property to a AutoScalingGroupavailabilityZoneDistribution
property to an AutoScalingGroup
…vailability-zone-distribution
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #32100 +/- ##
=======================================
Coverage 80.54% 80.54%
=======================================
Files 106 106
Lines 6954 6954
Branches 1287 1287
=======================================
Hits 5601 5601
Misses 1175 1175
Partials 178 178
Flags with carried forward coverage won't be shown. Click here to find out more.
|
…vailability-zone-distribution
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.
Thank you for the contribution.
I've commented on property design.
If you have any thoughts on that please let me know.
* The instance capacity distribution across Availability Zones. | ||
* @default { capacityDistributionStrategy: CapacityDistributionStrategy.BALANCED_BEST_EFFORT } | ||
*/ | ||
readonly availabilityZoneDistribution?: AvailabilityZoneDistribution; |
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.
IMO, we can reduce a nest like this:
readonly azCapacityDistributionStrategy?: CapacityDistributionStrategy;
In the design docs, fewer nesting is preferred.
@@ -1529,6 +1560,7 @@ export class AutoScalingGroup extends AutoScalingGroupBase implements | |||
|
|||
const asgProps: CfnAutoScalingGroupProps = { | |||
autoScalingGroupName: this.physicalName, | |||
availabilityZoneDistribution: props.availabilityZoneDistribution, |
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 we reduce nest, we can set property like this:
availabilityZoneDistribution: props.azCapacityDistributionStrategy ? { capacityDistributionStrategy: props.azCapacityDistributionStrategy } : undefined,
…vailability-zone-distribution
@Mergifyio update |
☑️ Nothing to do
|
@Mergifyio update |
☑️ Nothing to do
|
I am getting the following error in Report creating failed: {“message”: “Token required because branch is protected”} However, I do not have this branch protected and am not sure of the direct cause. Also, How can I resolve these issues? |
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! Some minor comments.
I'm not sure why Codecov failed.
Let's see if the issue persists after the changes are applied.
|
||
/** | ||
* The strategy for distributing instances across Availability Zones. | ||
* @default BALANCED_BEST_EFFORT |
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.
* @default BALANCED_BEST_EFFORT | |
* @default CapacityDistributionStrategy.BALANCED_BEST_EFFORT |
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 launches fail in an Availability Zone, Auto Scaling will attempt to launch in another healthy Availability Zone instead. | ||
*/ | ||
BALANCED_BEST_EFFORT= 'balanced-best-effort', |
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.
nit: space
BALANCED_BEST_EFFORT= 'balanced-best-effort', | |
BALANCED_BEST_EFFORT = 'balanced-best-effort', |
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.
Thank you for comment! Also, I fixed the default value of (Codecov seems to have fixed it too! Thank you 😆 ) |
@@ -1530,6 +1550,9 @@ export class AutoScalingGroup extends AutoScalingGroupBase implements | |||
|
|||
const asgProps: CfnAutoScalingGroupProps = { | |||
autoScalingGroupName: this.physicalName, | |||
availabilityZoneDistribution: props.azCapacityDistributionStrategy | |||
? { capacityDistributionStrategy: props.azCapacityDistributionStrategy } | |||
: { capacityDistributionStrategy: CapacityDistributionStrategy.BALANCED_BEST_EFFORT }, |
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.
Thank you for the fix.
But I think default value should be undefined
.
The @default
should describe the behavior at that time.
When the default value is explicitly set, it causes a breaking change.
This is because before and after this PR merged, the synth result changes when props.azCapacityDistributionStrategy
is omitted.
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.
thank you!
I see, I understand.
So, I will also omit the description of default in JSDoc, is that correct?
(Because there was no mention of default values in the CloudFormation documentation...)
https://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/aws-properties-autoscaling-autoscalinggroup-availabilityzonedistribution.html
/**
* The strategy for distributing instances across Availability Zones.
- * @default CapacityDistributionStrategy.BALANCED_BEST_EFFORT
*/
readonly azCapacityDistributionStrategy?: CapacityDistributionStrategy;
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.
For optional properties, @default
is necessary.
Also, it's common that default value behaviors are not documented in the CFn documentation.
In such cases, I often verify the default value by deploying without specifying the value.
When I tried deploying it without availabilityZoneDistribution
property, the value became Balanced best effort
, so I think this is the default value.
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.
Thank you for the details.
I have corrected it with the following commit!
…vailability-zone-distribution
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! LGTM
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). |
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 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 main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Comments on closed issues and PRs are hard for our team to see. |
Issue # (if applicable)
n/A
Reason for this change
We can set a
availabilityZoneDistribution
for an AutoScalingGroup from cloudformation, but this was not supported in the AWS CDK L2 construct.Description of changes
Add
availabilityZoneDistribution
property to CommonAutoScalingGroupProps and set it in the CfnAutoScalingGroup.Description of how you validated changes
Added both unit and integration tests.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license