From 6e6aa1df244642f2ade9fd2e3fa55fdeb7afbdcf Mon Sep 17 00:00:00 2001 From: Rico Huijbers Date: Fri, 26 Oct 2018 18:52:05 +0200 Subject: [PATCH] fix(aws-cdk): fix bug in SSM Parameter Provider (#1023) SSM Parameter Provider Plugin was not properly updated for the new context provider protocol. It is now, and an integ test is added. --- packages/aws-cdk/integ-tests/app/app.js | 5 ++++- packages/aws-cdk/lib/contextplugins.ts | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/aws-cdk/integ-tests/app/app.js b/packages/aws-cdk/integ-tests/app/app.js index 5ec721079c981..19264e52f4eec 100644 --- a/packages/aws-cdk/integ-tests/app/app.js +++ b/packages/aws-cdk/integ-tests/app/app.js @@ -5,6 +5,9 @@ class MyStack extends cdk.Stack { constructor(parent, id) { super(parent, id); new sns.Topic(this, 'topic'); + + console.log(new cdk.AvailabilityZoneProvider(this).availabilityZones); + console.log(new cdk.SSMParameterProvider(this, { parameterName: '/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2' }).parameterValue('')); } } @@ -21,4 +24,4 @@ const app = new cdk.App(); new MyStack(app, 'cdk-toolkit-integration-test-1'); new YourStack(app, 'cdk-toolkit-integration-test-2'); -app.run(); \ No newline at end of file +app.run(); diff --git a/packages/aws-cdk/lib/contextplugins.ts b/packages/aws-cdk/lib/contextplugins.ts index 6817b30ff1e9b..8af2987a3d214 100644 --- a/packages/aws-cdk/lib/contextplugins.ts +++ b/packages/aws-cdk/lib/contextplugins.ts @@ -38,16 +38,16 @@ export class SSMContextProviderPlugin implements ContextProviderPlugin { public async getValue(args: {[key: string]: any}) { const region = args.region; const account = args.account; - if (!('parameterName' in args.props)) { + if (!('parameterName' in args)) { throw new Error('parameterName must be provided in props for SSMContextProviderPlugin'); } - const parameterName = args.props.parameterName; + const parameterName = args.parameterName; debug(`Reading SSM parameter ${account}:${region}:${parameterName}`); const ssm = await this.aws.ssm(account, region, Mode.ForReading); const response = await ssm.getParameter({ Name: parameterName }).promise(); if (!response.Parameter || response.Parameter.Value === undefined) { - throw new Error(`SSM parameter not availble in account ${account}, region ${region}: ${parameterName}`); + throw new Error(`SSM parameter not available in account ${account}, region ${region}: ${parameterName}`); } return response.Parameter.Value; }