@aws-cdk/core
Advanced tools
Comparing version 1.36.1 to 1.37.0
@@ -39,2 +39,8 @@ export * from './aspect'; | ||
export * from './tree'; | ||
export * from './asset-staging'; | ||
export * from './fs'; | ||
export * from './custom-resource'; | ||
export * from './nested-stack'; | ||
export * from './cfn-capabilities'; | ||
export * from './cloudformation.generated'; | ||
export * from './private/intrinsic'; |
@@ -41,5 +41,11 @@ "use strict"; | ||
__export(require("./tree")); | ||
__export(require("./asset-staging")); | ||
__export(require("./fs")); | ||
__export(require("./custom-resource")); | ||
__export(require("./nested-stack")); | ||
__export(require("./cfn-capabilities")); | ||
__export(require("./cloudformation.generated")); | ||
// WARNING: Should not be exported, but currently is because of a bug. See the | ||
// class description for more information. | ||
__export(require("./private/intrinsic")); | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJpbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUNBLGtDQUE2QjtBQUU3Qix3Q0FBbUM7QUFDbkMsNkJBQXdCO0FBQ3hCLGtDQUE2QjtBQUM3Qiw0QkFBdUI7QUFDdkIsbUNBQThCO0FBQzlCLGtDQUE2QjtBQUM3Qix3Q0FBbUM7QUFFbkMsaUNBQTRCO0FBQzVCLHFDQUFnQztBQUNoQyw4QkFBeUI7QUFDekIsbUNBQThCO0FBQzlCLG1DQUE4QjtBQUM5QixrQ0FBNkI7QUFDN0IscUNBQWdDO0FBQ2hDLGtDQUE2QjtBQUM3QixvQ0FBK0I7QUFDL0IsMkNBQXNDO0FBQ3RDLGdDQUEyQjtBQUMzQiw2QkFBd0I7QUFDeEIsbUNBQThCO0FBQzlCLDZDQUF3QztBQUV4QyxzQ0FBaUM7QUFDakMsMkJBQXNCO0FBQ3RCLGdDQUEyQjtBQUMzQiw0QkFBdUI7QUFDdkIsbUNBQThCO0FBRTlCLDJCQUFzQjtBQUN0Qix3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ubWVudCc7XG5cbmV4cG9ydCAqIGZyb20gJy4vcnVudGltZSc7XG5leHBvcnQgKiBmcm9tICcuL3NlY3JldC12YWx1ZSc7XG5cbmV4cG9ydCAqIGZyb20gJy4vcmVzb3VyY2UnO1xuZXhwb3J0ICogZnJvbSAnLi9waHlzaWNhbC1uYW1lJztcbmV4cG9ydCAqIGZyb20gJy4vYXNzZXRzJztcblxuZXhwb3J0ICogZnJvbSAnLi90cmVlJztcblxuZXhwb3J0ICogZnJvbSAnLi9hc3NldC1zdGFnaW5nJztcbmV4cG9ydCAqIGZyb20gJy4vZnMnO1xuXG5leHBvcnQgKiBmcm9tICcuL2N1c3RvbS1yZXNvdXJjZSc7XG5leHBvcnQgKiBmcm9tICcuL25lc3RlZC1zdGFjayc7XG5cbmV4cG9ydCAqIGZyb20gJy4vY2ZuLWNhcGFiaWxpdGllcyc7XG5leHBvcnQgKiBmcm9tICcuL2Nsb3VkZm9ybWF0aW9uLmdlbmVyYXRlZCc7XG5cbi8vIFdBUk5JTkc6IFNob3VsZCBub3QgYmUgZXhwb3J0ZWQsIGJ1dCBjdXJyZW50bHkgaXMgYmVjYXVzZSBvZiBhIGJ1Zy4gU2VlIHRoZVxuLy8gY2xhc3MgZGVzY3JpcHRpb24gZm9yIG1vcmUgaW5mb3JtYXRpb24uXG5leHBvcnQgKiBmcm9tICcuL3ByaXZhdGUvaW50cmluc2ljJztcbiJdfQ== |
@@ -33,2 +33,8 @@ import * as cxapi from '@aws-cdk/cx-api'; | ||
}; | ||
/** | ||
* Whether to enable termination protection for this stack. | ||
* | ||
* @default false | ||
*/ | ||
readonly terminationProtection?: boolean; | ||
} | ||
@@ -115,2 +121,6 @@ /** | ||
/** | ||
* Whether termination protection is enabled for this stack. | ||
*/ | ||
readonly terminationProtection?: boolean; | ||
/** | ||
* If this is a nested stack, this represents its `AWS::CloudFormation::Stack` | ||
@@ -117,0 +127,0 @@ * resource. `undefined` for top-level (non-nested) stacks. |
{ | ||
"name": "@aws-cdk/core", | ||
"version": "1.36.1", | ||
"version": "1.37.0", | ||
"description": "AWS Cloud Development Kit Core Library", | ||
@@ -37,2 +37,3 @@ "main": "lib/index.js", | ||
"exclude": [ | ||
"props-physical-name:@aws-cdk/aws-cloudformation.CustomResourceProps", | ||
"construct-ctor:@aws-cdk/core.App.<initializer>", | ||
@@ -107,3 +108,7 @@ "props-no-cfn-types:@aws-cdk/core.CfnOutputProps.condition", | ||
"docs-public-apis:@aws-cdk/core.RemovalPolicy", | ||
"docs-public-apis:@aws-cdk/core.TagType" | ||
"docs-public-apis:@aws-cdk/core.TagType", | ||
"module-name:@aws-cdk/core", | ||
"construct-ctor:@aws-cdk/core.CustomResourceProvider", | ||
"construct-interface-extends-iconstruct:@aws-cdk/core.ICustomResourceProvider", | ||
"props-physical-name:@aws-cdk/core.CustomResourceProps" | ||
] | ||
@@ -117,2 +122,3 @@ }, | ||
"pkglint": "pkglint -f", | ||
"cfn2ts": "cfn2ts", | ||
"package": "cdk-package", | ||
@@ -124,2 +130,9 @@ "awslint": "cdk-awslint", | ||
}, | ||
"cdk-build": { | ||
"cloudformation": "AWS::CloudFormation", | ||
"cfn2ts-core-import": ".", | ||
"pre": [ | ||
"rm -rf test/fs/fixtures && cd test/fs && tar -xzf fixtures.tar.gz" | ||
] | ||
}, | ||
"nyc": { | ||
@@ -146,22 +159,28 @@ "statements": 55, | ||
"@types/nodeunit": "^0.0.30", | ||
"cdk-build-tools": "1.36.1", | ||
"cfn2ts": "1.36.1", | ||
"@types/minimatch": "^3.0.3", | ||
"cdk-build-tools": "1.37.0", | ||
"cfn2ts": "1.37.0", | ||
"fast-check": "^1.24.2", | ||
"lodash": "^4.17.15", | ||
"nodeunit": "^0.11.3", | ||
"pkglint": "1.36.1" | ||
"pkglint": "1.37.0", | ||
"ts-mock-imports": "^1.3.0" | ||
}, | ||
"dependencies": { | ||
"@aws-cdk/cx-api": "1.36.1", | ||
"@aws-cdk/cloud-assembly-schema": "1.36.1", | ||
"minimatch": "^3.0.4", | ||
"@aws-cdk/cx-api": "1.37.0", | ||
"@aws-cdk/cloud-assembly-schema": "1.37.0", | ||
"constructs": "^3.0.2" | ||
}, | ||
"bundledDependencies": [ | ||
"minimatch" | ||
], | ||
"homepage": "https://github.com/aws/aws-cdk", | ||
"peerDependencies": { | ||
"@aws-cdk/cx-api": "1.36.1", | ||
"@aws-cdk/cloud-assembly-schema": "1.36.1", | ||
"@aws-cdk/cx-api": "1.37.0", | ||
"@aws-cdk/cloud-assembly-schema": "1.37.0", | ||
"constructs": "^3.0.2" | ||
}, | ||
"engines": { | ||
"node": ">= 10.12.0" | ||
"node": ">= 10.13.0" | ||
}, | ||
@@ -168,0 +187,0 @@ "stability": "stable", |
244
README.md
@@ -5,2 +5,4 @@ ## AWS Cloud Development Kit Core Library | ||
![cfn-resources: Stable](https://img.shields.io/badge/cfn--resources-stable-success.svg?style=for-the-badge) | ||
![cdk-constructs: Stable](https://img.shields.io/badge/cdk--constructs-stable-success.svg?style=for-the-badge) | ||
@@ -19,2 +21,44 @@ | ||
## Nested Stacks | ||
[Nested stacks](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-nested-stacks.html) are stacks created as part of other stacks. You create a nested stack within another stack by using the `NestedStack` construct. | ||
As your infrastructure grows, common patterns can emerge in which you declare the same components in multiple templates. You can separate out these common components and create dedicated templates for them. Then use the resource in your template to reference other templates, creating nested stacks. | ||
For example, assume that you have a load balancer configuration that you use for most of your stacks. Instead of copying and pasting the same configurations into your templates, you can create a dedicated template for the load balancer. Then, you just use the resource to reference that template from within other templates. | ||
The following example will define a single top-level stack that contains two nested stacks: each one with a single Amazon S3 bucket: | ||
```ts | ||
import { Stack, Construct, StackProps } from '@aws-cdk/core'; | ||
import cfn = require('@aws-cdk/aws-cloudformation'); | ||
import s3 = require('@aws-cdk/aws-s3'); | ||
class MyNestedStack extends cfn.NestedStack { | ||
constructor(scope: Construct, id: string, props?: cfn.NestedStackProps) { | ||
super(scope, id, props); | ||
new s3.Bucket(this, 'NestedBucket'); | ||
} | ||
} | ||
class MyParentStack extends Stack { | ||
constructor(scope: Construct, id: string, props?: StackProps) { | ||
super(scope, id, props); | ||
new MyNestedStack(this, 'Nested1'); | ||
new MyNestedStack(this, 'Nested2'); | ||
} | ||
} | ||
``` | ||
Resources references across nested/parent boundaries (even with multiple levels of nesting) will be wired by the AWS CDK | ||
through CloudFormation parameters and outputs. When a resource from a parent stack is referenced by a nested stack, | ||
a CloudFormation parameter will automatically be added to the nested stack and assigned from the parent; when a resource | ||
from a nested stack is referenced by a parent stack, a CloudFormation output will be automatically be added to the | ||
nested stack and referenced using `Fn::GetAtt "Outputs.Xxx"` from the parent. | ||
Nested stacks also support the use of Docker image and file assets. | ||
## Durations | ||
@@ -177,2 +221,186 @@ | ||
## Custom Resources | ||
Custom Resources are CloudFormation resources that are implemented by arbitrary | ||
user code. They can do arbitrary lookups or modifications during a | ||
CloudFormation deployment. | ||
To define a custom resource, use the `CustomResource` construct: | ||
```ts | ||
import { CustomResource } from '@aws-cdk/core'; | ||
new CustomResource(this, 'MyMagicalResource', { | ||
resourceType: 'Custom::MyCustomResource', // must start with 'Custom::' | ||
// the resource properties | ||
properties: { | ||
Property1: 'foo', | ||
Property2: 'bar' | ||
}, | ||
// the ARN of the provider (SNS/Lambda) which handles | ||
// CREATE, UPDATE or DELETE events for this resource type | ||
// see next section for details | ||
serviceToken: 'ARN' | ||
}); | ||
``` | ||
### Custom Resource Providers | ||
Custom resources are backed by a **custom resource provider** which can be | ||
implemented in one of the following ways (ordered from low-level to high-level): | ||
* `@aws-cdk/aws-sns.Topic` | ||
* `@aws-cdk/aws-lambda.Function` | ||
* `@aws-cdk/custom-resources.Provider` | ||
**NOTE**: when defining resources for a custom resource provider, you will | ||
likely want to define them as a *stack singleton* so that only a single instance | ||
of the provider is created in your stack and which is used by all custom | ||
resources of that type. | ||
The following is a pattern for defining stack singletons in the CDK: | ||
```ts | ||
const stack = Stack.of(this); | ||
const uniqueid = 'GloballyUniqueIdForSingleton'; | ||
return stack.node.tryFindChild(uniqueid) as MySingleton | ||
?? new MySingleton(stack, uniqueid); | ||
``` | ||
#### Amazon SNS Topic | ||
Every time a resource event occurs (CREATE/UPDATE/DELETE), an SNS notification | ||
is sent to the SNS topic. Users must process these notifications (e.g. through a | ||
fleet of worker hosts) and submit success/failure responses to the | ||
CloudFormation service. | ||
Set `serviceToken` to `topic.topicArn` in order to use this provider: | ||
```ts | ||
import * as sns from '@aws-cdk/aws-sns'; | ||
import { CustomResource } from '@aws-cdk/core'; | ||
const topic = new sns.Topic(this, 'MyProvider'); | ||
new CustomResource(this, 'MyResource', { | ||
serviceToken: topic.topicArn | ||
}); | ||
``` | ||
#### AWS Lambda Function | ||
An AWS lambda function is called *directly* by CloudFormation for all resource | ||
events. The handler must take care of explicitly submitting a success/failure | ||
response to the CloudFormation service and handle various error cases. | ||
Set `serviceToken` to `lambda.functionArn` to use this provider: | ||
```ts | ||
import * as lambda from '@aws-cdk/aws-lambda'; | ||
import { CustomResource } from '@aws-cdk/core'; | ||
const fn = new lambda.Function(this, 'MyProvider'); | ||
new CustomResource(this, 'MyResource', { | ||
serviceToken: lambda.functionArn | ||
}); | ||
``` | ||
#### The Custom Resource Provider Framework | ||
The [`@aws-cdk/custom-resource`] module includes an advanced framework for | ||
implementing custom resource providers. | ||
[`@aws-cdk/custom-resource`]: https://docs.aws.amazon.com/cdk/api/latest/docs/custom-resources-readme.html | ||
Handlers are implemented as AWS Lambda functions, which means that they can be | ||
implemented in any Lambda-supported runtime. Furthermore, this provider has an | ||
asynchronous mode, which means that users can provide an `isComplete` lambda | ||
function which is called periodically until the operation is complete. This | ||
allows implementing providers that can take up to two hours to stabilize. | ||
Set `serviceToken` to `provider.serviceToken` to use this provider: | ||
```ts | ||
import { Provider } from 'custom-resources'; | ||
const provider = new Provider(this, 'MyProvider', { | ||
onEventHandler: onEventLambdaFunction, | ||
isCompleteHandler: isCompleteLambdaFunction // optional async waiter | ||
}); | ||
new CustomResource(this, 'MyResource', { | ||
serviceToken: provider.serviceToken | ||
}); | ||
``` | ||
#### Amazon SNS Topic | ||
Every time a resource event occurs (CREATE/UPDATE/DELETE), an SNS notification | ||
is sent to the SNS topic. Users must process these notifications (e.g. through a | ||
fleet of worker hosts) and submit success/failure responses to the | ||
CloudFormation service. | ||
Set `serviceToken` to `topic.topicArn` in order to use this provider: | ||
```ts | ||
import * as sns from '@aws-cdk/aws-sns'; | ||
import { CustomResource } from '@aws-cdk/core'; | ||
const topic = new sns.Topic(this, 'MyProvider'); | ||
new CustomResource(this, 'MyResource', { | ||
serviceToken: topic.topicArn | ||
}); | ||
``` | ||
#### AWS Lambda Function | ||
An AWS lambda function is called *directly* by CloudFormation for all resource | ||
events. The handler must take care of explicitly submitting a success/failure | ||
response to the CloudFormation service and handle various error cases. | ||
Set `serviceToken` to `lambda.functionArn` to use this provider: | ||
```ts | ||
import * as lambda from '@aws-cdk/aws-lambda'; | ||
import { CustomResource } from '@aws-cdk/core'; | ||
const fn = new lambda.Function(this, 'MyProvider'); | ||
new CustomResource(this, 'MyResource', { | ||
serviceToken: lambda.functionArn | ||
}); | ||
``` | ||
#### The Custom Resource Provider Framework | ||
The [`@aws-cdk/custom-resource`] module includes an advanced framework for | ||
implementing custom resource providers. | ||
[`@aws-cdk/custom-resource`]: https://docs.aws.amazon.com/cdk/api/latest/docs/custom-resources-readme.html | ||
Handlers are implemented as AWS Lambda functions, which means that they can be | ||
implemented in any Lambda-supported runtime. Furthermore, this provider has an | ||
asynchronous mode, which means that users can provide an `isComplete` lambda | ||
function which is called periodically until the operation is complete. This | ||
allows implementing providers that can take up to two hours to stabilize. | ||
Set `serviceToken` to `provider.serviceToken` to use this provider: | ||
```ts | ||
import { Provider } from 'custom-resources'; | ||
const provider = new Provider(this, 'MyProvider', { | ||
onEventHandler: onEventLambdaFunction, | ||
isCompleteHandler: isCompleteLambdaFunction // optional async waiter | ||
}); | ||
new CustomResource(this, 'MyResource', { | ||
serviceToken: provider.serviceToken | ||
}); | ||
``` | ||
## AWS CloudFormation features | ||
@@ -428,1 +656,17 @@ | ||
``` | ||
### Termination Protection | ||
You can prevent a stack from being accidentally deleted by enabling termination | ||
protection on the stack. If a user attempts to delete a stack with termination | ||
protection enabled, the deletion fails and the stack--including its status--remains | ||
unchanged. Enabling or disabling termination protection on a stack sets it for any | ||
nested stacks belonging to that stack as well. You can enable termination protection | ||
on a stack by setting the `terminationProtection` prop to `true`. | ||
```ts | ||
const stack = new Stack(app, 'StackName', { | ||
terminationProtection: true, | ||
}); | ||
``` | ||
By default, termination protection is disabled. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2766723
236
21037
669
7
11
1
24
+ Addedminimatch@^3.0.4
+ Added@aws-cdk/cloud-assembly-schema@1.37.0(transitive)
+ Added@aws-cdk/cx-api@1.37.0(transitive)
- Removed@aws-cdk/cloud-assembly-schema@1.36.1(transitive)
- Removed@aws-cdk/cx-api@1.36.1(transitive)
Updated@aws-cdk/cx-api@1.37.0