question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Import VPC from existing stack

See original GitHub issue

Hello,

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:closed
  • Created 4 years ago
  • Comments:12 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
lkonieczcommented, Jun 13, 2019

@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

2reactions
lkonieczcommented, Jun 26, 2019

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found