Skip to content

Commit

Permalink
feat(ssm): add ability to specify SSM Parameter tier (#6326)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertd authored Feb 19, 2020
1 parent cd6cd42 commit 9209ef6
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/@aws-cdk/aws-ssm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ a CDK app. These are public (not secret) values. Parameters of type
to provision secrets automatically, use Secrets Manager Secrets (see the
`@aws-cdk/aws-secretsmanager` package).

```ts
new ssm.StringParameter(stack, 'Parameter', {
allowedPattern: '.*',
description: 'The value Foo',
parameterName: 'FooParameter',
stringValue: 'Foo',
tier: ssm.ParameterTier.ADVANCED,
});
```

[creating SSM parameters](test/integ.parameter.lit.ts)

When specifying an `allowedPattern`, the values provided as string literals
Expand Down
28 changes: 28 additions & 0 deletions packages/@aws-cdk/aws-ssm/lib/parameter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ export interface ParameterOptions {
* @default - auto-detect based on `parameterName`
*/
readonly simpleName?: boolean;

/**
* The tier of the string parameter
*
* @default - undefined
*/
readonly tier?: ParameterTier;
}

/**
Expand Down Expand Up @@ -206,6 +213,24 @@ export enum ParameterType {
AWS_EC2_IMAGE_ID = 'AWS::EC2::Image::Id',
}

/**
* SSM parameter tier
*/
export enum ParameterTier {
/**
* String
*/
ADVANCED = 'Advanced',
/**
* String
*/
INTELLIGENT_TIERING = 'Intelligent-Tiering',
/**
* String
*/
STANDARD = 'Standard',
}

/**
* Common attributes for string parameters.
*/
Expand Down Expand Up @@ -271,6 +296,7 @@ export interface SecureStringParameterAttributes extends CommonStringParameterAt
* @default - default master key
*/
readonly encryptionKey?: kms.IKey;

}

/**
Expand Down Expand Up @@ -404,6 +430,7 @@ export class StringParameter extends ParameterBase implements IStringParameter {
allowedPattern: props.allowedPattern,
description: props.description,
name: this.physicalName,
tier: props.tier,
type: props.type || ParameterType.STRING,
value: props.stringValue,
});
Expand Down Expand Up @@ -462,6 +489,7 @@ export class StringListParameter extends ParameterBase implements IStringListPar
allowedPattern: props.allowedPattern,
description: props.description,
name: this.physicalName,
tier: props.tier,
type: ParameterType.STRING_LIST,
value: props.stringListValue.join(','),
});
Expand Down
20 changes: 20 additions & 0 deletions packages/@aws-cdk/aws-ssm/test/test.parameter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,26 @@ export = {
test.done();
},

'expect String SSM Parameter to have tier properly set'(test: Test) {
// GIVEN
const stack = new cdk.Stack();

// WHEN
new ssm.StringParameter(stack, 'Parameter', {
allowedPattern: '.*',
description: 'The value Foo',
parameterName: 'FooParameter',
stringValue: 'Foo',
tier: ssm.ParameterTier.ADVANCED,
});

// THEN
expect(stack).to(haveResource('AWS::SSM::Parameter', {
Tier: 'Advanced',
}));
test.done();
},

'String SSM Parameter rejects invalid values'(test: Test) {
// GIVEN
const stack = new cdk.Stack();
Expand Down

0 comments on commit 9209ef6

Please sign in to comment.