You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(elasticloadbalancerV2): logicalId supports switch from addTargetGroups (under feature flag) (#29513)
### Issue ELBv2 logicalId inconsistency of ApplicationListenerRule logicalIds
Mitigates #29496
### Reason for this change
People using ALBs who need to migrate from the `addTargetGroups()` convenience method to the lower level `addAction()` method should not be blocked due to inconsistent logicalId's. Further, the logicalIds should be consistent going forward.
### Description of changes
There are two feature flags, one which sets a migration compat mode and another which fixed the behaviour to be consistent.
### Description of how you validated changes
Unit testing.
### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)
----
*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
- Set `introducedIn.v2` to the literal string `'V2NEXT'`.
1200
1202
- Double negatives should be avoided. If you want to add a flag that disables something that was previously
1201
1203
enabled, set `default.v2` to `true` and the `recommendedValue` to `false`. You will need to update
1202
1204
a test in `features.test.ts` -- this is okay if you have a good reason.
1203
-
2. Use `FeatureFlags.of(construct).isEnabled(cxapi.ENABLE_XXX)` to check if this feature is enabled
1204
-
in your code. If it is not defined, revert to the legacy behavior.
1205
-
3. Add your feature flag to the `FLAGS` map in
1206
-
[cx-api/lib/features.ts](https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/cx-api/lib/features.ts). In
1207
-
your description, be sure to cover the following:
1205
+
In your description, be sure to cover the following:
1208
1206
- Consciously pick the type of feature flag. Can the flag be removed in a future major version, or not?
1209
1207
- Motivate why the feature flag exists. What is the change to existing infrastructure and why is it not safe?
1210
1208
- In case of a "default change flag", describe what the user needs to do to restore the old behavior.
1209
+
3. Use `FeatureFlags.of(construct).isEnabled(cxapi.ENABLE_XXX)` to check if this feature is enabled
1210
+
in your code. If it is not defined, revert to the legacy behavior.
1211
1211
4. Add an entry for your feature flag in the [README](https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/cx-api/README.md) file.
1212
1212
5. In your tests, ensure that you test your feature with and without the feature flag enabled. You can do this by passing the feature flag to the `context` property when instantiating an `App`.
Copy file name to clipboardExpand all lines: packages/aws-cdk-lib/cx-api/FEATURE_FLAGS.md
+17
Original file line number
Diff line number
Diff line change
@@ -67,6 +67,8 @@ Flags come in three types:
67
67
|[@aws-cdk/aws-codepipeline:crossAccountKeysDefaultValueToFalse](#aws-cdkaws-codepipelinecrossaccountkeysdefaultvaluetofalse)| Enables Pipeline to set the default value for crossAccountKeys to false. | 2.127.0 | (default) |
68
68
|[@aws-cdk/aws-codepipeline:defaultPipelineTypeToV2](#aws-cdkaws-codepipelinedefaultpipelinetypetov2)| Enables Pipeline to set the default pipeline type to V2. | 2.133.0 | (default) |
69
69
|[@aws-cdk/aws-kms:reduceCrossAccountRegionPolicyScope](#aws-cdkaws-kmsreducecrossaccountregionpolicyscope)| When enabled, IAM Policy created from KMS key grant will reduce the resource scope to this key only. | 2.134.0 | (fix) |
70
+
| [@aws-cdk/aws-elasticloadbalancingv2:ExternalApplicationListener-noRuleSuffixForAddAction](#aws-cdkaws-elasticloadbalancingv2externalapplicationlistener-norulesuffixforaddaction) | When enabled, you can switch from the `addTargetGroups()` method of declaring a `ListenerRule` to the `addAction()` method,
71
+
without changing the logicalId and replacing your resource. | V2NEXT | (fix) |
70
72
71
73
<!-- END table -->
72
74
@@ -1265,4 +1267,19 @@ When this feature flag is enabled and calling KMS key grant method, the created
Alternatively, do not enable this feature flag and instead consider the `@aws-cdk/aws-elasticloadbalancingv2:ExternalApplicationListener-noRuleSuffixForAddAction` as necessary.
summary: 'When enabled, you can switch from the \`addTargetGroups()\` method of declaring a \`ListenerRule\` to the \`addAction()\` method, without changing the logicalId and replacing your resource.',
1043
+
detailsMd: `
1044
+
When switching from a less complex to a more complex use of ALB,
1045
+
you will eventually need features not available in the \`addTargetGroups()\` convenience method.
1046
+
In this case you will want to use the \`addAction()\` method.
1047
+
Before this feature is enabled, switching over to \`addAction()\` from using \`addTargetGroups()\`
1048
+
will add a \`Rule\` suffix to the logicalId of your \`ListenerRule\`,
1049
+
causing CloudFormation to attempt to replace the resource.
1050
+
Since \`ListenerRule\`s have a unique priority,
1051
+
CloudFormation will always fail when generating the new \`ListenerRule\`.
1052
+
1053
+
Setting this feature flag will cause the \`addAction()\` method to not add the \`Rule\` suffix on the logicalId.
1054
+
This allows you to switch from the \`addTargetGroups()\` method without having CloudFormation deadlock while attempting to replace the resource.
0 commit comments