Help us understand the problem. What is going on with this article?

AWS CDKでステージ別のスタックを作る[context編]

More than 1 year has passed since last update.

AWS CDKでステージ別にスタックを作る を書いてからもっといい方法が見つかったので続報。

$ cdk --version
0.23.0 (build 1d705e7)


cdk synthまたはcdk deployには-c / --contextオプションがつけれます。これを使うことで、ステージやさまざまな値をスタックに流し込めます。

$ npm run build && cdk synth -c stage=development --output output/



const app = new cdk.App();
const stage = app.node.getContext('stage')
new TestStack(app, `TestStack-${stage}`, stage);


class TestStack extends cdk.Stack {
    scope: cdk.App,
    id: string,
    props?: cdk.StackProps
  ) {
    super(scope, id, props);
    const stage = console.log(this.node.getContext('stage'))

    new sqs.Queue(this, `ProjdynamoQueue-${stage}`, {
      visibilityTimeoutSec: 300,
AWS Samurai 2017 Alexa Champions
デジタルキューブは AWS Partner Network (APN) アドバンスドテクノロジーパートナーです。
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away