diff --git a/.env.example b/.env.example index 5199548..2067263 100644 --- a/.env.example +++ b/.env.example @@ -2,7 +2,7 @@ # Copy this file to .env and adjust values for local development # AWS CDK Stage (stg or prod) -# STAGE=stg +STAGE=prod # Mesh Secret Key (for domain validation) MESH_SECRET_KEY=your-secret-key-here diff --git a/bin/mesh-v2.ts b/bin/mesh-v2.ts index 9776fe7..a7f94f2 100644 --- a/bin/mesh-v2.ts +++ b/bin/mesh-v2.ts @@ -9,8 +9,8 @@ dotenv.config({ path: path.join(__dirname, '../.env'), override: true }); const app = new cdk.App(); -// Stage取得(デフォルト: stg) -const stage = app.node.tryGetContext('stage') || 'stg'; +// Stage取得(優先順位: --context stage=..., .envのSTAGE, デフォルト: stg) +const stage = app.node.tryGetContext('stage') || process.env.STAGE || 'stg'; const stackName = stage === 'prod' ? 'MeshV2Stack' : `MeshV2Stack-${stage}`; new MeshV2Stack(app, stackName, { diff --git a/cdk.json b/cdk.json index 4d48f03..641dd5c 100644 --- a/cdk.json +++ b/cdk.json @@ -17,7 +17,6 @@ ] }, "context": { - "stage": "stg", "@aws-cdk/aws-signer:signingProfileNamePassedToCfn": true, "@aws-cdk/aws-ecs-patterns:secGroupsDisablesImplicitOpenListener": true, "@aws-cdk/aws-lambda:recognizeLayerVersion": true, diff --git a/lib/mesh-v2-stack.ts b/lib/mesh-v2-stack.ts index b906a51..3fa5c48 100644 --- a/lib/mesh-v2-stack.ts +++ b/lib/mesh-v2-stack.ts @@ -12,8 +12,8 @@ export class MeshV2Stack extends cdk.Stack { constructor(scope: Construct, id: string, props?: cdk.StackProps) { super(scope, id, props); - // Stage取得(デフォルト: stg) - const stage = this.node.tryGetContext('stage') || 'stg'; + // Stage取得(優先順位: --context stage=..., .envのSTAGE, デフォルト: stg) + const stage = this.node.tryGetContext('stage') || process.env.STAGE || 'stg'; const stageSuffix = stage === 'prod' ? '' : `-${stage}`; // Stack全体にタグ付与