@Stability(value=Experimental)
See: Description
| Interface | Description |
|---|---|
| AppProps |
Initialization props for apps.
|
| ArnComponents |
EXPERIMENTAL
|
| CfnAutoScalingReplacingUpdate |
Specifies whether an Auto Scaling group and the instances it contains are replaced during an update.
|
| CfnAutoScalingRollingUpdate |
To specify how AWS CloudFormation handles rolling updates for an Auto Scaling group, use the AutoScalingRollingUpdate policy.
|
| CfnAutoScalingScheduledAction |
With scheduled actions, the group size properties of an Auto Scaling group can change at any time.
|
| CfnCodeDeployLambdaAliasUpdate |
To perform an AWS CodeDeploy deployment when the version changes on an AWS::Lambda::Alias resource, use the CodeDeployLambdaAliasUpdate update policy.
|
| CfnConditionProps |
EXPERIMENTAL
|
| CfnCreationPolicy |
Associate the CreationPolicy attribute with a resource to prevent its status from reaching create complete until AWS CloudFormation receives a specified number of success signals or the timeout period is exceeded.
|
| CfnDynamicReferenceProps |
Properties for a Dynamic Reference.
|
| CfnIncludeProps |
EXPERIMENTAL
|
| CfnMappingProps |
EXPERIMENTAL
|
| CfnOutputProps |
EXPERIMENTAL
|
| CfnParameterProps |
EXPERIMENTAL
|
| CfnResourceAutoScalingCreationPolicy |
For an Auto Scaling group replacement update, specifies how many instances must signal success for the update to succeed.
|
| CfnResourceProps |
EXPERIMENTAL
|
| CfnResourceSignal |
When AWS CloudFormation creates the associated resource, configures the number of required success signals and the length of time that AWS CloudFormation waits for those signals.
|
| CfnRuleAssertion |
A rule assertion.
|
| CfnRuleProps |
A rule can include a RuleCondition property and must include an Assertions property.
|
| CfnTag |
EXPERIMENTAL
|
| CfnUpdatePolicy |
Use the UpdatePolicy attribute to specify how AWS CloudFormation handles updates to the AWS::AutoScaling::AutoScalingGroup resource.
|
| Dependency |
A single dependency.
|
| EncodingOptions |
Properties to string encodings.
|
| Environment |
The deployment environment for a stack.
|
| GetContextKeyOptions |
EXPERIMENTAL
|
| GetContextKeyResult |
EXPERIMENTAL
|
| GetContextValueOptions |
EXPERIMENTAL
|
| GetContextValueResult |
EXPERIMENTAL
|
| IAnyProducer |
Interface for lazy untyped value producers.
|
| IAspect |
Represents an Aspect.
|
| ICfnConditionExpression |
Represents a CloudFormation element that can be used within a Condition.
|
| ICfnResourceOptions |
EXPERIMENTAL
|
| IConstruct |
Represents a construct.
|
| IDependable |
Trait marker for classes that can be depended upon.
|
| IFragmentConcatenator |
Function used to concatenate symbols in the target document language.
|
| IListProducer |
Interface for lazy list producers.
|
| INumberProducer |
Interface for lazy number producers.
|
| IPostProcessor |
A Token that can post-process the complete resolved value, after resolve() has recursed over it.
|
| IResolvable |
Interface for values that can be resolvable later.
|
| IResolveContext |
Current resolution context for tokens.
|
| IResource |
Interface for the Resource construct.
|
| IStringProducer |
Interface for lazy string producers.
|
| ISynthesisSession |
Represents a single session of synthesis.
|
| ITaggable |
Interface to implement tags.
|
| ITemplateOptions |
CloudFormation template options for a stack.
|
| ITokenMapper |
Interface to apply operation to tokens in a string.
|
| ITokenResolver |
How to resolve tokens.
|
| LazyAnyValueOptions |
Options for creating lazy untyped tokens.
|
| LazyListValueOptions |
Options for creating a lazy list token.
|
| LazyStringValueOptions |
Options for creating a lazy string token.
|
| OutgoingReference |
Represents a reference that originates from a specific construct.
|
| RemovalPolicyOptions |
EXPERIMENTAL
|
| ResolveOptions |
Options to the resolve() operation.
|
| ResourceProps |
Construction properties for
Resource. |
| SecretsManagerSecretOptions |
Options for referencing a secret value from Secrets Manager.
|
| StackProps |
EXPERIMENTAL
|
| SynthesisOptions |
Options for synthesis.
|
| TagProps |
Properties for a tag.
|
| TimeConversionOptions |
Options for how to convert time to a different unit.
|
| ValidationError |
An error returned during the validation phase.
|
| Class | Description |
|---|---|
| App |
A construct which represents an entire CDK app.
|
| AppProps.Builder |
A builder for
AppProps |
| AppProps.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| Arn |
EXPERIMENTAL
|
| ArnComponents.Builder |
A builder for
ArnComponents |
| ArnComponents.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| Aws |
Accessor for pseudo parameters.
|
| CfnAutoScalingReplacingUpdate.Builder |
A builder for
CfnAutoScalingReplacingUpdate |
| CfnAutoScalingReplacingUpdate.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| CfnAutoScalingRollingUpdate.Builder |
A builder for
CfnAutoScalingRollingUpdate |
| CfnAutoScalingRollingUpdate.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| CfnAutoScalingScheduledAction.Builder |
A builder for
CfnAutoScalingScheduledAction |
| CfnAutoScalingScheduledAction.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| CfnCodeDeployLambdaAliasUpdate.Builder |
A builder for
CfnCodeDeployLambdaAliasUpdate |
| CfnCodeDeployLambdaAliasUpdate.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| CfnCondition |
Represents a CloudFormation condition, for resources which must be conditionally created and the determination must be made at deploy time.
|
| CfnConditionProps.Builder |
A builder for
CfnConditionProps |
| CfnConditionProps.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| CfnCreationPolicy.Builder |
A builder for
CfnCreationPolicy |
| CfnCreationPolicy.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| CfnDynamicReference |
References a dynamically retrieved value.
|
| CfnDynamicReferenceProps.Builder |
A builder for
CfnDynamicReferenceProps |
| CfnDynamicReferenceProps.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| CfnElement |
An element of a CloudFormation stack.
|
| CfnInclude |
Includes a CloudFormation template into a stack.
|
| CfnIncludeProps.Builder |
A builder for
CfnIncludeProps |
| CfnIncludeProps.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| CfnMapping |
Represents a CloudFormation mapping.
|
| CfnMappingProps.Builder |
A builder for
CfnMappingProps |
| CfnMappingProps.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| CfnOutput |
EXPERIMENTAL
|
| CfnOutputProps.Builder |
A builder for
CfnOutputProps |
| CfnOutputProps.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| CfnParameter |
A CloudFormation parameter.
|
| CfnParameterProps.Builder |
A builder for
CfnParameterProps |
| CfnParameterProps.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| CfnRefElement |
Base class for referenceable CloudFormation constructs which are not Resources.
|
| CfnResource |
Represents a CloudFormation resource.
|
| CfnResourceAutoScalingCreationPolicy.Builder |
A builder for
CfnResourceAutoScalingCreationPolicy |
| CfnResourceAutoScalingCreationPolicy.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| CfnResourceProps.Builder |
A builder for
CfnResourceProps |
| CfnResourceProps.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| CfnResourceSignal.Builder |
A builder for
CfnResourceSignal |
| CfnResourceSignal.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| CfnRule |
The Rules that define template constraints in an AWS Service Catalog portfolio describe when end users can use the template and which values they can specify for parameters that are declared in the AWS CloudFormation template used to create the product they are attempting to use.
|
| CfnRuleAssertion.Builder |
A builder for
CfnRuleAssertion |
| CfnRuleAssertion.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| CfnRuleProps.Builder |
A builder for
CfnRuleProps |
| CfnRuleProps.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| CfnTag.Builder |
A builder for
CfnTag |
| CfnTag.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| CfnUpdatePolicy.Builder |
A builder for
CfnUpdatePolicy |
| CfnUpdatePolicy.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| ConcreteDependable |
A set of constructs to be used as a dependable.
|
| Construct |
Represents the building block of the construct graph.
|
| ConstructNode |
Represents the construct node in the scope tree.
|
| ContextProvider |
Base class for the model side of context providers.
|
| DefaultTokenResolver |
Default resolver implementation.
|
| DependableTrait |
Trait for IDependable.
|
| Dependency.Builder |
A builder for
Dependency |
| Dependency.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| Duration |
Represents a length of time.
|
| EncodingOptions.Builder |
A builder for
EncodingOptions |
| EncodingOptions.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| Environment.Builder |
A builder for
Environment |
| Environment.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| Fn |
CloudFormation intrinsic functions.
|
| GetContextKeyOptions.Builder |
A builder for
GetContextKeyOptions |
| GetContextKeyOptions.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| GetContextKeyResult.Builder |
A builder for
GetContextKeyResult |
| GetContextKeyResult.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| GetContextValueOptions.Builder |
A builder for
GetContextValueOptions |
| GetContextValueOptions.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| GetContextValueResult.Builder |
A builder for
GetContextValueResult |
| GetContextValueResult.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| IAnyProducer.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| IAspect.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| ICfnConditionExpression.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| ICfnResourceOptions.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| IConstruct.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| IDependable.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| IFragmentConcatenator.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| IListProducer.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| Intrinsic |
Token subclass that represents values intrinsic to the target document language.
|
| INumberProducer.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| IPostProcessor.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| IResolvable.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| IResolveContext.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| IResource.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| IStringProducer.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| ISynthesisSession.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| ITaggable.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| ITemplateOptions.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| ITokenMapper.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| ITokenResolver.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| Lazy |
Lazily produce a value.
|
| LazyAnyValueOptions.Builder |
A builder for
LazyAnyValueOptions |
| LazyAnyValueOptions.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| LazyListValueOptions.Builder |
A builder for
LazyListValueOptions |
| LazyListValueOptions.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| LazyStringValueOptions.Builder |
A builder for
LazyStringValueOptions |
| LazyStringValueOptions.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| OutgoingReference.Builder |
A builder for
OutgoingReference |
| OutgoingReference.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| PhysicalName |
Includes special markers for automatic generation of physical names.
|
| Reference |
An intrinsic Token that represents a reference to a construct.
|
| RemovalPolicyOptions.Builder |
A builder for
RemovalPolicyOptions |
| RemovalPolicyOptions.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| RemoveTag |
The RemoveTag Aspect will handle removing tags from this node and children.
|
| ResolveOptions.Builder |
A builder for
ResolveOptions |
| ResolveOptions.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| Resource |
A construct which represents an AWS resource.
|
| ResourceProps.Builder |
A builder for
ResourceProps |
| ResourceProps.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| ScopedAws |
Accessor for scoped pseudo parameters.
|
| SecretsManagerSecretOptions.Builder |
A builder for
SecretsManagerSecretOptions |
| SecretsManagerSecretOptions.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| SecretValue |
Work with secret values in the CDK.
|
| Stack |
A root construct which represents a single CloudFormation stack.
|
| StackProps.Builder |
A builder for
StackProps |
| StackProps.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| StringConcat |
Converts all fragments to strings and concats those.
|
| SynthesisOptions.Builder |
A builder for
SynthesisOptions |
| SynthesisOptions.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| Tag |
The Tag Aspect will handle adding a tag to this node and cascading tags to children.
|
| TagManager |
TagManager facilitates a common implementation of tagging for Constructs.
|
| TagProps.Builder |
A builder for
TagProps |
| TagProps.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| TimeConversionOptions.Builder |
A builder for
TimeConversionOptions |
| TimeConversionOptions.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| Token |
Represents a special or lazily-evaluated value.
|
| Tokenization |
Less oft-needed functions to manipulate Tokens.
|
| TokenizedStringFragments |
Fragments of a concatenated string containing stringified Tokens.
|
| ValidationError.Builder |
A builder for
ValidationError |
| ValidationError.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| ValidationResult |
Representation of validation results.
|
| ValidationResults |
A collection of validation results.
|
| Enum | Description |
|---|---|
| CfnDeletionPolicy |
With the DeletionPolicy attribute you can preserve or (in some cases) backup a resource when its stack is deleted.
|
| CfnDynamicReferenceService |
The service to retrieve the dynamic reference from.
|
| ConstructOrder |
In what order to return constructs.
|
| RemovalPolicy |
EXPERIMENTAL
|
| TagType |
EXPERIMENTAL
|
This is a developer preview (public beta) module. Releases might lack important features and might have future breaking changes.
This API is still under active development and subject to non-backward compatible changes or removal in any future version. Use of the API is not recommended in production environments. Experimental APIs are not subject to the Semantic Versioning model.
This library includes the basic building blocks of the AWS Cloud Development Kit (AWS CDK).
Aspects are a mechanism to extend the CDK without having to directly impact the class hierarchy. We have implemented aspects using the Visitor Pattern.
An aspect in the CDK is defined by this interface
Aspects can be applied to any construct. During the tree
"prepare" phase the aspect will visit each construct in the tree once.
Aspects are invoked in the order they were added to the construct. They
traverse the construct tree in a breadth first order starting at the App
ending at the leaf nodes (most commonly the CloudFormation Resource). Aspect
authors implement the visit(IConstruct) function and can inspect the
Construct for specific characteristics. Such as, is this construct a
CloudFormation Resource?
Tags are implemented using aspects.
Tags can be applied to any construct. Tags are inherited, based on the scope. If you tag construct A, and A contains construct B, construct B inherits the tag. The Tag API supports:
Tag add (apply) a tag, either to specific resources or all but specific resourcesRemoveTag remove a tag, again either from specific resources or all but specific resourcesA simple example, if you create a stack and want anything in the stack to receive a tag:
import cdk = require('@aws-cdk/core');
const app = new cdk.App();
const theBestStack = new cdk.Stack(app, 'MarketingSystem');
theBestStack.node.apply(new cdk.Tag('StackType', 'TheBest'));
// any resources added that support tags will get them
The goal was to enable the ability to define tags in one place and have them applied consistently for all resources that support tagging. In addition the developer should not have to know if the resource supports tags. The developer defines the tagging intents for all resources within a path. If the resources support tags they are added, else no action is taken.
We are going to use the ECS example as starting point.
For the purposes of example, this ECS cluster is for the Marketing Department. Marketing has two core groups Business to Business (B2B) and Business to Consumer (B2C). However, the Marketing team relies on the Platform team to help build the common components across businesses and separates costs to match. The goal here is tag the Platform team resources, the Marketing Department and then Marketing groups to enable proper cost allocations.
We have modified the example and the code is located: examples/cdk-examples-typescript/hello-cdk-ecs-tags
When the example is run the following tags are created:
We are omitting the default tags for VPC components.
| Construct Path | Tag Key | Tag Value | | ----------|:---------|:-----| |MarketingSystem/MarketingVpc|CostCenter|Platform| |MarketingSystem/MarketingVpc/PublicSubnet1| CostCenter | Platform| |MarketingSystem/MarketingVpc/PublicSubnet1/RouteTable| CostCenter | Platform| |MarketingSystem/MarketingVpc/PublicSubnet1/NATGateway| CostCenter | Platform| |MarketingSystem/MarketingVpc/PublicSubnet2| CostCenter | Platform| |MarketingSystem/MarketingVpc/PublicSubnet2/RouteTable| CostCenter | Platform| |MarketingSystem/MarketingVpc/PublicSubnet2/NATGateway| CostCenter | Platform| |MarketingSystem/MarketingVpc/PublicSubnet3| CostCenter | Platform| |MarketingSystem/MarketingVpc/PublicSubnet3/RouteTable| CostCenter | Platform| |MarketingSystem/MarketingVpc/PublicSubnet3/NATGateway| CostCenter | Platform| |MarketingSystem/MarketingVpc/PrivateSubnet1| CostCenter | Platform| |MarketingSystem/MarketingVpc/PrivateSubnet1/RouteTable| CostCenter | Platform| |MarketingSystem/MarketingVpc/PrivateSubnet2| CostCenter | Platform| |MarketingSystem/MarketingVpc/PrivateSubnet2/RouteTable| CostCenter | Platform| |MarketingSystem/MarketingVpc/PrivateSubnet3| CostCenter | Platform| |MarketingSystem/MarketingVpc/PrivateSubnet3/RouteTable| CostCenter | Platform| |MarketingSystem/MarketingVpc/IGW|CostCenter|Platform| |MarketingSystem/B2BService/Service/SecurityGroup/Resource|CostCenter|Marketing| |MarketingSystem/B2BService/LB/Resource|CostCenter|Marketing| |MarketingSystem/B2BService/LB/SecurityGroup/Resource|CostCenter|Marketing| |MarketingSystem/B2BService/LB/PublicListener/ECSGroup/Resource|CostCenter|Marketing| |MarketingSystem/B2CService/Service/SecurityGroup/Resource|CostCenter|Marketing| |MarketingSystem/B2CService/LB/Resource|CostCenter|Marketing| |MarketingSystem/B2CService/LB/SecurityGroup/Resource|CostCenter|Marketing| |MarketingSystem/B2CService/LB/PublicListener/ECSGroup/Resource|CostCenter|Marketing|
As you can see many tags are generated with only a few intent based directives. The CDK does default some additional tags for suggested Name keys. If you want to remove those tags you can do so by using the RemoveTag aspect, see below:
// snip //
const vpc = new ec2.Vpc(marketingStack, 'MarketingVpc', {
maxAZs: 3 // Default is all AZs in region
});
// override the VPC tags with Platform
// this will tag the VPC, Subnets, Route Tables, IGW, and NatGWs
vpc.node.apply(new cdk.Tag(COST_CENTER_KEY, 'Platform'));
vpc.node.apply(new cdk.RemoveTag('Name'));
// snip //
This will remove the name tags from the VPC, subnets, route tables and NAT gateways. If you've been following closely, this may lead you to ask how does remove work when the tag is actually applied closer to the resource? The Tag API has a few features that are covered later to explain how this works.
In order to enable additional controls a Tag can specifically include or
exclude a CloudFormation Resource Type, propagate tags for an autoscaling group,
and use priority to override the default precedence. See the TagProps
interface for more details.
Tags can be configured by using the properties for the AWS CloudFormation layer resources or by using the tag aspects described here. The aspects will always take precedence over the AWS CloudFormation layer in the event of a name collision. The tags will be merged otherwise. For the aspect based tags, the tags applied closest to the resource will take precedence, given an equal priority. A higher priority tag will always take precedence over a lower priority tag.
This property is a boolean that defaults to true. When true and the aspect
visits an AutoScalingGroup resource the PropagateAtLaunch property is set to
true. If false the property is set accordingly.
// ... snip
const vpc = new ec2.Vpc(this, 'MyVpc', { ... });
vpc.node.apply(new cdk.Tag('MyKey', 'MyValue', { applyToLaunchedInstances: false }));
// ... snip
Include is an array property that contains strings of CloudFormation Resource Types. As the aspect visits nodes it only takes action if node is one of the resource types in the array. By default the array is empty and an empty array is interpreted as apply to any resource type.
// ... snip
const vpc = new ec2.Vpc(this, 'MyVpc', { ... });
vpc.node.apply(new cdk.Tag('MyKey', 'MyValue', { includeResourceTypes: ['AWS::EC2::Subnet']}));
// ... snip
Exclude is the inverse of include. Exclude is also an array of CloudFormation Resource Types. As the aspect visit nodes it will not take action if the node is one of the resource types in the array. By default the array is empty and an empty array is interpreted to match no resource type. Exclude takes precedence over include in the event of a collision.
// ... snip
const vpc = new ec2.Vpc(this, 'MyVpc', { ... });
vpc.node.apply(new cdk.Tag('MyKey', 'MyValue', { exludeResourceTypes: ['AWS::EC2::Subnet']}));
// ... snip
Priority is used to control precedence when the default pattern does not work.
In general users should try to avoid using priority, but in some situations it
is required. In the example above, this is how RemoveTag works. The default
setting for removing tags uses a higher priority than the standard tag.
// ... snip
const vpc = new ec2.Vpc(this, 'MyVpc', { ... });
vpc.node.apply(new cdk.Tag('MyKey', 'MyValue', { priority: 2 }));
// ... snip
To help avoid accidental storage of secrets as plain text we use the SecretValue type to
represent secrets.
The best practice is to store secrets in AWS Secrets Manager and reference them using SecretValue.secretsManager:
const secret = SecretValue.secretsManager('secretId', {
jsonField: 'password' // optional: key of a JSON field to retrieve (defaults to all content),
versionId: 'id' // optional: id of the version (default AWSCURRENT)
versionStage: 'stage' // optional: version stage name (default AWSCURRENT)
});
Using AWS Secrets Manager is the recommended way to reference secrets in a CDK app.
However, SecretValue supports the following additional options:
SecretValue.plainText(secret): stores the secret as plain text in your app and the resulting template (not recommended).SecretValue.ssmSecure(param, version): refers to a secret stored as a SecureString in the SSM Parameter Store.SecretValue.cfnParameter(param): refers to a secret passed through a CloudFormation parameter (must have NoEcho: true).SecretValue.cfnDynamicReference(dynref): refers to a secret described by a CloudFormation dynamic reference (used by ssmSecure and secretsManager).Copyright © 2019. All rights reserved.