amazon-web-servicesaws-cdkamazon-vpcterraform-cdk

How to import existing AWS resources like VPC using cdktf?


I can import AWS resources using AWS CDK (python) like this

   # lookup existing VPC
    vpc = ec2.Vpc.from_lookup(self,"vpc",vpc_id=vpcID,)
    
    #lookup existing Security group
    sec_group = ec2.SecurityGroup.from_lookup_by_id(self,'SG',sgID) 

I cannot find proper documentation or example of doing the same in terraform cdktf


Solution

  • CDKTF(Terraform) provides data sources to fetch information from resources created outside of Terraform, therefore you can use the DataAwsVpc method.