class CfnService (construct)
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.ECS.CfnService |
![]() | github.com/aws/aws-cdk-go/awscdk/v2/awsecs#CfnService |
![]() | software.amazon.awscdk.services.ecs.CfnService |
![]() | aws_cdk.aws_ecs.CfnService |
![]() | aws-cdk-lib » aws_ecs » CfnService |
Implements
IConstruct
, IDependable
, IInspectable
, ITaggable
The AWS::ECS::Service
resource creates an Amazon Elastic Container Service (Amazon ECS) service that runs and maintains the requested number of tasks and associated load balancers.
The stack update fails if you change any properties that require replacement and at least one Amazon ECS Service Connect
ServiceConnectConfiguration
property is configured. This is because AWS CloudFormation creates the replacement service first, but eachServiceConnectService
must have a name that is unique in the namespace. > Starting April 15, 2023, AWS ; will not onboard new customers to Amazon Elastic Inference (EI), and will help current customers migrate their workloads to options that offer better price and performance. After April 15, 2023, new customers will not be able to launch instances with Amazon EI accelerators in Amazon SageMaker, Amazon ECS , or Amazon EC2 . However, customers who have used Amazon EI at least once during the past 30-day period are considered current customers and will be able to continue using the service.
See also: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ecs-service.html
Example
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_ecs as ecs } from 'aws-cdk-lib';
const cfnService = new ecs.CfnService(this, 'MyCfnService', /* all optional props */ {
availabilityZoneRebalancing: 'availabilityZoneRebalancing',
capacityProviderStrategy: [{
base: 123,
capacityProvider: 'capacityProvider',
weight: 123,
}],
cluster: 'cluster',
deploymentConfiguration: {
alarms: {
alarmNames: ['alarmNames'],
enable: false,
rollback: false,
},
deploymentCircuitBreaker: {
enable: false,
rollback: false,
},
maximumPercent: 123,
minimumHealthyPercent: 123,
},
deploymentController: {
type: 'type',
},
desiredCount: 123,
enableEcsManagedTags: false,
enableExecuteCommand: false,
healthCheckGracePeriodSeconds: 123,
launchType: 'launchType',
loadBalancers: [{
containerName: 'containerName',
containerPort: 123,
loadBalancerName: 'loadBalancerName',
targetGroupArn: 'targetGroupArn',
}],
networkConfiguration: {
awsvpcConfiguration: {
assignPublicIp: 'assignPublicIp',
securityGroups: ['securityGroups'],
subnets: ['subnets'],
},
},
placementConstraints: [{
type: 'type',
// the properties below are optional
expression: 'expression',
}],
placementStrategies: [{
type: 'type',
// the properties below are optional
field: 'field',
}],
platformVersion: 'platformVersion',
propagateTags: 'propagateTags',
role: 'role',
schedulingStrategy: 'schedulingStrategy',
serviceConnectConfiguration: {
enabled: false,
// the properties below are optional
logConfiguration: {
logDriver: 'logDriver',
options: {
optionsKey: 'options',
},
secretOptions: [{
name: 'name',
valueFrom: 'valueFrom',
}],
},
namespace: 'namespace',
services: [{
portName: 'portName',
// the properties below are optional
clientAliases: [{
port: 123,
// the properties below are optional
dnsName: 'dnsName',
}],
discoveryName: 'discoveryName',
ingressPortOverride: 123,
timeout: {
idleTimeoutSeconds: 123,
perRequestTimeoutSeconds: 123,
},
tls: {
issuerCertificateAuthority: {
awsPcaAuthorityArn: 'awsPcaAuthorityArn',
},
// the properties below are optional
kmsKey: 'kmsKey',
roleArn: 'roleArn',
},
}],
},
serviceName: 'serviceName',
serviceRegistries: [{
containerName: 'containerName',
containerPort: 123,
port: 123,
registryArn: 'registryArn',
}],
tags: [{
key: 'key',
value: 'value',
}],
taskDefinition: 'taskDefinition',
volumeConfigurations: [{
name: 'name',
// the properties below are optional
managedEbsVolume: {
roleArn: 'roleArn',
// the properties below are optional
encrypted: false,
filesystemType: 'filesystemType',
iops: 123,
kmsKeyId: 'kmsKeyId',
sizeInGiB: 123,
snapshotId: 'snapshotId',
tagSpecifications: [{
resourceType: 'resourceType',
// the properties below are optional
propagateTags: 'propagateTags',
tags: [{
key: 'key',
value: 'value',
}],
}],
throughput: 123,
volumeInitializationRate: 123,
volumeType: 'volumeType',
},
}],
vpcLatticeConfigurations: [{
portName: 'portName',
roleArn: 'roleArn',
targetGroupArn: 'targetGroupArn',
}],
});
Initializer
new CfnService(scope: Construct, id: string, props?: CfnServiceProps)
Parameters
- scope
Construct
— Scope in which this resource is defined. - id
string
— Construct identifier for this resource (unique in its scope). - props
Cfn
— Resource properties.Service Props
Construct Props
Name | Type | Description |
---|---|---|
availability | string | Indicates whether to use Availability Zone rebalancing for the service. |
capacity | IResolvable | IResolvable | Capacity [] | The capacity provider strategy to use for the service. |
cluster? | string | The short name or full Amazon Resource Name (ARN) of the cluster that you run your service on. |
deployment | IResolvable | Deployment | Optional deployment parameters that control how many tasks run during the deployment and the ordering of stopping and starting tasks. |
deployment | IResolvable | Deployment | The deployment controller to use for the service. |
desired | number | The number of instantiations of the specified task definition to place and keep running in your service. |
enable | boolean | IResolvable | Specifies whether to turn on Amazon ECS managed tags for the tasks within the service. |
enable | boolean | IResolvable | Determines whether the execute command functionality is turned on for the service. |
health | number | The period of time, in seconds, that the Amazon ECS service scheduler ignores unhealthy Elastic Load Balancing, VPC Lattice, and container health checks after a task has first started. |
launch | string | The launch type on which to run your service. |
load | IResolvable | IResolvable | Load [] | A list of load balancer objects to associate with the service. |
network | IResolvable | Network | The network configuration for the service. |
placement | IResolvable | IResolvable | Placement [] | An array of placement constraint objects to use for tasks in your service. |
placement | IResolvable | IResolvable | Placement [] | The placement strategy objects to use for tasks in your service. |
platform | string | The platform version that your tasks in the service are running on. |
propagate | string | Specifies whether to propagate the tags from the task definition to the task. |
role? | string | The name or full Amazon Resource Name (ARN) of the IAM role that allows Amazon ECS to make calls to your load balancer on your behalf. |
scheduling | string | The scheduling strategy to use for the service. For more information, see Services . |
service | IResolvable | Service | The configuration for this service to discover and connect to services, and be discovered by, and connected from, other services within a namespace. |
service | string | The name of your service. |
service | IResolvable | IResolvable | Service [] | The details of the service discovery registry to associate with this service. For more information, see Service discovery . |
tags? | Cfn [] | The metadata that you apply to the service to help you categorize and organize them. |
task | string | The family and revision ( family:revision ) or full ARN of the task definition to run in your service. |
volume | IResolvable | IResolvable | Service [] | The configuration for a volume specified in the task definition as a volume that is configured at launch time. |
vpc | IResolvable | IResolvable | Vpc [] | The VPC Lattice configuration for the service being created. |
availabilityZoneRebalancing?
Type:
string
(optional, default: "DISABLED")
Indicates whether to use Availability Zone rebalancing for the service.
For more information, see Balancing an Amazon ECS service across Availability Zones in the Amazon Elastic Container Service Developer Guide .
capacityProviderStrategy?
Type:
IResolvable
|
IResolvable
|
Capacity
[]
(optional)
The capacity provider strategy to use for the service.
If a capacityProviderStrategy
is specified, the launchType
parameter must be omitted. If no capacityProviderStrategy
or launchType
is specified, the defaultCapacityProviderStrategy
for the cluster is used.
A capacity provider strategy may contain a maximum of 6 capacity providers.
To remove this property from your service resource, specify an empty
CapacityProviderStrategyItem
array.
cluster?
Type:
string
(optional)
The short name or full Amazon Resource Name (ARN) of the cluster that you run your service on.
If you do not specify a cluster, the default cluster is assumed.
deploymentConfiguration?
Type:
IResolvable
|
Deployment
(optional)
Optional deployment parameters that control how many tasks run during the deployment and the ordering of stopping and starting tasks.
deploymentController?
Type:
IResolvable
|
Deployment
(optional)
The deployment controller to use for the service.
If no deployment controller is specified, the default value of ECS
is used.
desiredCount?
Type:
number
(optional)
The number of instantiations of the specified task definition to place and keep running in your service.
For new services, if a desired count is not specified, a default value of 1
is used. When using the DAEMON
scheduling strategy, the desired count is not required.
For existing services, if a desired count is not specified, it is omitted from the operation.
enableEcsManagedTags?
Type:
boolean |
IResolvable
(optional)
Specifies whether to turn on Amazon ECS managed tags for the tasks within the service.
For more information, see Tagging your Amazon ECS resources in the Amazon Elastic Container Service Developer Guide .
When you use Amazon ECS managed tags, you need to set the propagateTags
request parameter.
enableExecuteCommand?
Type:
boolean |
IResolvable
(optional)
Determines whether the execute command functionality is turned on for the service.
If true
, the execute command functionality is turned on for all containers in tasks as part of the service.
healthCheckGracePeriodSeconds?
Type:
number
(optional)
The period of time, in seconds, that the Amazon ECS service scheduler ignores unhealthy Elastic Load Balancing, VPC Lattice, and container health checks after a task has first started.
If you don't specify a health check grace period value, the default value of 0
is used. If you don't use any of the health checks, then healthCheckGracePeriodSeconds
is unused.
If your service's tasks take a while to start and respond to health checks, you can specify a health check grace period of up to 2,147,483,647 seconds (about 69 years). During that time, the Amazon ECS service scheduler ignores health check status. This grace period can prevent the service scheduler from marking tasks as unhealthy and stopping them before they have time to come up.
launchType?
Type:
string
(optional)
The launch type on which to run your service.
For more information, see Amazon ECS Launch Types in the Amazon Elastic Container Service Developer Guide .
loadBalancers?
Type:
IResolvable
|
IResolvable
|
Load
[]
(optional)
A list of load balancer objects to associate with the service.
If you specify the Role
property, LoadBalancers
must be specified as well. For information about the number of load balancers that you can specify per service, see Service Load Balancing in the Amazon Elastic Container Service Developer Guide .
To remove this property from your service resource, specify an empty
LoadBalancer
array.
networkConfiguration?
Type:
IResolvable
|
Network
(optional)
The network configuration for the service.
This parameter is required for task definitions that use the awsvpc
network mode to receive their own elastic network interface, and it is not supported for other network modes. For more information, see Task Networking in the Amazon Elastic Container Service Developer Guide .
placementConstraints?
Type:
IResolvable
|
IResolvable
|
Placement
[]
(optional)
An array of placement constraint objects to use for tasks in your service.
You can specify a maximum of 10 constraints for each task. This limit includes constraints in the task definition and those specified at runtime.
To remove this property from your service resource, specify an empty
PlacementConstraint
array.
placementStrategies?
Type:
IResolvable
|
IResolvable
|
Placement
[]
(optional)
The placement strategy objects to use for tasks in your service.
You can specify a maximum of 5 strategy rules for each service.
To remove this property from your service resource, specify an empty
PlacementStrategy
array.
platformVersion?
Type:
string
(optional, default: "LATEST")
The platform version that your tasks in the service are running on.
A platform version is specified only for tasks using the Fargate launch type. If one isn't specified, the LATEST
platform version is used. For more information, see AWS Fargate platform versions in the Amazon Elastic Container Service Developer Guide .
propagateTags?
Type:
string
(optional)
Specifies whether to propagate the tags from the task definition to the task.
If no value is specified, the tags aren't propagated. Tags can only be propagated to the task during task creation. To add tags to a task after task creation, use the TagResource API action.
You must set this to a value other than NONE
when you use Cost Explorer. For more information, see Amazon ECS usage reports in the Amazon Elastic Container Service Developer Guide .
The default is NONE
.
role?
Type:
string
(optional)
The name or full Amazon Resource Name (ARN) of the IAM role that allows Amazon ECS to make calls to your load balancer on your behalf.
This parameter is only permitted if you are using a load balancer with your service and your task definition doesn't use the awsvpc
network mode. If you specify the role
parameter, you must also specify a load balancer object with the loadBalancers
parameter.
If your account has already created the Amazon ECS service-linked role, that role is used for your service unless you specify a role here. The service-linked role is required if your task definition uses the
awsvpc
network mode or if the service is configured to use service discovery, an external deployment controller, multiple target groups, or Elastic Inference accelerators in which case you don't specify a role here. For more information, see Using service-linked roles for Amazon ECS in the Amazon Elastic Container Service Developer Guide .
If your specified role has a path other than /
, then you must either specify the full role ARN (this is recommended) or prefix the role name with the path. For example, if a role with the name bar
has a path of /foo/
then you would specify /foo/bar
as the role name. For more information, see Friendly names and paths in the IAM User Guide .
schedulingStrategy?
Type:
string
(optional)
The scheduling strategy to use for the service. For more information, see Services .
There are two service scheduler strategies available:
REPLICA
-The replica scheduling strategy places and maintains the desired number of tasks across your cluster. By default, the service scheduler spreads tasks across Availability Zones. You can use task placement strategies and constraints to customize task placement decisions. This scheduler strategy is required if the service uses theCODE_DEPLOY
orEXTERNAL
deployment controller types.DAEMON
-The daemon scheduling strategy deploys exactly one task on each active container instance that meets all of the task placement constraints that you specify in your cluster. The service scheduler also evaluates the task placement constraints for running tasks and will stop tasks that don't meet the placement constraints. When you're using this strategy, you don't need to specify a desired number of tasks, a task placement strategy, or use Service Auto Scaling policies.
Tasks using the Fargate launch type or the
CODE_DEPLOY
orEXTERNAL
deployment controller types don't support theDAEMON
scheduling strategy.
serviceConnectConfiguration?
Type:
IResolvable
|
Service
(optional)
The configuration for this service to discover and connect to services, and be discovered by, and connected from, other services within a namespace.
Tasks that run in a namespace can use short names to connect to services in the namespace. Tasks can connect to services across all of the clusters in the namespace. Tasks connect through a managed proxy container that collects logs and metrics for increased visibility. Only the tasks that Amazon ECS services create are supported with Service Connect. For more information, see Service Connect in the Amazon Elastic Container Service Developer Guide .
serviceName?
Type:
string
(optional)
The name of your service.
Up to 255 letters (uppercase and lowercase), numbers, underscores, and hyphens are allowed. Service names must be unique within a cluster, but you can have similarly named services in multiple clusters within a Region or across multiple Regions.
The stack update fails if you change any properties that require replacement and the
ServiceName
is configured. This is because AWS CloudFormation creates the replacement service first, but eachServiceName
must be unique in the cluster.
serviceRegistries?
Type:
IResolvable
|
IResolvable
|
Service
[]
(optional)
The details of the service discovery registry to associate with this service. For more information, see Service discovery .
Each service may be associated with one service registry. Multiple service registries for each service isn't supported. > To remove this property from your service resource, specify an empty
ServiceRegistry
array.
tags?
Type:
Cfn
[]
(optional)
The metadata that you apply to the service to help you categorize and organize them.
Each tag consists of a key and an optional value, both of which you define. When a service is deleted, the tags are deleted as well.
The following basic restrictions apply to tags:
- Maximum number of tags per resource - 50
- For each resource, each tag key must be unique, and each tag key can have only one value.
- Maximum key length - 128 Unicode characters in UTF-8
- Maximum value length - 256 Unicode characters in UTF-8
- If your tagging schema is used across multiple services and resources, remember that other services may have restrictions on allowed characters. Generally allowed characters are: letters, numbers, and spaces representable in UTF-8, and the following characters: + - = . _ : /
taskDefinition?
Type:
string
(optional)
The family
and revision
( family:revision
) or full ARN of the task definition to run in your service.
If a revision
isn't specified, the latest ACTIVE
revision is used.
A task definition must be specified if the service uses either the ECS
or CODE_DEPLOY
deployment controllers.
For more information about deployment types, see Amazon ECS deployment types .
volumeConfigurations?
Type:
IResolvable
|
IResolvable
|
Service
[]
(optional)
The configuration for a volume specified in the task definition as a volume that is configured at launch time.
Currently, the only supported volume type is an Amazon EBS volume.
To remove this property from your service resource, specify an empty
ServiceVolumeConfiguration
array.
vpcLatticeConfigurations?
Type:
IResolvable
|
IResolvable
|
Vpc
[]
(optional)
The VPC Lattice configuration for the service being created.
Properties
Name | Type | Description |
---|---|---|
attr | string | The name of the Amazon ECS service, such as sample-webapp . |
attr | string | Not currently supported in AWS CloudFormation . |
cfn | ICfn | Options for this resource, such as condition, update policy etc. |
cfn | { [string]: any } | |
cfn | string | AWS resource type. |
creation | string[] | |
logical | string | The logical ID for this CloudFormation stack element. |
node | Node | The tree node. |
ref | string | Return a string that will be resolved to a CloudFormation { Ref } for this element. |
stack | Stack | The stack in which this element is defined. |
tags | Tag | Tag Manager which manages the tags for this resource. |
availability | string | Indicates whether to use Availability Zone rebalancing for the service. |
capacity | IResolvable | IResolvable | Capacity [] | The capacity provider strategy to use for the service. |
cluster? | string | The short name or full Amazon Resource Name (ARN) of the cluster that you run your service on. |
deployment | IResolvable | Deployment | Optional deployment parameters that control how many tasks run during the deployment and the ordering of stopping and starting tasks. |
deployment | IResolvable | Deployment | The deployment controller to use for the service. |
desired | number | The number of instantiations of the specified task definition to place and keep running in your service. |
enable | boolean | IResolvable | Specifies whether to turn on Amazon ECS managed tags for the tasks within the service. |
enable | boolean | IResolvable | Determines whether the execute command functionality is turned on for the service. |
health | number | The period of time, in seconds, that the Amazon ECS service scheduler ignores unhealthy Elastic Load Balancing, VPC Lattice, and container health checks after a task has first started. |
launch | string | The launch type on which to run your service. |
load | IResolvable | IResolvable | Load [] | A list of load balancer objects to associate with the service. |
network | IResolvable | Network | The network configuration for the service. |
placement | IResolvable | IResolvable | Placement [] | An array of placement constraint objects to use for tasks in your service. |
placement | IResolvable | IResolvable | Placement [] | The placement strategy objects to use for tasks in your service. |
platform | string | The platform version that your tasks in the service are running on. |
propagate | string | Specifies whether to propagate the tags from the task definition to the task. |
role? | string | The name or full Amazon Resource Name (ARN) of the IAM role that allows Amazon ECS to make calls to your load balancer on your behalf. |
scheduling | string | The scheduling strategy to use for the service. |
service | IResolvable | Service | The configuration for this service to discover and connect to services, and be discovered by, and connected from, other services within a namespace. |
service | string | The name of your service. |
service | IResolvable | IResolvable | Service [] | The details of the service discovery registry to associate with this service. |
tags | Cfn [] | The metadata that you apply to the service to help you categorize and organize them. |
task | string | The family and revision ( family:revision ) or full ARN of the task definition to run in your service. |
volume | IResolvable | IResolvable | Service [] | The configuration for a volume specified in the task definition as a volume that is configured at launch time. |
vpc | IResolvable | IResolvable | Vpc [] | The VPC Lattice configuration for the service being created. |
static CFN_RESOURCE_TYPE_NAME | string | The CloudFormation resource type name for this resource class. |
attrName
Type:
string
The name of the Amazon ECS service, such as sample-webapp
.
attrServiceArn
Type:
string
Not currently supported in AWS CloudFormation .
cfnOptions
Type:
ICfn
Options for this resource, such as condition, update policy etc.
cfnProperties
Type:
{ [string]: any }
cfnResourceType
Type:
string
AWS resource type.
creationStack
Type:
string[]
logicalId
Type:
string
The logical ID for this CloudFormation stack element.
The logical ID of the element is calculated from the path of the resource node in the construct tree.
To override this value, use overrideLogicalId(newLogicalId)
.
node
Type:
Node
The tree node.
ref
Type:
string
Return a string that will be resolved to a CloudFormation { Ref }
for this element.
If, by any chance, the intrinsic reference of a resource is not a string, you could
coerce it to an IResolvable through Lazy.any({ produce: resource.ref })
.
stack
Type:
Stack
The stack in which this element is defined.
CfnElements must be defined within a stack scope (directly or indirectly).
tags
Type:
Tag
Tag Manager which manages the tags for this resource.
availabilityZoneRebalancing?
Type:
string
(optional)
Indicates whether to use Availability Zone rebalancing for the service.
capacityProviderStrategy?
Type:
IResolvable
|
IResolvable
|
Capacity
[]
(optional)
The capacity provider strategy to use for the service.
cluster?
Type:
string
(optional)
The short name or full Amazon Resource Name (ARN) of the cluster that you run your service on.
deploymentConfiguration?
Type:
IResolvable
|
Deployment
(optional)
Optional deployment parameters that control how many tasks run during the deployment and the ordering of stopping and starting tasks.
deploymentController?
Type:
IResolvable
|
Deployment
(optional)
The deployment controller to use for the service.
desiredCount?
Type:
number
(optional)
The number of instantiations of the specified task definition to place and keep running in your service.
enableEcsManagedTags?
Type:
boolean |
IResolvable
(optional)
Specifies whether to turn on Amazon ECS managed tags for the tasks within the service.
enableExecuteCommand?
Type:
boolean |
IResolvable
(optional)
Determines whether the execute command functionality is turned on for the service.
healthCheckGracePeriodSeconds?
Type:
number
(optional)
The period of time, in seconds, that the Amazon ECS service scheduler ignores unhealthy Elastic Load Balancing, VPC Lattice, and container health checks after a task has first started.
launchType?
Type:
string
(optional)
The launch type on which to run your service.
loadBalancers?
Type:
IResolvable
|
IResolvable
|
Load
[]
(optional)
A list of load balancer objects to associate with the service.
networkConfiguration?
Type:
IResolvable
|
Network
(optional)
The network configuration for the service.
placementConstraints?
Type:
IResolvable
|
IResolvable
|
Placement
[]
(optional)
An array of placement constraint objects to use for tasks in your service.
placementStrategies?
Type:
IResolvable
|
IResolvable
|
Placement
[]
(optional)
The placement strategy objects to use for tasks in your service.
platformVersion?
Type:
string
(optional)
The platform version that your tasks in the service are running on.
propagateTags?
Type:
string
(optional)
Specifies whether to propagate the tags from the task definition to the task.
role?
Type:
string
(optional)
The name or full Amazon Resource Name (ARN) of the IAM role that allows Amazon ECS to make calls to your load balancer on your behalf.
schedulingStrategy?
Type:
string
(optional)
The scheduling strategy to use for the service.
For more information, see Services .
serviceConnectConfiguration?
Type:
IResolvable
|
Service
(optional)
The configuration for this service to discover and connect to services, and be discovered by, and connected from, other services within a namespace.
serviceName?
Type:
string
(optional)
The name of your service.
serviceRegistries?
Type:
IResolvable
|
IResolvable
|
Service
[]
(optional)
The details of the service discovery registry to associate with this service.
For more information, see Service discovery .
tagsRaw?
Type:
Cfn
[]
(optional)
The metadata that you apply to the service to help you categorize and organize them.
taskDefinition?
Type:
string
(optional)
The family
and revision
( family:revision
) or full ARN of the task definition to run in your service.
volumeConfigurations?
Type:
IResolvable
|
IResolvable
|
Service
[]
(optional)
The configuration for a volume specified in the task definition as a volume that is configured at launch time.
vpcLatticeConfigurations?
Type:
IResolvable
|
IResolvable
|
Vpc
[]
(optional)
The VPC Lattice configuration for the service being created.
static CFN_RESOURCE_TYPE_NAME
Type:
string
The CloudFormation resource type name for this resource class.
Methods
Name | Description |
---|---|
add | Syntactic sugar for addOverride(path, undefined) . |
add | Indicates that this resource depends on another resource and cannot be provisioned unless the other resource has been successfully provisioned. |
add | Indicates that this resource depends on another resource and cannot be provisioned unless the other resource has been successfully provisioned. |
add | Add a value to the CloudFormation Resource Metadata. |
add | Adds an override to the synthesized CloudFormation resource. |
add | Adds an override that deletes the value of a property from the resource definition. |
add | Adds an override to a resource property. |
apply | Sets the deletion policy of the resource based on the removal policy specified. |
get | Returns a token for an runtime attribute of this resource. |
get | Retrieve a value value from the CloudFormation Resource Metadata. |
inspect(inspector) | Examines the CloudFormation resource and discloses attributes. |
obtain | Retrieves an array of resources this resource depends on. |
obtain | Get a shallow copy of dependencies between this resource and other resources in the same stack. |
override | Overrides the auto-generated logical ID with a specific ID. |
remove | Indicates that this resource no longer depends on another resource. |
replace | Replaces one dependency with another. |
to | Returns a string representation of this construct. |
protected render |
addDeletionOverride(path)
public addDeletionOverride(path: string): void
Parameters
- path
string
— The path of the value to delete.
Syntactic sugar for addOverride(path, undefined)
.
addDependency(target)
public addDependency(target: CfnResource): void
Parameters
- target
Cfn
Resource
Indicates that this resource depends on another resource and cannot be provisioned unless the other resource has been successfully provisioned.
This can be used for resources across stacks (or nested stack) boundaries and the dependency will automatically be transferred to the relevant scope.
addDependsOn(target)
public addDependsOn(target: CfnResource): void
⚠️ Deprecated: use addDependency
Parameters
- target
Cfn
Resource
Indicates that this resource depends on another resource and cannot be provisioned unless the other resource has been successfully provisioned.
addMetadata(key, value)
public addMetadata(key: string, value: any): void
Parameters
- key
string
- value
any
Add a value to the CloudFormation Resource Metadata.
Note that this is a different set of metadata from CDK node metadata; this metadata ends up in the stack template under the resource, whereas CDK node metadata ends up in the Cloud Assembly.](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/metadata-section-structure.html
Note that this is a different set of metadata from CDK node metadata; this metadata ends up in the stack template under the resource, whereas CDK node metadata ends up in the Cloud Assembly.)
addOverride(path, value)
public addOverride(path: string, value: any): void
Parameters
- path
string
— - The path of the property, you can use dot notation to override values in complex types. - value
any
— - The value.
Adds an override to the synthesized CloudFormation resource.
To add a
property override, either use addPropertyOverride
or prefix path
with
"Properties." (i.e. Properties.TopicName
).
If the override is nested, separate each nested level using a dot (.) in the path parameter. If there is an array as part of the nesting, specify the index in the path.
To include a literal .
in the property name, prefix with a \
. In most
programming languages you will need to write this as "\\."
because the
\
itself will need to be escaped.
For example,
cfnResource.addOverride('Properties.GlobalSecondaryIndexes.0.Projection.NonKeyAttributes', ['myattribute']);
cfnResource.addOverride('Properties.GlobalSecondaryIndexes.1.ProjectionType', 'INCLUDE');
would add the overrides
"Properties": {
"GlobalSecondaryIndexes": [
{
"Projection": {
"NonKeyAttributes": [ "myattribute" ]
...
}
...
},
{
"ProjectionType": "INCLUDE"
...
},
]
...
}
The value
argument to addOverride
will not be processed or translated
in any way. Pass raw JSON values in here with the correct capitalization
for CloudFormation. If you pass CDK classes or structs, they will be
rendered with lowercased key names, and CloudFormation will reject the
template.
addPropertyDeletionOverride(propertyPath)
public addPropertyDeletionOverride(propertyPath: string): void
Parameters
- propertyPath
string
— The path to the property.
Adds an override that deletes the value of a property from the resource definition.
addPropertyOverride(propertyPath, value)
public addPropertyOverride(propertyPath: string, value: any): void
Parameters
- propertyPath
string
— The path of the property. - value
any
— The value.
Adds an override to a resource property.
Syntactic sugar for addOverride("Properties.<...>", value)
.
applyRemovalPolicy(policy?, options?)
public applyRemovalPolicy(policy?: RemovalPolicy, options?: RemovalPolicyOptions): void
Parameters
- policy
Removal
Policy - options
Removal
Policy Options
Sets the deletion policy of the resource based on the removal policy specified.
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.
The resource can be deleted (RemovalPolicy.DESTROY
), or left in your AWS
account for data recovery and cleanup later (RemovalPolicy.RETAIN
). In some
cases, a snapshot can be taken of the resource prior to deletion
(RemovalPolicy.SNAPSHOT
). A list of resources that support this policy
can be found in the following link:
getAtt(attributeName, typeHint?)
public getAtt(attributeName: string, typeHint?: ResolutionTypeHint): Reference
Parameters
- attributeName
string
— The name of the attribute. - typeHint
Resolution
Type Hint
Returns
Returns a token for an runtime attribute of this resource.
Ideally, use generated attribute accessors (e.g. resource.arn
), but this can be used for future compatibility
in case there is no generated attribute.
getMetadata(key)
public getMetadata(key: string): any
Parameters
- key
string
Returns
any
Retrieve a value value from the CloudFormation Resource Metadata.
Note that this is a different set of metadata from CDK node metadata; this metadata ends up in the stack template under the resource, whereas CDK node metadata ends up in the Cloud Assembly.](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/metadata-section-structure.html
Note that this is a different set of metadata from CDK node metadata; this metadata ends up in the stack template under the resource, whereas CDK node metadata ends up in the Cloud Assembly.)
inspect(inspector)
public inspect(inspector: TreeInspector): void
Parameters
- inspector
Tree
— tree inspector to collect and process attributes.Inspector
Examines the CloudFormation resource and discloses attributes.
obtainDependencies()
public obtainDependencies(): Stack | CfnResource[]
Returns
Stack
|
Cfn
Resource []
Retrieves an array of resources this resource depends on.
This assembles dependencies on resources across stacks (including nested stacks) automatically.
obtainResourceDependencies()
public obtainResourceDependencies(): CfnResource[]
Returns
Get a shallow copy of dependencies between this resource and other resources in the same stack.
overrideLogicalId(newLogicalId)
public overrideLogicalId(newLogicalId: string): void
Parameters
- newLogicalId
string
— The new logical ID to use for this stack element.
Overrides the auto-generated logical ID with a specific ID.
removeDependency(target)
public removeDependency(target: CfnResource): void
Parameters
- target
Cfn
Resource
Indicates that this resource no longer depends on another resource.
This can be used for resources across stacks (including nested stacks) and the dependency will automatically be removed from the relevant scope.
replaceDependency(target, newTarget)
public replaceDependency(target: CfnResource, newTarget: CfnResource): void
Parameters
- target
Cfn
— The dependency to replace.Resource - newTarget
Cfn
— The new dependency to add.Resource
Replaces one dependency with another.
toString()
public toString(): string
Returns
string
Returns a string representation of this construct.
protected renderProperties(props)
protected renderProperties(props: { [string]: any }): { [string]: any }
Parameters
- props
{ [string]: any }
Returns
{ [string]: any }