feat(cli): build your own fromLookup() imports with the new context provider for CloudControl API#138
Merged
aws-cdk-automation merged 13 commits intomainfrom Feb 26, 2025
Merged
Conversation
A generic Context Provider for CloudControl API. Extracted from aws/aws-cdk#33258.
Signed-off-by: github-actions <github-actions@github.com>
Signed-off-by: github-actions <github-actions@github.com>
mrgrain
reviewed
Feb 25, 2025
mrgrain
reviewed
Feb 25, 2025
| } from '../../lib/commands/migrate'; | ||
| import { MockSdkProvider, mockCloudFormationClient, restoreSdkMocksToDefault } from '../util/mock-sdk'; | ||
|
|
||
| jest.setTimeout(120_000); |
mrgrain
requested changes
Feb 25, 2025
Contributor
mrgrain
left a comment
There was a problem hiding this comment.
One minor comment. Otherwise good to go.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #138 +/- ##
==========================================
- Coverage 84.76% 84.58% -0.19%
==========================================
Files 196 198 +2
Lines 35187 35380 +193
Branches 4552 4555 +3
==========================================
+ Hits 29828 29926 +98
- Misses 5208 5310 +102
+ Partials 151 144 -7
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: github-actions <github-actions@github.com>
Signed-off-by: github-actions <github-actions@github.com>
Signed-off-by: github-actions <github-actions@github.com>
Signed-off-by: github-actions <github-actions@github.com>
mrgrain
approved these changes
Feb 26, 2025
fromLookup() imports with the new context provider for CloudControl API
This was referenced Feb 27, 2025
1 task
mergify bot
pushed a commit
to aws/aws-cdk
that referenced
this pull request
Mar 24, 2025
### Issue # (if applicable) Closes #33606. Closes #15115. ### Reason for this change AWS-managed prefix lists are useful to control traffic VPC and AWS managed services. The name of the AWS-managed prefix list is documented but the id should be copy&paste by hand. ### Description of changes This PR implements `PrefixList.fromLookup()` to look up an existing managed prefix list by name. ``` ts ec2.PrefixList.fromLookup(this, 'CloudFrontOriginFacing', { prefixListName: 'com.amazonaws.global.cloudfront.origin-facing', }); ``` Uses the new CloudControl context provider: aws/aws-cdk-cli#138 and cdklabs/cloud-assembly-schema#124. ### Describe any new or updated permissions being added Nothing. ### Description of how you validated changes Added unit tests and an integ test. ### 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*
shikha372
pushed a commit
to shikha372/aws-cdk
that referenced
this pull request
Apr 4, 2025
### Issue # (if applicable) Closes aws#33606. Closes aws#15115. ### Reason for this change AWS-managed prefix lists are useful to control traffic VPC and AWS managed services. The name of the AWS-managed prefix list is documented but the id should be copy&paste by hand. ### Description of changes This PR implements `PrefixList.fromLookup()` to look up an existing managed prefix list by name. ``` ts ec2.PrefixList.fromLookup(this, 'CloudFrontOriginFacing', { prefixListName: 'com.amazonaws.global.cloudfront.origin-facing', }); ``` Uses the new CloudControl context provider: aws/aws-cdk-cli#138 and cdklabs/cloud-assembly-schema#124. ### Describe any new or updated permissions being added Nothing. ### Description of how you validated changes Added unit tests and an integ test. ### 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*
mergify bot
pushed a commit
to aws/aws-cdk
that referenced
this pull request
Apr 10, 2025
### Issue # (if applicable) Closes #31720 This replaces my previous PR #32901. I addressed the PR comments in this new PR. This depends on this PR: cdklabs/cloud-assembly-schema#124. Also depends on this CDK CLI PR: aws/aws-cdk-cli#138. That PR should be merged first and the CLI released, before this PR can be merged. ### Reason for this change Add DatabaseInstance.fromLookup() feature ### Description of changes * Add CC API Context Provider. Needs this PR: cdklabs/cloud-assembly-schema#124 * DatabaseInstance.fromLookup call CC API to get the database instance info from instanceIdentifier. * Add units tests. ### Describe any new or updated permissions being added User will need to have permission to run CloudControl API. ### Description of how you validated changes Tested with this code. I already have an RDS DB in my AWS account. I want to look it up and grant connect to a new user. Saved to packages/@aws-cdk-testing/framework-integ/test/aws-rds/test/my-test-app.ts ``` import * as cdk from 'aws-cdk-lib'; import * as iam from 'aws-cdk-lib/aws-iam'; import * as rds from 'aws-cdk-lib/aws-rds'; const awsAccountId = 'XXXXXXXXXX79'; const instanceId = 'XXXXXXXXXX-instance-1'; const appWithDb = new cdk.App(); const stack = new cdk.Stack(appWithDb, 'StackWithVpc', { env: { region: 'us-east-1', account: awsAccountId, }, }); const dbFromLookup = rds.DatabaseInstance.fromLookup(stack, 'dbFromLookup', { instanceIdentifier: instanceId, }); /* eslint-disable no-console */ console.log('lookup values', dbFromLookup.dbInstanceEndpointAddress, dbFromLookup.dbInstanceEndpointPort); const consoleReadOnlyRole = new iam.Role(stack, 'TestRole', { assumedBy: new iam.ArnPrincipal('arn_for_trusted_principal'), }); dbFromLookup.grantConnect(consoleReadOnlyRole, 'dbTestUser'); ``` Ran this command: ``` ../../aws-cdk/bin/cdk -a 'npx ts-node test/aws-rds/test/my-test-app.ts' synth ``` ### 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*
mergify bot
pushed a commit
to aws/aws-cdk
that referenced
this pull request
Apr 23, 2025
### Issue # (if applicable) Closes #33602. ### Reason for this change There will be many cases where IAM roles will be created outside the CFn stack and used. Importing actual existing roles from AWS accounts is very convenience. It is also useful to be able to make an error if a role does not exist. On the other hand, a generic Context Provider for CloudControl API has been added in aws-cdk-cli. aws/aws-cdk-cli#138 This allows us to implement new context methods. ### Description of changes Add `Role.fromLookup` method using the new context provider. ### Describe any new or updated permissions being added ### Description of how you validated changes Both unit and integ tests. ### 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*
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
A generic Context Provider for CloudControl API. See aws/aws-cdk#33258 for an example how to implement a
fromLookup()method using the new context provider.(Extracted from aws/aws-cdk#33258)
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license