Skip to content

Instantly share code, notes, and snippets.

@badfun
Last active May 27, 2022 21:52

Revisions

  1. badfun renamed this gist Nov 26, 2021. 1 changed file with 0 additions and 0 deletions.
  2. badfun created this gist Nov 26, 2021.
    21 changes: 21 additions & 0 deletions aws-custom-resource-example
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    import { AwsCustomResource, AwsCustomResourcePolicy, PhysicalResourceId } from '@aws-cdk/custom-resources'

    /**
    * Secure string from Parameter store
    */
    const getParameter = new AwsCustomResource(this, 'SsmSecureStringParameter', {
    onUpdate: {
    service: 'SSM',
    action: 'getParameter',
    parameters: {
    Name: this.node.tryGetContext('secureStringParameter'),
    WithDecryption: true,
    },
    physicalResourceId: PhysicalResourceId.of(Date.now().toString()),
    },
    policy: AwsCustomResourcePolicy.fromSdkCalls({
    resources: AwsCustomResourcePolicy.ANY_RESOURCE,
    }),
    })

    const secureString = getParameter.getResponseField('Parameter.Value')