Import VPC from existing stack
See original GitHub issueHello,
typescript. I have an existing stack (non CDK, provisioned via aws cli). The stack has VCP resource and it is exported so that other stacks could use it.
aws cloudformation describe-stacks --stack-name network --query 'Stacks[*].Outputs[?ExportName==`VPC`]'
[
[
{
"OutputKey": "VpcOutput",
"OutputValue": "vpc-0d9c4bf811814d8f7",
"Description": "The ID of VPC",
"ExportName": "VPC"
}
]
]
How can I import it and pass it to CDK so that it can be used as an input parameter to any construct that requires VPC?
thanks
Issue Analytics
- State:
- Created 4 years ago
- Comments:12 (8 by maintainers)
Top Results From Across the Web
How to import an Existing VPC in AWS CDK | bobbyhadz
To import an existing, external VPC in CDK, we have to use the `fromLookup` static method on the Vpc construct.
Read more >How to import existing VPC in aws cdk? - Stack Overflow
If your VPC is created outside your CDK app, you can use Vpc.fromLookup(). The CDK CLI will search for the specified VPC in...
Read more >Importing VPC IDs into a stack with CDK - DEV Community
When we want to import a VPC ID from another stack using CDK, not all methods will accept the imported value. Errors can...
Read more >Importing existing resources into a stack - AWS CloudFormation
Import an existing resource into a stack using the AWS Management Console. Sign in to the AWS Management Console and open the AWS...
Read more >How to import existing VPC in aws cdk | Edureka Community
If your VPC is created outside your cdk app you can use Vpc.formLookup(). The CDK CLI will search for the specified VPC in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@hoegertn Thanks for the reply. I don’t quite understand why would I ever need availibity zones or subnets. Isn’t unique VPC id enough to target an existing VPC?
This is at least how https://docs.aws.amazon.com/cli/latest/reference/ec2/create-security-group.html (and all SDks I have worked with) and cloudformation work, where VPC id is all they need.
regards
@hoegertn - I am afraid I completely don’t undestand your statement. Say, I have 1 VPC and 3 subnets within the VPC. What if I pass only 2 subnets to ‘fromVpcAttributes’? Did I create a semi-constructed object? How does VPC imported with az1 and az2 differ from VPC with az3 and az4?
@NGL321 - I managed to reuse existing VPC, but I had to pass some meaningless attributes there were never used by the resource that needed the VPC. Go ahead and close it.