How to import existing VPC in aws cdk

0 votes

Hi I am working on aws cdk. I am trying to get existing non-default vpc. I tried below options.

vpc = ec2.Vpc.from_lookup(self, id = "VPC", vpc_id='vpcid', vpc_name='vpc-dev')

This results in below error

[Error at /LocationCdkStack-cdkstack] Request has expired.
[Warning at /LocationCdkStack-cdkstack/TaskDef/mw-service] Proper policies need to be attached before pulling from ECR repository, or use 'fromEcrRepository'.
Found errors

Other method I tried is

vpc = ec2.Vpc.from_vpc_attributes(self, 'VPC', vpc_id='vpc-839227e7', availability_zones=['ap-southeast-2a','ap-southeast-2b','ap-southeast-2c'])

This results in

[Error at /LocationCdkStack-cdkstack] Request has expired.
[Warning at /LocationCdkStack-cdkstack/TaskDef/mw-service] Proper policies need to be attached before pulling from ECR repository, or use 'fromEcrRepository'.
Found errors

Other method I tried is

vpc = ec2.Vpc.from_lookup(self, id = "VPC", is_default=True) // This will get default vpc and this will work

Can someone help me to get non-default vpc in aws cdk? Any help would be appreciated. Thanks

Mar 9, 2022 in Others by Edureka
• 13,690 points
956 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Others

0 votes
1 answer

How to create subnet inside a VPC in AWS using Terraform?

Hi@akhtar, You need to use aws_subnet resource inside your ...READ MORE

answered Jul 21, 2020 in Others by MD
• 95,460 points
589 views
0 votes
0 answers

how to import jar in Mac

Jul 7, 2019 in Others by anonymous
780 views
0 votes
1 answer

How to import module in Flutter code?

Hi@akhtar, You can import your module from different ...READ MORE

answered Jul 23, 2020 in Others by MD
• 95,460 points
1,771 views
0 votes
1 answer

How to import excel file in Oracle SQL live

Hello, there are a few steps You'll ...READ MORE

answered Feb 18, 2022 in Others by gaurav
• 23,260 points
2,075 views
0 votes
0 answers
0 votes
1 answer
0 votes
1 answer

How to add S3 BucketPolicy with AWS CDK?

In AWS CDK, there are two ways ...READ MORE

answered Mar 9, 2022 in Others by gaurav
• 23,260 points
3,209 views
0 votes
0 answers

How to add S3 BucketPolicy with AWS CDK?

I wanna translate this CloudFormation piece into ...READ MORE

Mar 11, 2022 in Others by Edureka
• 13,690 points
1,081 views
0 votes
1 answer

How to use AWS S3 CLI to dump files to stdout in BASH?

All file objects must have their contents ...READ MORE

answered Mar 24, 2022 in Others by gaurav
• 23,260 points
2,086 views
0 votes
1 answer

NodeJS Amazon AWS S3 getObject how to send file in API response to download

Server Side const aws = require('aws-sdk'); router.get('/getfilefroms3', async (req, ...READ MORE

answered Mar 24, 2022 in Others by gaurav
• 23,260 points
9,651 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP