Skip to content

Commit 6e6aa1d

Browse files
authored
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.
1 parent e283711 commit 6e6aa1d

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

packages/aws-cdk/integ-tests/app/app.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ class MyStack extends cdk.Stack {
55
constructor(parent, id) {
66
super(parent, id);
77
new sns.Topic(this, 'topic');
8+
9+
console.log(new cdk.AvailabilityZoneProvider(this).availabilityZones);
10+
console.log(new cdk.SSMParameterProvider(this, { parameterName: '/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2' }).parameterValue(''));
811
}
912
}
1013

@@ -21,4 +24,4 @@ const app = new cdk.App();
2124
new MyStack(app, 'cdk-toolkit-integration-test-1');
2225
new YourStack(app, 'cdk-toolkit-integration-test-2');
2326

24-
app.run();
27+
app.run();

packages/aws-cdk/lib/contextplugins.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,16 @@ export class SSMContextProviderPlugin implements ContextProviderPlugin {
3838
public async getValue(args: {[key: string]: any}) {
3939
const region = args.region;
4040
const account = args.account;
41-
if (!('parameterName' in args.props)) {
41+
if (!('parameterName' in args)) {
4242
throw new Error('parameterName must be provided in props for SSMContextProviderPlugin');
4343
}
44-
const parameterName = args.props.parameterName;
44+
const parameterName = args.parameterName;
4545
debug(`Reading SSM parameter ${account}:${region}:${parameterName}`);
4646

4747
const ssm = await this.aws.ssm(account, region, Mode.ForReading);
4848
const response = await ssm.getParameter({ Name: parameterName }).promise();
4949
if (!response.Parameter || response.Parameter.Value === undefined) {
50-
throw new Error(`SSM parameter not availble in account ${account}, region ${region}: ${parameterName}`);
50+
throw new Error(`SSM parameter not available in account ${account}, region ${region}: ${parameterName}`);
5151
}
5252
return response.Parameter.Value;
5353
}

0 commit comments

Comments
 (0)