I'm trying to deploy a simple stack to AWS
using CDK
. Unfortunately though when I'm running it through my GitHub actions workflow it seems to be deploying to the wrong region and I can't work out why...
The contents of my bin\cdk.js
look like (sample account):
#!/usr/bin/env node
const cdk = require("@aws-cdk/core");
const { CdkStack } = require("../lib/cdk-stack");
const app = new cdk.App();
new CdkStack(app, "CdkStack", { account: "000000000001", region: "eu-west-1" });
This looks correct to my eyes following the docs. I haven't defined anything anywhere else as far as I'm aware. If I run a cdk bootstrap
the CloudFormation is generated. The only reference to region is:
"environment": "aws://unknown-account/unknown-region",
Am I missing something totally obvious here? The way I've got it configured in my pipeline is simply using:
- name: CDK Deploy
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID}}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY}}
run: |
npm install -g aws-cdk
cdk bootstrap
cdk deploy --require-approval never
You can set the default region as an environment variable in the pipeline configuration:
- name: CDK Deploy
env:
AWS_DEFAULT_REGION: eu-west-1
...
run: |
npm install -g aws-cdk
cdk bootstrap
cdk deploy --require-approval never