aws-cloudformation / aws-cloudformation/custom-resource-helper
How to test Lambdas using crhelper
- Dominant language
- Python
- Stars
- 383
- Forks
- 61
- PR merge metrics
- No merged PRs in 30d
Description
Sorry for this stupid question...
How do I run tests? When using cfnresponse I could simply create a standard Lambda Cloudformation TestEvent and somewhat test my lambda (besides the cfnresponse failing in the end).
When trying the same with a Lambda using crhelper I run into loads of errors as I do not want to specify a CFN Stack to send the response to. I simply want to run my code and not communicate with CFN-Stacks (as there are none so far).
Here is my sample test event which returns this error. Basically it's a createSnapshot for elastiCache, however I don't think this is relevant. The final product would be a CFN Template accessible via ServiceCatalog where customers enter their ReplicationGroupId to create a snapshot.
" socket.gaierror: [Errno -2] Name or service not known[ERROR] Unexpected failure sending response to CloudFormation [Errno -2] Name or service not known "
`{
"RequestType": "Create",
"ResponseURL": "http://pre-signed-S3-url-for-response",
"StackId": "arn:aws:cloudformation:eu-central-1:123456789012:stack/MyStack/guid",
"RequestId": "unique id for this create request",
"ResourceType": "Custom::TestResource",
"LogicalResourceId": "MyTestResource",
"ResourceProperties": {
"StackName": "MyStack",
"ApplicationName": "abcd",
"SnapshotMode": "Create",
"CacheClusterId": "",
"ReplicationGroupId": "abcd-ttwoshards",
"CostReference": "abc",
"KmsKeyId": "abc",
"SnapshotName": "mySnapshotviaLambda"
}
}`
Thanks you for helping a newb out. If this isn't the right place to ask this question please let me know the right place to ask, or link a me docs explaining what I am tryin to achieve.
Contributor guide
Research direction
Review the crhelper documentation and the Lambda test-event behavior described in the issue. Document how to exercise the Lambda logic without a live CloudFormation stack or response callback, and state what successful local testing should look like.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, python
- Domain
- cloud, documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100