Skip to content

Commit

Permalink
Merge pull request #17 from fogfish/master
Browse files Browse the repository at this point in the history
Fix KMS alias name for newly created keys
  • Loading branch information
fogfish committed May 18, 2020
2 parents 7767005 + 9531c09 commit c91950f
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/kms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ export class SymmetricKey extends kms.Key {

constructor(scope: cdk.Construct, id: string, props: kms.KeyProps = {}) {
const { alias, ...other } = props
const keyAlias = alias || id
const keyAlias = alias || `alias/${id}`
super(scope, id, symmetricKeyProps({ alias: keyAlias, ...other }))

this.alias = new JustAlias(scope, `alias/${keyAlias}`, keyAlias)
this.alias = new JustAlias(scope, keyAlias, keyAlias)
cdk.Tag.add(this, 'stack', cdk.Aws.STACK_NAME)
}

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ssh.com/c3",
"version": "0.5.1",
"version": "0.5.2",
"description": "Compliant Cloud Components",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion test/kms.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ it('symmetric kms.Key compliant with CIS 2.8',
UpdateReplacePolicy: 'Retain',
}

expect(key.alias.aliasName).toBe('MyKey')
expect(key.alias.aliasName).toBe('alias/MyKey')
expect(key.alias.aliasTargetKey).toBeUndefined()
assert.expect(stack).to(assert.countResources('AWS::KMS::Key', 1))
assert.expect(stack).to(assert.haveResource('AWS::KMS::Key', expectKey, assert.ResourcePart.CompleteDefinition))
Expand Down

0 comments on commit c91950f

Please sign in to comment.