Open4

CDK

kenpikenpi
  • cdk init・・・初期プロジェクト作成 bin/lib/ができる
  • cdk synth・・・今のCDKをロードし、デプロイされるCloudFormationテンプレートを作成
  • cdk bootstrap
cdk bootstrap
 ⏳  Bootstrapping environment aws://654654550185/ap-northeast-1...
Trusted accounts for deployment: (none)
Trusted accounts for lookup: (none)
Using default execution policy of 'arn:aws:iam::aws:policy/AdministratorAccess'. Pass '--cloudformation-execution-policies' to customize.
CDKToolkit: creating CloudFormation changeset...
 ✅  Environment aws://654654550185/ap-northeast-1 bootstrapped.
  • cdk deploy
  • cdk diff
kenpikenpi
  const sg = ec2.SecurityGroup.fromLookupById(this, 'SG', "sg-0548bf52bb1c7d92a");

すると、

Error: Cannot retrieve value from context provider security-group since account/region are not specified at the stack level. Configure "env" with an account and region when you define your stack.See https://docs.aws.amazon.com/cdk/latest/guide/environments.html for more details.
    at Function.getValue

appでenv渡す