I'm using AWS CDK and am trying to enable the associatePublicIpAddress
property for an AutoScalingGroup
that's using a launch template.
I'm hitting this error (https://github.com/aws/aws-cdk/blob/master/packages/%40aws-cdk/aws-autoscaling/lib/auto-scaling-group.ts#L1526-L1528)
if (props.associatePublicIpAddress) {
throw new Error('Setting \'associatePublicIpAddress\' must not be set when \'launchTemplate\' or \'mixedInstancesPolicy\' is set');
}
Is it possible to enable public ip addresses with launch templates? I don't see any workarounds documented in the codebase or in the cdk docs.
I believe the error is to prevent the ASG prop from conflicting with a Launch Template's public IP settings. The template's network interface section deals with IPs. Public IPs are assigned by default:
By default, instances in a default subnet receive a public IPv4 address and instances in a nondefault subnet do not. You can select Enable or Disable to override the subnet's default setting.
Looks like the network interface defaults work for you, but if necessary, you can override them with a CfnLaunchTemplate construct.