Skip to content

Instantly share code, notes, and snippets.

@patrobinson
Created May 7, 2020 10:08
Show Gist options
  • Save patrobinson/312b3fb955758cd19528b89b4b757605 to your computer and use it in GitHub Desktop.
Save patrobinson/312b3fb955758cd19528b89b4b757605 to your computer and use it in GitHub Desktop.
Replicate unable to lookup VPC in CDK
import * as core from "@aws-cdk/core";
import * as ec2 from "@aws-cdk/aws-ec2";
export class MyStack extends core.Stack {
constructor(scope: core.Construct, id: string, props: core.StackProps) {
super(scope, id, props);
console.log(ec2.Vpc.fromLookup(this, "Vpc1", { isDefault: true }).vpcId);
}
}
const app = new core.App();
const stack = new MyStack(app, "App", {env: {region: "us-east-1", account: "012345678910"}});
{
"name": "foo",
"version": "0.0.0",
"author": "Patrick Robinson @patrobinson",
"dependencies": {
"@aws-cdk/aws-ec2": "^1.37.0",
"@aws-cdk/core": "^1.37.0",
"aws-cdk": "^1.37.0",
"tslib": "^1.11.2",
"typescript": "^3.8.3"
}
}
{
"compilerOptions": {
"declaration": true,
"esModuleInterop": true,
"importHelpers": true,
"module": "commonjs",
"outDir": "lib",
"resolveJsonModule": true,
"rootDir": "src",
"strict": true,
"target": "es2018"
},
"include": [
"src/**/*"
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment