base2Services / base2Services/cloudformation-custom-resources
Add support for any custom resource to be invoked directly or Via SNS
- Dominant language
- JavaScript
- Stars
- 3
- Forks
- 3
- PR merge metrics
- No merged PRs in 30d
Description
In Order to allow the lambda functions to be invoked directly as a custom resource or via an SNS based custom resource we need custom logic to handle the unwrapping for the event payload depending on the source of the went.
Currently the lookup-ami function supports SNS based invocation
``` json
{
"Records": [
{
"EventSource": "aws:sns",
"EventVersion": "1.0",
"EventSubscriptionArn": "arn:aws:sns:eu-west-1:445283150479:lookup-ami-topic:41215ad8-d033-44ee-b283-16239dd1816c",
"Sns": {
"Type": "Notification",
"MessageId": "be19847c-3a4b-5c48-8802-ca46e65da096",
"TopicArn": "arn:aws:sns:eu-west-1:445283150479:lookup-ami-topic",
"Subject": "AWS CloudFormation custom resource request",
"Message": "{\"RequestType\":\"Create\",\"ServiceToken\":\"arn:aws:sns:eu-west-1:445283150479:lookup-ami-topic\",\"ResponseURL\":\"https://cloudformation-custom-resource-response-euwest1.s3-eu-west-1.amazonaws.com/arn%3Aaws%3Acloudformation%3Aeu-west-1%3A445283150479%3Astack/test-lookup-amu/48be2900-3abd-11e5-a043-50d5026f660a%7CAMIInfo%7Ca35837f0-d27c-49c3-83b5-4379bbf20796?AWSAccessKeyId=AKIAJ7MCS7PVEUOADEEA&Expires=1438709238&Signature=PIviT4tgD2D1VQH6lKgJt2bkd9M%3D\",\"StackId\":\"arn:aws:cloudformation:eu-west-1:445283150479:stack/test-lookup-amu/48be2900-3abd-11e5-a043-50d5026f660a\",\"RequestId\":\"a35837f0-d27c-49c3-83b5-4379bbf20796\",\"LogicalResourceId\":\"AMIInfo\",\"ResourceType\":\"Custom::AMIInfo\",\"ResourceProperties\":{\"ServiceToken\":\"arn:aws:sns:eu-west-1:445283150479:lookup-ami-topic\",\"Region\":\"eu-west-1\",\"AMIName\":\"nat\"}}",
"Timestamp": "2015-08-04T15:27:18.808Z",
"SignatureVersion": "1",
"Signature": "fCG+KCDbA7KuqeuCi5IuPcsdh9VUGuBLWR4GmQQJ8LL+hdi+MGMcrjJKUlDaB8Nga136H47Dfz4UfnVVfVl633reeAWAEZ8jg7O2aqiqcqvx+5o+yPffwhT/+EPxH4LI7OhC63LD5u7lPhY5N8qYRgfajkLjEIV4cIyZ8WE3VWykuGPvrnU3R6Q3WyM156UnZaJaktLHHG6qlwHklJmuRCaaVkMxinaMTnfn9tyIm/9R44RN1wEW/pYmFbZFe612ijZxT0805auIg6ITFF+0WsdrkbWTo/iIymaaWi51HOrrfYG/nCeE6mQ2bxu7WE0Uq1+NvYD1Fb0Pc+/LrKI5qQ==",
"SigningCertUrl": "https://sns.eu-west-1.amazonaws.com/SimpleNotificationService-d6d679a1d18e95c2f9ffcf11f4f9e198.pem",
"UnsubscribeUrl": "https://sns.eu-west-1.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:eu-west-1:445283150479:lookup-ami-topic:41215ad8-d033-44ee-b283-16239dd1816c",
"MessageAttributes": {}
}
}
]
}
```
Basically we unwrap the message but we need logic to handle calling it directly
``` json
{
"RequestType": "Create",
"ServiceToken": "arn:aws:sns:eu-west-1:445283150479:lookup-ami-topic",
"ResponseURL": "https://cloudformation-custom-resource-response-euwest1.s3-eu-west-1.amazonaws.com/arn%3Aaws%3Acloudformation%3Aeu-west-1%3A445283150479%3Astack/test-lookup-ami-5/c788c050-3ac3-11e5-9940-5001411350b4%7CAMIInfo%7C8c3da2da-e1ac-4e15-968a-1151e6f656b0?AWSAccessKeyId=AKIAJ7MCS7PVEUOADEEA&Expires=1438712047&Signature=jZULmFiKE9IqecjHQNsxnfhCaYc%3D",
"StackId": "arn:aws:cloudformation:eu-west-1:445283150479:stack/test-lookup-ami-5/c788c050-3ac3-11e5-9940-5001411350b4",
"RequestId": "8c3da2da-e1ac-4e15-968a-1151e6f656b0",
"LogicalResourceId": "AMIInfo",
"ResourceType": "Custom::AMIInfo",
"ResourceProperties": {
"ServiceToken": "arn:aws:sns:eu-west-1:445283150479:lookup-ami-topic",
"Region": "eu-west-1",
"AMIName": "nat"
}
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.