Skip to content

fix(autoscaling): error not thrown when associatePublicIpAddress is set to false when specifying launchTemplate#21714

Merged
mergify[bot] merged 3 commits intomainfrom
peterwoodworth/autoscalingPropBug
Aug 25, 2022
Merged

fix(autoscaling): error not thrown when associatePublicIpAddress is set to false when specifying launchTemplate#21714
mergify[bot] merged 3 commits intomainfrom
peterwoodworth/autoscalingPropBug

Conversation

@peterwoodworth
Copy link
Copy Markdown
Contributor

@peterwoodworth peterwoodworth commented Aug 22, 2022

Setting associatePublicIpAddress prop when also setting launchTemplate prop on a new ASG is supposed to throw an error, but doesn't due to associatePublicIpAddress being a boolean, and the error message not triggering if a falsy value is used for the prop. This PR will ensure an error is thrown when associatePublicIpAddress is set, even when the value passed is falsy. It also updates the documentation on all props which conflict with launchTemplate or mixedInstancesPolicy

fixes: #21576


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
Copy Markdown

gitpod-io bot commented Aug 22, 2022

@github-actions github-actions bot added the p2 label Aug 22, 2022
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Aug 22, 2022
@aws-cdk-automation aws-cdk-automation requested a review from a team August 22, 2022 21:26
* Type of instance to launch
*
* `launchTemplate` must not be specified when this property is specified.
* Cannot specify this property when `launchTemplate` or `mixedInstancesPolicy` are specified
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This comment stands for each instance here (I won't repeat it because that's just kind of annoying), but I think we actually want the original style comment of:

`whatever` must not be specified when `whatever-else` is specified.

throw new Error('Setting \'instanceMonitoring\' must not be set when \'launchTemplate\' or \'mixedInstancesPolicy\' is set');
}
if (props.associatePublicIpAddress) {
if (props.associatePublicIpAddress || props.associatePublicIpAddress === false) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not sure I get why setting it to false should be an issue here. It seems like we're mishandling it somewhere else and that's where we need to apply the fix.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This could probably be simplified to if (props.associatePublicIpAddress !== undefined).

It looks like if you specify the launchTemplate then you must specify the associatePublicIpAddress on the LaunchTemplate and not the AutoScalingGroup. The problem in the linked issue is that associatePublicIpAddress must be specified in the LaunchTemplate.networkInterfaces property which is not currently supported, which means that you can't use launchTemplate and set associatePublicIpAddress: false currently. Which is not great.

I think long term we should deprecate the AutoScalingGroup construct and create a AutoScalingGroupV2 (or something) which accepts an ILaunchConfiguration instead of just having all the properties for a LaunchConfiguration in the AutoScalingGroupProps.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yep, the design here isn't too great. However I'm not sure what we can do for now except ensure the error gets thrown.

* You can use block device mappings to specify additional EBS volumes or
* instance store volumes to attach to an instance when it is launched.
*
* `launchTemplate` and `mixedInstancesPolicy` must not be specified when this property is specified
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Aug 25, 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
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 1bf056c
  • 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 da61adc into main Aug 25, 2022
@mergify mergify bot deleted the peterwoodworth/autoscalingPropBug branch August 25, 2022 16:28
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Aug 25, 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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contribution/core This is a PR that came from AWS. p2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AutoScalingGroupProps.AssociatePublicIpAddress has no effect

5 participants