Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
The sequence of events triggered for a CloudFormation custom resource backed by an AWS Lambda function

Create a stack

{
    "event": {
        "StackId": "arn:aws:cloudformation:us-west-2:656532927350:stack/genetest2/c6c0c040-c5ee-11e9-9ec7-0ad236afdc80",
        "ResponseURL": "https://cloudformation-custom-resource-response-uswest2.s3-us-west-2.amazonaws.com/arn%3Aaws%3Acloudformation%3Aus-west-2%3A656532927350%3Astack/genetest2/c6c0c040-c5ee-11e9-9ec7-0ad236afdc80%7CExample%7Cef8641a2-cac0-4eaf-aed6-df08cd9aae26?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20190823T214203Z&X-Amz-SignedHeaders=host&X-Amz-Expires=7199&X-Amz-Credential=AKIA54RCMT6SG7Y5BKPL%2F20190823%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Signature=a5f9d0ac53360f385b20e9f71a36746d691b2d161bf45ab867a76a858de3e1e0",
        "ResourceProperties": {
            "ServiceToken": "arn:aws:lambda:us-west-2:656532927350:function:genetest2-ExampleFunction-NQLOVV15EHNT",
            "Param": "alpha"
        },
        "RequestType": "Create",
        "ServiceToken": "arn:aws:lambda:us-west-2:656532927350:function:genetest2-ExampleFunction-NQLOVV15EHNT",
        "ResourceType": "Custom::Example",
        "RequestId": "ef8641a2-cac0-4eaf-aed6-df08cd9aae26",
        "LogicalResourceId": "Example"
    }
}

Update a parameter not not the code

{
    "event": {
        "StackId": "arn:aws:cloudformation:us-west-2:656532927350:stack/genetest2/c6c0c040-c5ee-11e9-9ec7-0ad236afdc80",
        "ResponseURL": "https://cloudformation-custom-resource-response-uswest2.s3-us-west-2.amazonaws.com/arn%3Aaws%3Acloudformation%3Aus-west-2%3A656532927350%3Astack/genetest2/c6c0c040-c5ee-11e9-9ec7-0ad236afdc80%7CExample%7C472d3e01-0a72-493b-a5f9-e6f149bcd073?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20190823T214424Z&X-Amz-SignedHeaders=host&X-Amz-Expires=7200&X-Amz-Credential=AKIA54RCMT6SG7Y5BKPL%2F20190823%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Signature=1f1d6de31ceca85bbb9ae7f9511a9868296138b5ca626bac0a904a0c906a6351",
        "ResourceProperties": {
            "ServiceToken": "arn:aws:lambda:us-west-2:656532927350:function:genetest2-ExampleFunction-NQLOVV15EHNT",
            "Param": "beta"
        },
        "RequestType": "Update",
        "OldResourceProperties": {
            "ServiceToken": "arn:aws:lambda:us-west-2:656532927350:function:genetest2-ExampleFunction-NQLOVV15EHNT",
            "Param": "alpha"
        },
        "ServiceToken": "arn:aws:lambda:us-west-2:656532927350:function:genetest2-ExampleFunction-NQLOVV15EHNT",
        "ResourceType": "Custom::Example",
        "PhysicalResourceId": "2019/08/23/[$LATEST]b5b45ebc348e48e6affaf71581e341a0",
        "RequestId": "472d3e01-0a72-493b-a5f9-e6f149bcd073",
        "LogicalResourceId": "Example"
    }
}

Update param 2 to trigger a failure

{
    "event": {
        "StackId": "arn:aws:cloudformation:us-west-2:656532927350:stack/genetest2/c6c0c040-c5ee-11e9-9ec7-0ad236afdc80",
        "ResponseURL": "https://cloudformation-custom-resource-response-uswest2.s3-us-west-2.amazonaws.com/arn%3Aaws%3Acloudformation%3Aus-west-2%3A656532927350%3Astack/genetest2/c6c0c040-c5ee-11e9-9ec7-0ad236afdc80%7CExample%7C93875b8b-dfcf-47f4-a416-b2d330d81c10?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20190823T214542Z&X-Amz-SignedHeaders=host&X-Amz-Expires=7200&X-Amz-Credential=AKIA54RCMT6SG7Y5BKPL%2F20190823%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Signature=ee686074c4f6df4affb7e5a1154fe17c7b616a9dc1463d4c08993dd2fbf206fe",
        "ResourceProperties": {
            "ServiceToken": "arn:aws:lambda:us-west-2:656532927350:function:genetest2-ExampleFunction-NQLOVV15EHNT",
            "Param": "charlie"
        },
        "RequestType": "Update",
        "OldResourceProperties": {
            "ServiceToken": "arn:aws:lambda:us-west-2:656532927350:function:genetest2-ExampleFunction-NQLOVV15EHNT",
            "Param": "beta"
        },
        "ServiceToken": "arn:aws:lambda:us-west-2:656532927350:function:genetest2-ExampleFunction-NQLOVV15EHNT",
        "ResourceType": "Custom::Example",
        "PhysicalResourceId": "2019/08/23/[$LATEST]b5b45ebc348e48e6affaf71581e341a0",
        "RequestId": "93875b8b-dfcf-47f4-a416-b2d330d81c10",
        "LogicalResourceId": "Example"
    }
}
{
    "event": {
        "StackId": "arn:aws:cloudformation:us-west-2:656532927350:stack/genetest2/c6c0c040-c5ee-11e9-9ec7-0ad236afdc80",
        "ResponseURL": "https://cloudformation-custom-resource-response-uswest2.s3-us-west-2.amazonaws.com/arn%3Aaws%3Acloudformation%3Aus-west-2%3A656532927350%3Astack/genetest2/c6c0c040-c5ee-11e9-9ec7-0ad236afdc80%7CExample%7C2acf779a-b3f7-47e5-a31a-46cdbc1a38cf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20190823T214552Z&X-Amz-SignedHeaders=host&X-Amz-Expires=7200&X-Amz-Credential=AKIA54RCMT6SG7Y5BKPL%2F20190823%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Signature=5824c9c64f8b2546433fed3c1585aa012c3e82b8e96be2fb435197e6b40c2979",
        "ResourceProperties": {
            "ServiceToken": "arn:aws:lambda:us-west-2:656532927350:function:genetest2-ExampleFunction-NQLOVV15EHNT",
            "Param": "beta"
        },
        "RequestType": "Update",
        "OldResourceProperties": {
            "ServiceToken": "arn:aws:lambda:us-west-2:656532927350:function:genetest2-ExampleFunction-NQLOVV15EHNT",
            "Param": "charlie"
        },
        "ServiceToken": "arn:aws:lambda:us-west-2:656532927350:function:genetest2-ExampleFunction-NQLOVV15EHNT",
        "ResourceType": "Custom::Example",
        "PhysicalResourceId": "2019/08/23/[$LATEST]b5b45ebc348e48e6affaf71581e341a0",
        "RequestId": "2acf779a-b3f7-47e5-a31a-46cdbc1a38cf",
        "LogicalResourceId": "Example"
    }
}

Update param 3 after rollback to a success

{
    "event": {
        "StackId": "arn:aws:cloudformation:us-west-2:656532927350:stack/genetest2/c6c0c040-c5ee-11e9-9ec7-0ad236afdc80",
        "ResponseURL": "https://cloudformation-custom-resource-response-uswest2.s3-us-west-2.amazonaws.com/arn%3Aaws%3Acloudformation%3Aus-west-2%3A656532927350%3Astack/genetest2/c6c0c040-c5ee-11e9-9ec7-0ad236afdc80%7CExample%7C7b4f9e8c-e832-485b-a58a-eebb649693cc?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20190823T214658Z&X-Amz-SignedHeaders=host&X-Amz-Expires=7200&X-Amz-Credential=AKIA54RCMT6SG7Y5BKPL%2F20190823%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Signature=5446b30c763ddd6be5f933ad486b7de2ea6d6447f62e8112cdab866a46f73e7a",
        "ResourceProperties": {
            "ServiceToken": "arn:aws:lambda:us-west-2:656532927350:function:genetest2-ExampleFunction-NQLOVV15EHNT",
            "Param": "delta"
        },
        "RequestType": "Update",
        "OldResourceProperties": {
            "ServiceToken": "arn:aws:lambda:us-west-2:656532927350:function:genetest2-ExampleFunction-NQLOVV15EHNT",
            "Param": "beta"
        },
        "ServiceToken": "arn:aws:lambda:us-west-2:656532927350:function:genetest2-ExampleFunction-NQLOVV15EHNT",
        "ResourceType": "Custom::Example",
        "PhysicalResourceId": "2019/08/23/[$LATEST]b5b45ebc348e48e6affaf71581e341a0",
        "RequestId": "7b4f9e8c-e832-485b-a58a-eebb649693cc",
        "LogicalResourceId": "Example"
    }
}

Update code but not param

no change triggered since param didn't change

update param after previously changing code

{
    "event": {
        "StackId": "arn:aws:cloudformation:us-west-2:656532927350:stack/genetest2/c6c0c040-c5ee-11e9-9ec7-0ad236afdc80",
        "ResponseURL": "https://cloudformation-custom-resource-response-uswest2.s3-us-west-2.amazonaws.com/arn%3Aaws%3Acloudformation%3Aus-west-2%3A656532927350%3Astack/genetest2/c6c0c040-c5ee-11e9-9ec7-0ad236afdc80%7CExample%7C8245a92c-6ec6-447e-98bf-55c1b8616d80?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20190823T215202Z&X-Amz-SignedHeaders=host&X-Amz-Expires=7200&X-Amz-Credential=AKIA54RCMT6SG7Y5BKPL%2F20190823%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Signature=32892dfec4f3fd0298293ea75dbf113fdbb0622eec62058cee9cce774a64d80e",
        "ResourceProperties": {
            "ServiceToken": "arn:aws:lambda:us-west-2:656532927350:function:genetest2-ExampleFunction-NQLOVV15EHNT",
            "Param": "echo"
        },
        "RequestType": "Update",
        "OldResourceProperties": {
            "ServiceToken": "arn:aws:lambda:us-west-2:656532927350:function:genetest2-ExampleFunction-NQLOVV15EHNT",
            "Param": "delta"
        },
        "ServiceToken": "arn:aws:lambda:us-west-2:656532927350:function:genetest2-ExampleFunction-NQLOVV15EHNT",
        "ResourceType": "Custom::Example",
        "PhysicalResourceId": "2019/08/23/[$LATEST]b5b45ebc348e48e6affaf71581e341a0",
        "RequestId": "8245a92c-6ec6-447e-98bf-55c1b8616d80",
        "LogicalResourceId": "Example"
    }
}
{
    "event": {
        "StackId": "arn:aws:cloudformation:us-west-2:656532927350:stack/genetest2/c6c0c040-c5ee-11e9-9ec7-0ad236afdc80",
        "ResponseURL": "https://cloudformation-custom-resource-response-uswest2.s3-us-west-2.amazonaws.com/arn%3Aaws%3Acloudformation%3Aus-west-2%3A656532927350%3Astack/genetest2/c6c0c040-c5ee-11e9-9ec7-0ad236afdc80%7CExample%7C08af1594-82db-49d9-b3fc-76a5214c9a98?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20190823T215208Z&X-Amz-SignedHeaders=host&X-Amz-Expires=7200&X-Amz-Credential=AKIA54RCMT6SG7Y5BKPL%2F20190823%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Signature=96a007bf83d9096a253f8a3e2665b916943ca4bb3bb76556f46858ff98b69369",
        "ResourceProperties": {
            "ServiceToken": "arn:aws:lambda:us-west-2:656532927350:function:genetest2-ExampleFunction-NQLOVV15EHNT",
            "Param": "delta"
        },
        "RequestType": "Delete",
        "ServiceToken": "arn:aws:lambda:us-west-2:656532927350:function:genetest2-ExampleFunction-NQLOVV15EHNT",
        "ResourceType": "Custom::Example",
        "PhysicalResourceId": "2019/08/23/[$LATEST]b5b45ebc348e48e6affaf71581e341a0",
        "RequestId": "08af1594-82db-49d9-b3fc-76a5214c9a98",
        "LogicalResourceId": "Example"
    }
}

update param a second time but no code change this time

{
    "event": {
        "StackId": "arn:aws:cloudformation:us-west-2:656532927350:stack/genetest2/c6c0c040-c5ee-11e9-9ec7-0ad236afdc80",
        "ResponseURL": "https://cloudformation-custom-resource-response-uswest2.s3-us-west-2.amazonaws.com/arn%3Aaws%3Acloudformation%3Aus-west-2%3A656532927350%3Astack/genetest2/c6c0c040-c5ee-11e9-9ec7-0ad236afdc80%7CExample%7C45653917-badc-4d26-8147-c8071393f7ef?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20190823T215310Z&X-Amz-SignedHeaders=host&X-Amz-Expires=7200&X-Amz-Credential=AKIA54RCMT6SG7Y5BKPL%2F20190823%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Signature=56ea2ce12e644b66a6296657632278a61c83513088c8fb9c0fd850a9579da533",
        "ResourceProperties": {
            "ServiceToken": "arn:aws:lambda:us-west-2:656532927350:function:genetest2-ExampleFunction-NQLOVV15EHNT",
            "Param": "foxtrot"
        },
        "RequestType": "Update",
        "OldResourceProperties": {
            "ServiceToken": "arn:aws:lambda:us-west-2:656532927350:function:genetest2-ExampleFunction-NQLOVV15EHNT",
            "Param": "echo"
        },
        "ServiceToken": "arn:aws:lambda:us-west-2:656532927350:function:genetest2-ExampleFunction-NQLOVV15EHNT",
        "ResourceType": "Custom::Example",
        "PhysicalResourceId": "2019/08/23/[$LATEST]ff78c763f75f4e83b21540fdfed735bd",
        "RequestId": "45653917-badc-4d26-8147-c8071393f7ef",
        "LogicalResourceId": "Example"
    }
}

delete stack

{
    "event": {
        "StackId": "arn:aws:cloudformation:us-west-2:656532927350:stack/genetest2/ff917420-c5f6-11e9-80d3-0a7f77c1d258",
        "ResponseURL": "https://cloudformation-custom-resource-response-uswest2.s3-us-west-2.amazonaws.com/arn%3Aaws%3Acloudformation%3Aus-west-2%3A656532927350%3Astack/genetest2/ff917420-c5f6-11e9-80d3-0a7f77c1d258%7CExample%7C558bd5db-747d-43b7-8c46-9f32f97eb033?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20190823T224148Z&X-Amz-SignedHeaders=host&X-Amz-Expires=7200&X-Amz-Credential=AKIA54RCMT6SG7Y5BKPL%2F20190823%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Signature=acbbd74b545a3eb7f949d32ae84933f6199090d3f9ce5d8b93019f68567bdba9",
        "ResourceProperties": {
            "ServiceToken": "arn:aws:lambda:us-west-2:656532927350:function:genetest2-ExampleFunction-B1OGHXJLRWL8",
            "Param": "echo"
        },
        "RequestType": "Delete",
        "ServiceToken": "arn:aws:lambda:us-west-2:656532927350:function:genetest2-ExampleFunction-B1OGHXJLRWL8",
        "ResourceType": "Custom::Example",
        "PhysicalResourceId": "2019/08/23/[$LATEST]5e1471ba34f74e9f95dad512d42a697f",
        "RequestId": "558bd5db-747d-43b7-8c46-9f32f97eb033",
        "LogicalResourceId": "Example"
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.