feat(cli): can ignore errors and return dummy value in CloudControl API context provider #211
+226
−17
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
CDK app with CC API Context Provider fails if the resource we want to get doesn't exist.
Also CC API Context Provider (
CcApiContextProviderPlugin
) cannot ignore errors even ifignoreErrorOnMissingContext
is passed in aws-cdk-lib because the current code in aws-cdk-cli doesn't handle the property.Sample cdk-lib code (based on my PR for IAM Role fromLookup):
However it would be good if the provider can ignore errors and return any dummy value to cdk library. This allows all resources to be used if available, or created if not.
Actually, SSM and KMS provider can ignore errors:
KMS: https://github.com/aws/aws-cdk-cli/blob/main/packages/aws-cdk/lib/context-providers/keys.ts#L43-L48
SSM: https://github.com/aws/aws-cdk-cli/blob/main/packages/aws-cdk/lib/context-providers/ssm-parameters.ts#L27-L30
For example, in cdk-lib, we can specify ignoreErrorOnMissingContext in the
fromLookup
. ThedummyValue
andignoreErrorOnMissingContext
properties can also be specified in GetContextValueOptions.cli-integ
aws/aws-cdk-cli-testing#50
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license