This repository was archived by the owner on Apr 22, 2025. It is now read-only.
feat(cli-integ): add new test for fromLookup() with dummy#50
Closed
feat(cli-integ): add new test for fromLookup() with dummy#50
fromLookup() with dummy#50Conversation
auto-merge was automatically disabled
March 12, 2025 06:46
Head branch was pushed to by a user without write access
github-merge-queue bot
pushed a commit
to aws/aws-cdk-cli
that referenced
this pull request
Mar 25, 2025
…PI context provider (#211) CDK app with CC API Context Provider fails if the resource we want to get doesn't exist. ``` [Error at /LookupStack] Encountered CC API error while getting resource MyLookupTestRole. Error: ResourceNotFoundException: AWS::IAM::Role Handler returned status FAILED: The role with name MyLookupTestRole cannot be found. (Service: Iam, Status Code: 404, Request ID: xxxx-xxx-xxxx-xxxx) (HandlerErrorCode: NotFound, RequestToken: xxxx-xxx-xxxx-xxxx) ``` Also CC API Context Provider (`CcApiContextProviderPlugin`) cannot ignore errors even if `ignoreErrorOnMissingContext` 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](aws/aws-cdk#33603) for IAM Role fromLookup): ```ts const response: {[key: string]: any}[] = ContextProvider.getValue(scope, { provider: cxschema.ContextProvider.CC_API_PROVIDER, props: { typeName: 'AWS::IAM::Role', exactIdentifier: options.roleName, propertiesToReturn: [ 'Arn', ], } as cxschema.CcApiContextQuery, dummyValue: [ { // eslint-disable-next-line @cdklabs/no-literal-partition Arn: 'arn:aws:iam::123456789012:role/DUMMY_ARN', }, ], ignoreErrorOnMissingContext: options.returnDummyRoleOnMissing, // added }).value; ``` 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](https://github.com/aws/aws-cdk/blob/v2.182.0/packages/aws-cdk-lib/aws-kms/lib/key.ts#L741-L744) in the `fromLookup`. The `dummyValue` and `ignoreErrorOnMissingContext` properties can also be specified in [GetContextValueOptions](https://github.com/go-to-k/aws-cdk/blob/45a276fd0fc9b7b08f69f7faf3d0091796ab1663/packages/aws-cdk-lib/core/lib/context-provider.ts#L31-L45). ## 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 --------- Co-authored-by: Rico Hermans <rix0rrr@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Add a new integ test for the PR in aws-cdk-cli: aws/aws-cdk-cli#211