Comments (8)
@danieljamesscott I agree,
but whole code of crhelper
is 💩, I'm working on and more clean version with hopefully some tests written!
from aws-cloudformation-templates.
I just saw that the finally
block with t.cancel()
was removed by this PR:
67d4f2a#diff-caf0cd039f3147afdf4f64683b74dad7
Should it be restored?
from aws-cloudformation-templates.
That will help!
I've encountered some other issues to do with logging:
https://forum.serverless.com/t/python-lambda-logging-duplication-workaround/1585
Might be nice to include this fix too.
from aws-cloudformation-templates.
This is my version, it's py3.6+ compatible, but easy to modify for older pythons
https://github.com/1oglop1/aws-cloudformation-templates/blob/master/community/custom_resources/python_custom_resource_helper/crhelper.py
lambda_handler.py
from crhelper import cfn_handler
def create(event, content):
"""Create resource."""
physical_resource_id = context.log_stream_name
return physical_resource_id, {"Some": "Data"}
def update(event, context)
"""Update resource."""
physical_resource_id = event['PhysicalResourceId']
return physical_resource_id, {}
def delete(event):
"""Delete resource."""
return event['PhysicalResourceId']
def lambda_handler(event, context):
cfn_handler(event, context, create, update, delete)
In case you want detailed logging for boto and crhelper, I'd suggest to use common approach to logging config
or simply add these 2 lines in your lambda handler
logging_level=logging.DEBUG
logging.getLogger("botocore").setLevel(logging_level)
logging.getLogger("crhelper").setLevel(logging_level)
You can always write your logic to handle env
vars to have it customisable, but that should be your application work, not a library what crhelper
should be.
from aws-cloudformation-templates.
@danieljamesscott
I'd like to have your opinion and other who read this:
I was thinking what would be the best Delete behaviour
I came up with 2 options:
- current state - delete must return
physical_resource_id
- the value is up on the developer to handle - and must be same as produced bycreate
If developer fails to return correctPhysicalResourceId
- stack will hang up
def delete(event, context):
"""Delete resource."""
return event['PhysicalResourceId']
- delete will not return anything and
send_cfn
will useevent['PhysicalResourceId']
behind the scenes - because it can be either value which came fromcreate
or automatic valuecontext.log_stream_name
- here the delete should not hang up as theevent['PhysicalResourceId']
is always same as it came from create
def delete(event, context):
"""Delete resource."""
pass
from aws-cloudformation-templates.
2nd option is probably better? If we can avoid hanging stacks, that would be best.
from aws-cloudformation-templates.
This seems to still be an issue? It's breaking my CustomResource because it will always return a FAILED status, even if it already returned a SUCCESS status resulting in it being stuck in an infinite loop.
from aws-cloudformation-templates.
This implementation has been deprecated in favor of https://github.com/aws-cloudformation/custom-resource-helper which has a richer feature set, is cleaner to implement and can be installed as a pip module.
from aws-cloudformation-templates.
Related Issues (20)
- Easy_Install command not found for RHEL 8 HOT 1
- Macro Transform LanguageExtensions not working HOT 1
- CloudFormation Macros Examples for .../Public-and-Private-Subnet-per-AZ/Create-Macro.yaml uses deprecated Lambda runtime. HOT 1
- SSH to EC2 in private vpc? HOT 3
- Incorrect reference to `/opt/aws/` HOT 2
- T4 instance group not working on ECS template HOT 1
- AWS::ApiGateway::Method Integration Uri incorrect parameter problem. HOT 1
- MacrosExamples - ExecutionRoleBuilder update and typo HOT 2
- cfn-hup in daemon mode doesn't work on any currently supported Python version, because of dependency on obsolete python-daemon version HOT 11
- AmazonCloudWatchAgent templates are outdated HOT 2
- AWS::Cognito::UserPool LambdaVersion does not get set correctly HOT 4
- Awslabs
- Use latest aws-cfn-bootstrap
- Move macros?
- Standardize template formats
- Make sure everything in aws directory passes cfn-lint and cfn-guard checks
- Make sure everything in the community directory passes cfn-lint
- Add custom resource examples HOT 1
- Re-organize directories
- Add PR validation
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aws-cloudformation-templates.