CDK Constructs for AWS CloudFormation
Project description
AWS CloudFormation Construct Library
This is a developer preview (public beta) module. Releases might lack important features and might have future breaking changes.
This module is part of the AWS Cloud Development Kit project.
Custom Resources
Custom Resources are CloudFormation resources that are implemented by arbitrary user code. They can do arbitrary lookups or modifications during a CloudFormation synthesis run.
You will typically use Lambda to implement a Construct implemented as a
Custom Resource (though SNS topics can be used as well). Your Lambda function
will be sent a CREATE, UPDATE or DELETE message, depending on the
CloudFormation life cycle, and can return any number of output values which
will be available as attributes of your Construct. In turn, those can
be used as input to other Constructs in your model.
In general, consumers of your Construct will not need to care whether it is implemented in term of other CloudFormation resources or as a custom resource.
Note: when implementing your Custom Resource using a Lambda, use
a SingletonLambda so that even if your custom resource is instantiated
multiple times, the Lambda will only get uploaded once.
Example
Sample of a Custom Resource that copies files into an S3 bucket during deployment
(implementation of actual copy.py operation elided).
interface CopyOperationProps {
sourceBucket: IBucket;
targetBucket: IBucket;
}
class CopyOperation extends Construct {
constructor(parent: Construct, name: string, props: DemoResourceProps) {
super(parent, name);
const lambdaProvider = new SingletonLambda(this, 'Provider', {
uuid: 'f7d4f730-4ee1-11e8-9c2d-fa7ae01bbebc',
code: new LambdaInlineCode(resources['copy.py']),
handler: 'index.handler',
timeout: 60,
runtime: LambdaRuntime.Python3,
});
new CustomResource(this, 'Resource', {
provider: CustomResourceProvider.lambda(provider),
properties: {
sourceBucketArn: props.sourceBucket.bucketArn,
targetBucketArn: props.targetBucket.bucketArn,
}
});
}
}
More examples are in the example directory, including an example of how to use
the cfnresponse module that is provided for you by CloudFormation.
References
See the following section of the docs on details to write Custom Resources:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aws-cdk.aws-cloudformation-0.36.2.tar.gz.
File metadata
- Download URL: aws-cdk.aws-cloudformation-0.36.2.tar.gz
- Upload date:
- Size: 48.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
916ba87ddc07b418bd7de95f098e7873e387e821e07dc4d20a8d37f12ead6e02
|
|
| MD5 |
c8f683687f7503367c50d93db709f647
|
|
| BLAKE2b-256 |
b5e5e0af980598f8c0512a51ba3ca0e2e8210677e65dba86376049c0c075434d
|
File details
Details for the file aws_cdk.aws_cloudformation-0.36.2-py3-none-any.whl.
File metadata
- Download URL: aws_cdk.aws_cloudformation-0.36.2-py3-none-any.whl
- Upload date:
- Size: 47.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c5bf4e692c268fb737f1de9f24429f7c9cbe23ceddb64b0a27d2695aa296100d
|
|
| MD5 |
1512aaf9effac3c8a0133f92d870f8cd
|
|
| BLAKE2b-256 |
8c5ea9c7eed467a37005fc0df349a4eabae3afb3916a840f005f628761069fd8
|