用于构建cloudformation自定义资源的包装器装饰器
cfn_resource的Python项目详细描述
##py
这个项目是一个装饰和验证系统,它消除了编写自定义资源的繁琐工作。您仍然可以正常访问上下文和事件,但是decorator处理序列化您的响应并将
结果传递给cloudformation。
将“cfn_resource.py”复制到lambda函数处理程序的目录中。使用“cfn_resource.resource”事件装饰器装饰处理程序
,就像在“example.py”中一样
1。压缩内容并上传到lambda
函数启动后,复制其arn并将其用作
[自定义资源][rsrc]的servicetoken。有关您可能收到的请求的详细信息,请参阅
[本文档][请求文档]
``json
{
“awstemplateformatversion”:“2010-09-09”,
“resources”:{
“faketing”:{
“type”:“custom::myresource”,
“properties”:{
“servicetoken”:“arn:aws:lambda:some-region:account:function:functionname”,
“otherthing”:“foobar”,
“otherthing”:2
}
}
}
}
}
````
参见[AWS文档][docs]
您需要将lambda中的处理程序设置为
`filename.handler`其中filename包含以下内容。
```
import cfn_resource
做些事情
return{“physicalresourceiid”:“arn:aws:fake:myid:fake:myid”}
@handler.update
>deupdate-thing(event,context):
;做些事情
return{“physicalresourceiid”:“arn:aws:fake:myid:fake:myid”}
``
``
``
` `
;做些事情
;做些事情
;做些事情
;做些事情
;做些事情
;做些事情
````“pip”。理想情况下,您应该使用virtualenv.
```
$pip install-r test requirements.txt
$py.test
```
不包括任何形式的保证,并且版权声明必须包含在再分配中。
[rsrc]:https://docs.aws.amazon.com/awscloudformation/latest/userguide/aws resource cfn customresource.html
[docs]:https://docs.aws.amazon.com/awscloudformation/latest/userguide/template custom resources.html
[reqdocs]:https://docs.aws.amazon.com/awscloudformation/latest/userguide/crpg ref requests.html
这个项目是一个装饰和验证系统,它消除了编写自定义资源的繁琐工作。您仍然可以正常访问上下文和事件,但是decorator处理序列化您的响应并将
结果传递给cloudformation。
将“cfn_resource.py”复制到lambda函数处理程序的目录中。使用“cfn_resource.resource”事件装饰器装饰处理程序
,就像在“example.py”中一样
1。压缩内容并上传到lambda
函数启动后,复制其arn并将其用作
[自定义资源][rsrc]的servicetoken。有关您可能收到的请求的详细信息,请参阅
[本文档][请求文档]
``json
{
“awstemplateformatversion”:“2010-09-09”,
“resources”:{
“faketing”:{
“type”:“custom::myresource”,
“properties”:{
“servicetoken”:“arn:aws:lambda:some-region:account:function:functionname”,
“otherthing”:“foobar”,
“otherthing”:2
}
}
}
}
}
````
参见[AWS文档][docs]
您需要将lambda中的处理程序设置为
`filename.handler`其中filename包含以下内容。
```
import cfn_resource
做些事情
return{“physicalresourceiid”:“arn:aws:fake:myid:fake:myid”}
@handler.update
>deupdate-thing(event,context):
;做些事情
return{“physicalresourceiid”:“arn:aws:fake:myid:fake:myid”}
``
``
``
` `
;做些事情
;做些事情
;做些事情
;做些事情
;做些事情
;做些事情
````“pip”。理想情况下,您应该使用virtualenv.
```
$pip install-r test requirements.txt
$py.test
```
不包括任何形式的保证,并且版权声明必须包含在再分配中。
[rsrc]:https://docs.aws.amazon.com/awscloudformation/latest/userguide/aws resource cfn customresource.html
[docs]:https://docs.aws.amazon.com/awscloudformation/latest/userguide/template custom resources.html
[reqdocs]:https://docs.aws.amazon.com/awscloudformation/latest/userguide/crpg ref requests.html