CfnService L1 construct
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
ServiceConnectConfigurationproperty is configured. This is because AWS CloudFormation creates the replacement service first, but eachServiceConnectServicemust 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. > On June 12, 2025, Amazon ECS launched support for updating capacity provider configuration for Amazon ECS services. With this launch, Amazon ECS also aligned the CloudFormation update behavior forCapacityProviderStrategyparameter with the standard practice. For more information, see Amazon ECS adds support for updating capacity provider configuration for ECS services . Previously Amazon ECS ignored theCapacityProviderStrategyproperty if it was set to an empty list for example,[]in CloudFormation , because updating capacity provider configuration was not supported. Now, with support for capacity provider updates, customers can remove capacity providers from a service by passing an empty list. When you specify an empty list ([]) for theCapacityProviderStrategyproperty in your CloudFormation template, Amazon ECS will remove any capacity providers associated with the service, as follows:
For services created with a capacity provider strategy after the launch:
If there's a cluster default strategy set, the service will revert to using that default strategy.
If no cluster default strategy exists, you will receive the following error:
No launch type to fall back to for empty capacity provider strategy. Your service was not created with a launch type.
For services created with a capacity provider strategy prior to the launch:
If
CapacityProviderStrategyhadFARGATE_SPOTorFARGATEcapacity providers, the launch type will be updated toFARGATEand the capacity provider will be removed.If the strategy included Auto Scaling group capacity providers, the service will revert to EC2 launch type, and the Auto Scaling group capacity providers will not be used.
Recommended Actions
If you are currently using
CapacityProviderStrategy: []in your CloudFormation templates, you should take one of the following actions:
If you do not intend to update the Capacity Provider Strategy:
Remove the
CapacityProviderStrategyproperty entirely from your CloudFormation templateAlternatively, use
!Ref AWS ::NoValuefor theCapacityProviderStrategyproperty in your templateIf you intend to maintain or update the Capacity Provider Strategy, specify the actual Capacity Provider Strategy for the service in your CloudFormation template.
If your CloudFormation template had an empty list ([]) for
CapacityProviderStrategyprior to the aforementioned launch on June 12, and you are using the same template withCapacityProviderStrategy: [], you might encounter the following error:Invalid request provided: When switching from launch type to capacity provider strategy on an existing service, or making a change to a capacity provider strategy on a service that is already using one, you must force a new deployment. (Service: Ecs, Status Code: 400, Request ID: xxx) (SDK Attempt Count: 1)" (RequestToken: xxx HandlerErrorCode: InvalidRequest)
Note that CloudFormation automatically initiates a new deployment when it detects a parameter change, but customers cannot choose to force a deployment through CloudFormation . This is an invalid input scenario that requires one of the remediation actions listed above.
If you are experiencing active production issues related to this change, contact AWS Support or your Technical Account Manager.
Example
declare const cluster: ecs.Cluster;
declare const taskDefinition: ecs.TaskDefinition;
declare const miCapacityProvider: ecs.ManagedInstancesCapacityProvider;
const service = new ecs.FargateService(this, 'Service', {
cluster,
taskDefinition,
capacityProviderStrategies: [
{
capacityProvider: miCapacityProvider.capacityProviderName,
weight: 1,
},
],
});
// Escape hatch: Force launchType at the CloudFormation level to prevent service replacement
const cfnService = service.node.defaultChild as ecs.CfnService;
cfnService.launchType = 'FARGATE'; // or 'FARGATE_SPOT' depending on your capacity provider
# cluster: ecs.Cluster
# task_definition: ecs.TaskDefinition
# mi_capacity_provider: ecs.ManagedInstancesCapacityProvider
service = ecs.FargateService(self, "Service",
cluster=cluster,
task_definition=task_definition,
capacity_provider_strategies=[ecs.CapacityProviderStrategy(
capacity_provider=mi_capacity_provider.capacity_provider_name,
weight=1
)
]
)
# Escape hatch: Force launchType at the CloudFormation level to prevent service replacement
cfn_service = service.node.default_child
cfn_service.launch_type = "FARGATE"
Cluster cluster;
TaskDefinition taskDefinition;
ManagedInstancesCapacityProvider miCapacityProvider;
FargateService service = FargateService.Builder.create(this, "Service")
.cluster(cluster)
.taskDefinition(taskDefinition)
.capacityProviderStrategies(List.of(CapacityProviderStrategy.builder()
.capacityProvider(miCapacityProvider.getCapacityProviderName())
.weight(1)
.build()))
.build();
// Escape hatch: Force launchType at the CloudFormation level to prevent service replacement
CfnService cfnService = (CfnService)service.getNode().getDefaultChild();
cfnService.getLaunchType() = "FARGATE";
// Install: dotnet add package Amazon.CDK.Lib
Cluster cluster;
TaskDefinition taskDefinition;
ManagedInstancesCapacityProvider miCapacityProvider;
var service = new FargateService(this, "Service", new FargateServiceProps {
Cluster = cluster,
TaskDefinition = taskDefinition,
CapacityProviderStrategies = new [] { new CapacityProviderStrategy {
CapacityProvider = miCapacityProvider.CapacityProviderName,
Weight = 1
} }
});
// Escape hatch: Force launchType at the CloudFormation level to prevent service replacement
var cfnService = (CfnService)service.Node.DefaultChild;
cfnService.LaunchType = "FARGATE";
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var cluster Cluster
var taskDefinition TaskDefinition
var miCapacityProvider ManagedInstancesCapacityProvider
service := ecs.NewFargateService(this, jsii.String("Service"), &FargateServiceProps{
Cluster: Cluster,
TaskDefinition: TaskDefinition,
CapacityProviderStrategies: []CapacityProviderStrategy{
&CapacityProviderStrategy{
CapacityProvider: miCapacityProvider.CapacityProviderName,
Weight: jsii.Number(1),
},
},
})
// Escape hatch: Force launchType at the CloudFormation level to prevent service replacement
cfnService := service.Node.defaultChild.(CfnService)
cfnService.launchType = "FARGATE"
Initializer
new CfnService(scope: Construct, id: string, props?: CfnServiceProps)
CfnService(scope: Construct, id: str, props: typing.Optional[CfnServiceProps] = None)
new CfnService(Construct scope, String id, CfnServiceProps props)
new CfnService(Construct scope, string id, CfnServiceProps? props = null)
NewCfnService(Scope Construct, Id *string, Props CfnServiceProps)
Construct Props
availabilityZoneRebalancingstringavailability_zone_rebalancingstravailabilityZoneRebalancingStringAvailabilityZoneRebalancingstringAvailabilityZoneRebalancing*string= "ENABLED"#notes
For more information, see Balancing an Amazon ECS service across Availability Zones in the Amazon Elastic Container Service Developer Guide .
The default behavior of AvailabilityZoneRebalancing differs between create and update requests:
- For create service requests, when no value is specified for
AvailabilityZoneRebalancing, Amazon ECS defaults the value toENABLED. - For update service requests, when no value is specified for
AvailabilityZoneRebalancing, Amazon ECS defaults to the existing service’sAvailabilityZoneRebalancingvalue. If the service never had anAvailabilityZoneRebalancingvalue set, Amazon ECS treats this asDISABLED.
capacityProviderStrategyIResolvable | IResolvable | CfnService.CapacityProviderStrategyItemProperty[]capacity_provider_strategytyping.Union[IResolvable, typing.List[typing.Union[IResolvable, CapacityProviderStrategyItemProperty]]]capacityProviderStrategyIResolvableCapacityProviderStrategyIResolvableCapacityProviderStrategyinterface{}#notes
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 can contain a maximum of 20 capacity providers.
To remove this property from your service resource, specify an empty
CapacityProviderStrategyItemarray.
clusterstring | IClusterRefclustertyping.Union[str, IClusterRef]clusterStringClusterstringClusterinterface{}#If you do not specify a cluster, the default cluster is assumed.
deploymentConfigurationIResolvable | CfnService.DeploymentConfigurationPropertydeployment_configurationtyping.Union[IResolvable, DeploymentConfigurationProperty]deploymentConfigurationIResolvableDeploymentConfigurationIResolvableDeploymentConfigurationinterface{}#deploymentControllerIResolvable | CfnService.DeploymentControllerPropertydeployment_controllertyping.Union[IResolvable, DeploymentControllerProperty]deploymentControllerIResolvableDeploymentControllerIResolvableDeploymentControllerinterface{}#notes
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.
enableEcsManagedTagsboolean | IResolvableenable_ecs_managed_tagstyping.Union[bool, IResolvable]enableEcsManagedTagsBooleanEnableEcsManagedTagsboolEnableEcsManagedTagsinterface{}#notes
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 must set the propagateTags request parameter.
enableExecuteCommandboolean | IResolvableenable_execute_commandtyping.Union[bool, IResolvable]enableExecuteCommandBooleanEnableExecuteCommandboolEnableExecuteCommandinterface{}#If true , the execute command functionality is turned on for all containers in tasks as part of the service.
forceNewDeploymentIResolvable | CfnService.ForceNewDeploymentPropertyforce_new_deploymenttyping.Union[IResolvable, ForceNewDeploymentProperty]forceNewDeploymentIResolvableForceNewDeploymentIResolvableForceNewDeploymentinterface{}#notes
By default, deployments aren't forced. You can use this option to start a new deployment with no service definition changes. For example, you can update a service's tasks to use a newer Docker image with the same image/tag combination ( my_image:latest ) or to roll Fargate tasks onto a newer platform version.
healthCheckGracePeriodSecondsnumberhealth_check_grace_period_secondsint | floathealthCheckGracePeriodSecondsNumberHealthCheckGracePeriodSecondsdoubleHealthCheckGracePeriodSeconds*float64#notes
If you do not specify a health check grace period value, the default value of 0 is used. If you do not use any of the health checks, then healthCheckGracePeriodSeconds is unused.
If your service has more running tasks than desired, unhealthy tasks in the grace period might be stopped to reach the desired count.
notes
For more information, see Amazon ECS Launch Types in the Amazon Elastic Container Service Developer Guide .
If you want to use Managed Instances, you must use the
capacityProviderStrategyrequest parameter
loadBalancersIResolvable | IResolvable | CfnService.LoadBalancerProperty[]load_balancerstyping.Union[IResolvable, typing.List[typing.Union[IResolvable, LoadBalancerProperty]]]loadBalancersIResolvableLoadBalancersIResolvableLoadBalancersinterface{}#notes
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
LoadBalancerarray.
monitoringIResolvable | CfnService.MonitoringConfigurationPropertymonitoringtyping.Union[IResolvable, MonitoringConfigurationProperty]monitoringIResolvableMonitoringIResolvableMonitoringinterface{}#When not specified, Amazon ECS uses the default resolution of 60 seconds.
networkConfigurationIResolvable | CfnService.NetworkConfigurationPropertynetwork_configurationtyping.Union[IResolvable, NetworkConfigurationProperty]networkConfigurationIResolvableNetworkConfigurationIResolvableNetworkConfigurationinterface{}#notes
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 .
placementConstraintsIResolvable | IResolvable | CfnService.PlacementConstraintProperty[]placement_constraintstyping.Union[IResolvable, typing.List[typing.Union[IResolvable, PlacementConstraintProperty]]]placementConstraintsIResolvablePlacementConstraintsIResolvablePlacementConstraintsinterface{}#notes
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
PlacementConstraintarray.
placementStrategiesIResolvable | IResolvable | CfnService.PlacementStrategyProperty[]placement_strategiestyping.Union[IResolvable, typing.List[typing.Union[IResolvable, PlacementStrategyProperty]]]placementStrategiesIResolvablePlacementStrategiesIResolvablePlacementStrategiesinterface{}#You can specify a maximum of 5 strategy rules for each service.
To remove this property from your service resource, specify an empty
PlacementStrategyarray.
platformVersionstringplatform_versionstrplatformVersionStringPlatformVersionstringPlatformVersion*string= "LATEST"#notes
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 .
notes
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 .
notes
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
awsvpcnetwork 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 .
schedulingStrategystringscheduling_strategystrschedulingStrategyStringSchedulingStrategystringSchedulingStrategy*string#notes
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_DEPLOYorEXTERNALdeployment 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_DEPLOYorEXTERNALdeployment controller types don't support theDAEMONscheduling strategy.
serviceConnectConfigurationIResolvable | CfnService.ServiceConnectConfigurationPropertyservice_connect_configurationtyping.Union[IResolvable, ServiceConnectConfigurationProperty]serviceConnectConfigurationIResolvableServiceConnectConfigurationIResolvableServiceConnectConfigurationinterface{}#notes
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 .
notes
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
ServiceNameis configured. This is because AWS CloudFormation creates the replacement service first, but eachServiceNamemust be unique in the cluster.
serviceRegistriesIResolvable | IResolvable | CfnService.ServiceRegistryProperty[]service_registriestyping.Union[IResolvable, typing.List[typing.Union[IResolvable, ServiceRegistryProperty]]]serviceRegistriesIResolvableServiceRegistriesIResolvableServiceRegistriesinterface{}#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
ServiceRegistryarray.
notes
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: + - = . _ : /
taskDefinitionstring | ITaskDefinitionReftask_definitiontyping.Union[str, ITaskDefinitionRef]taskDefinitionStringTaskDefinitionstringTaskDefinitioninterface{}#notes
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 .
volumeConfigurationsIResolvable | IResolvable | CfnService.ServiceVolumeConfigurationProperty[]volume_configurationstyping.Union[IResolvable, typing.List[typing.Union[IResolvable, ServiceVolumeConfigurationProperty]]]volumeConfigurationsIResolvableVolumeConfigurationsIResolvableVolumeConfigurationsinterface{}#Currently, the only supported volume type is an Amazon EBS volume.
To remove this property from your service resource, specify an empty
ServiceVolumeConfigurationarray.
vpcLatticeConfigurationsIResolvable | IResolvable | CfnService.VpcLatticeConfigurationProperty[]vpc_lattice_configurationstyping.Union[IResolvable, typing.List[typing.Union[IResolvable, VpcLatticeConfigurationProperty]]]vpcLatticeConfigurationsIResolvableVpcLatticeConfigurationsIResolvableVpcLatticeConfigurationsinterface{}#Properties
attrServiceArnstringattr_service_arnstrattrServiceArnStringAttrServiceArnstringAttrServiceArn*stringrequired#For more information about the ARN format, see Amazon Resource Name (ARN) in the Amazon ECS Developer Guide .
availabilityZoneRebalancingstringavailability_zone_rebalancingstravailabilityZoneRebalancingStringAvailabilityZoneRebalancingstringAvailabilityZoneRebalancing*string#capacityProviderStrategyIResolvable | IResolvable | CfnService.CapacityProviderStrategyItemProperty[]capacity_provider_strategytyping.Union[IResolvable, typing.List[typing.Union[IResolvable, CapacityProviderStrategyItemProperty]]]capacityProviderStrategyIResolvableCapacityProviderStrategyIResolvableCapacityProviderStrategyinterface{}#CFN_RESOURCE_TYPE_NAMEstringcfn_resource_type_namestrCFN_RESOURCE_TYPE_NAMEStringCFN_RESOURCE_TYPE_NAMEstringCFN_RESOURCE_TYPE_NAME*stringrequiredstatic#cfnOptionsICfnResourceOptionscfn_optionsICfnResourceOptionscfnOptionsICfnResourceOptionsCfnOptionsICfnResourceOptionsCfnOptionsICfnResourceOptionsrequired#cfnResourceTypestringcfn_resource_typestrcfnResourceTypeStringCfnResourceTypestringCfnResourceType*stringrequired#creationStackstring[]creation_stacktyping.List[str]creationStackList<String>CreationStackstring[]CreationStack*[]*stringrequired#deploymentConfigurationIResolvable | CfnService.DeploymentConfigurationPropertydeployment_configurationtyping.Union[IResolvable, DeploymentConfigurationProperty]deploymentConfigurationIResolvableDeploymentConfigurationIResolvableDeploymentConfigurationinterface{}#deploymentControllerIResolvable | CfnService.DeploymentControllerPropertydeployment_controllertyping.Union[IResolvable, DeploymentControllerProperty]deploymentControllerIResolvableDeploymentControllerIResolvableDeploymentControllerinterface{}#enableEcsManagedTagsboolean | IResolvableenable_ecs_managed_tagstyping.Union[bool, IResolvable]enableEcsManagedTagsBooleanEnableEcsManagedTagsboolEnableEcsManagedTagsinterface{}#enableExecuteCommandboolean | IResolvableenable_execute_commandtyping.Union[bool, IResolvable]enableExecuteCommandBooleanEnableExecuteCommandboolEnableExecuteCommandinterface{}#forceNewDeploymentIResolvable | CfnService.ForceNewDeploymentPropertyforce_new_deploymenttyping.Union[IResolvable, ForceNewDeploymentProperty]forceNewDeploymentIResolvableForceNewDeploymentIResolvableForceNewDeploymentinterface{}#healthCheckGracePeriodSecondsnumberhealth_check_grace_period_secondsint | floathealthCheckGracePeriodSecondsNumberHealthCheckGracePeriodSecondsdoubleHealthCheckGracePeriodSeconds*float64#loadBalancersIResolvable | IResolvable | CfnService.LoadBalancerProperty[]load_balancerstyping.Union[IResolvable, typing.List[typing.Union[IResolvable, LoadBalancerProperty]]]loadBalancersIResolvableLoadBalancersIResolvableLoadBalancersinterface{}#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).
monitoringIResolvable | CfnService.MonitoringConfigurationPropertymonitoringtyping.Union[IResolvable, MonitoringConfigurationProperty]monitoringIResolvableMonitoringIResolvableMonitoringinterface{}#networkConfigurationIResolvable | CfnService.NetworkConfigurationPropertynetwork_configurationtyping.Union[IResolvable, NetworkConfigurationProperty]networkConfigurationIResolvableNetworkConfigurationIResolvableNetworkConfigurationinterface{}#placementConstraintsIResolvable | IResolvable | CfnService.PlacementConstraintProperty[]placement_constraintstyping.Union[IResolvable, typing.List[typing.Union[IResolvable, PlacementConstraintProperty]]]placementConstraintsIResolvablePlacementConstraintsIResolvablePlacementConstraintsinterface{}#placementStrategiesIResolvable | IResolvable | CfnService.PlacementStrategyProperty[]placement_strategiestyping.Union[IResolvable, typing.List[typing.Union[IResolvable, PlacementStrategyProperty]]]placementStrategiesIResolvablePlacementStrategiesIResolvablePlacementStrategiesinterface{}#platformVersionstringplatform_versionstrplatformVersionStringPlatformVersionstringPlatformVersion*string#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 }).
schedulingStrategystringscheduling_strategystrschedulingStrategyStringSchedulingStrategystringSchedulingStrategy*string#For more information, see Services .
serviceConnectConfigurationIResolvable | CfnService.ServiceConnectConfigurationPropertyservice_connect_configurationtyping.Union[IResolvable, ServiceConnectConfigurationProperty]serviceConnectConfigurationIResolvableServiceConnectConfigurationIResolvableServiceConnectConfigurationinterface{}#serviceRefServiceReferenceservice_refServiceReferenceserviceRefServiceReferenceServiceRefServiceReferenceServiceRefServiceReferencerequired#serviceRegistriesIResolvable | IResolvable | CfnService.ServiceRegistryProperty[]service_registriestyping.Union[IResolvable, typing.List[typing.Union[IResolvable, ServiceRegistryProperty]]]serviceRegistriesIResolvableServiceRegistriesIResolvableServiceRegistriesinterface{}#For more information, see Service discovery .
CfnElements must be defined within a stack scope (directly or indirectly).
taskDefinitionstringtask_definitionstrtaskDefinitionStringTaskDefinitionstringTaskDefinition*string#volumeConfigurationsIResolvable | IResolvable | CfnService.ServiceVolumeConfigurationProperty[]volume_configurationstyping.Union[IResolvable, typing.List[typing.Union[IResolvable, ServiceVolumeConfigurationProperty]]]volumeConfigurationsIResolvableVolumeConfigurationsIResolvableVolumeConfigurationsinterface{}#vpcLatticeConfigurationsIResolvable | IResolvable | CfnService.VpcLatticeConfigurationProperty[]vpc_lattice_configurationstyping.Union[IResolvable, typing.List[typing.Union[IResolvable, VpcLatticeConfigurationProperty]]]vpcLatticeConfigurationsIResolvableVpcLatticeConfigurationsIResolvableVpcLatticeConfigurationsinterface{}#Methods
addDeletionOverride(path: string): voiddef add_deletion_override(self, path: str) -> Nonepublic void addDeletionOverride(String path)public void AddDeletionOverride(string path)func AddDeletionOverride(Path *string)#1 parameter
Parameters
pathpathpathpathPath— The path of the value to delete.
addDependency(target: CfnResource): voiddef add_dependency(self, target: CfnResource) -> Nonepublic void addDependency(CfnResource target)public void AddDependency(CfnResource target)func AddDependency(Target CfnResource)deprecated#This method has been renamed to addResourceDependency to more clearly set it apart from construct.node.addDependency. See the documentation of that function for more details.
addDependsOn(target: CfnResource): voiddef add_depends_on(self, target: CfnResource) -> Nonepublic void addDependsOn(CfnResource target)public void AddDependsOn(CfnResource target)func AddDependsOn(Target CfnResource)deprecated#notes
This can be used for resources across stacks (or nested stack) boundaries and the dependency will automatically be transferred to the relevant scope.
This method has been renamed to addResourceDependency, which makes it more clear that this method operates at a different level from the construct-level construct.node.addDependency() mechanism.
addMetadata(key: string, value: any): voiddef add_metadata(self, key: str, value: Any) -> Nonepublic void addMetadata(String key, Object value)public void AddMetadata(string key, object value)func AddMetadata(Key *string, Value interface{})#addOverride(path: string, value: any): voiddef add_override(self, path: str, value: Any) -> Nonepublic void addOverride(String path, Object value)public void AddOverride(string path, object value)func AddOverride(Path *string, Value interface{})#notes · 2 parameters
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.
Parameters
pathpathpathpathPath— - The path of the property, you can use dot notation to override values in complex types.valuevaluevaluevalueValue— - The value.
addPropertyDeletionOverride(propertyPath: string): voiddef add_property_deletion_override(self, property_path: str) -> Nonepublic void addPropertyDeletionOverride(String propertyPath)public void AddPropertyDeletionOverride(string propertyPath)func AddPropertyDeletionOverride(PropertyPath *string)#1 parameter
Parameters
propertyPathproperty_pathpropertyPathpropertyPathPropertyPath— The path to the property.
addPropertyOverride(propertyPath: string, value: any): voiddef add_property_override(self, property_path: str, value: Any) -> Nonepublic void addPropertyOverride(String propertyPath, Object value)public void AddPropertyOverride(string propertyPath, object value)func AddPropertyOverride(PropertyPath *string, Value interface{})#Syntactic sugar for addOverride("Properties.<...>", value).
2 parameters
Parameters
propertyPathproperty_pathpropertyPathpropertyPathPropertyPath— The path of the property.valuevaluevaluevalueValue— The value.
addResourceDependency(target: CfnResource, reason?: string): voiddef add_resource_dependency(self, target: CfnResource, reason: typing.Optional[str] = None) -> Nonepublic void addResourceDependency(CfnResource target, String reason)public void AddResourceDependency(CfnResource target, string? reason = null)func AddResourceDependency(Target CfnResource, Reason *string)#notes
This can be used for resources across stacks (or nested stack) boundaries and the dependency will automatically be transferred to the relevant scope.
This method only adds dependencies between L1 resources. If you are looking for a generic construct-to-construct dependency mechanism that works for all constructs including L2s, use construct.node.addDependency instead.
applyCrossStackReferenceStrength(strength: ReferenceStrength): voiddef apply_cross_stack_reference_strength(self, strength: ReferenceStrength) -> Nonepublic void applyCrossStackReferenceStrength(ReferenceStrength strength)public void ApplyCrossStackReferenceStrength(ReferenceStrength strength)func ApplyCrossStackReferenceStrength(Strength ReferenceStrength)#When set, any cross-stack reference to this resource will use the specified strength instead of the global default from the consuming stack's context.
1 parameter
Parameters
strengthstrengthstrengthstrengthStrength— - The reference strength to use for this resource.
applyRemovalPolicy(policy?: RemovalPolicy, options?: RemovalPolicyOptions): voiddef apply_removal_policy(self, policy: typing.Optional[RemovalPolicy] = None, options: typing.Optional[RemovalPolicyOptions] = None) -> Nonepublic void applyRemovalPolicy(RemovalPolicy policy, RemovalPolicyOptions options)public void ApplyRemovalPolicy(RemovalPolicy? policy = null, RemovalPolicyOptions? options = null)func ApplyRemovalPolicy(Policy RemovalPolicy, Options RemovalPolicyOptions)#notes
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:
arnForService(resource: IServiceRef): string@staticmethod def arn_for_service(resource: IServiceRef) -> strpublic static String arnForService(IServiceRef resource)public static string ArnForService(IServiceRef resource)func ArnForService(Resource IServiceRef) *stringstatic#cfnPropertyName(cdkPropertyName: string): stringdef cfn_property_name(self, cdk_property_name: str) -> strpublic String cfnPropertyName(String cdkPropertyName)public string CfnPropertyName(string cdkPropertyName)func CfnPropertyName(CdkPropertyName *string) *string#getAtt(attributeName: string, typeHint?: ResolutionTypeHint): Referencedef get_att(self, attribute_name: str, type_hint: typing.Optional[ResolutionTypeHint] = None) -> Referencepublic Reference getAtt(String attributeName, ResolutionTypeHint typeHint)public Reference GetAtt(string attributeName, ResolutionTypeHint? typeHint = null)func GetAtt(AttributeName *string, TypeHint ResolutionTypeHint) Reference#Ideally, use generated attribute accessors (e.g. resource.arn), but this can be used for future compatibility in case there is no generated attribute.
1 parameter
Parameters
attributeNameattribute_nameattributeNameattributeNameAttributeName— The name of the attribute.
getMetadata(key: string): anydef get_metadata(self, key: str) -> Anypublic Object getMetadata(String key)public object GetMetadata(string key)func GetMetadata(Key *string) interface{}#inspect(inspector: TreeInspector): voiddef inspect(self, inspector: TreeInspector) -> Nonepublic void inspect(TreeInspector inspector)public void Inspect(TreeInspector inspector)func Inspect(Inspector TreeInspector)#1 parameter
Parameters
inspectorinspectorinspectorinspectorInspector— tree inspector to collect and process attributes.
isCfnElement(x: any): boolean@staticmethod def is_cfn_element(x: Any) -> boolpublic static Boolean isCfnElement(Object x)public static bool IsCfnElement(object x)func IsCfnElement(X interface{}) *boolstatic#Uses duck-typing instead of instanceof to allow stack elements from different versions of this library to be included in the same stack.
returns
Returns: The construct as a stack element or undefined if it is not a stack element.
isCfnResource(x: any): boolean@staticmethod def is_cfn_resource(x: Any) -> boolpublic static Boolean isCfnResource(Object x)public static bool IsCfnResource(object x)func IsCfnResource(X interface{}) *boolstatic#isCfnService(x: any): boolean@staticmethod def is_cfn_service(x: Any) -> boolpublic static Boolean isCfnService(Object x)public static bool IsCfnService(object x)func IsCfnService(X interface{}) *boolstatic#isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#notes · 1 parameter · returns
Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.
Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.
Parameters
xxxxX— Any object.
Returns: true if x is an object created from a class which extends Construct.
obtainDependencies(): Stack | CfnResource[]def obtain_dependencies(self, ) -> typing.List[typing.Union[Stack, CfnResource]]public List<Stack> obtainDependencies()public Stack[] ObtainDependencies()func ObtainDependencies() *[]interface{}#For resources depended on directly, returns the CfnResource object. For dependencies on other stacks, returns the Stack object. The order of the array is not guaranteed.
overrideLogicalId(newLogicalId: string): voiddef override_logical_id(self, new_logical_id: str) -> Nonepublic void overrideLogicalId(String newLogicalId)public void OverrideLogicalId(string newLogicalId)func OverrideLogicalId(NewLogicalId *string)#1 parameter
Parameters
newLogicalIdnew_logical_idnewLogicalIdnewLogicalIdNewLogicalId— The new logical ID to use for this stack element.
removeDependency(target: CfnResource): voiddef remove_dependency(self, target: CfnResource) -> Nonepublic void removeDependency(CfnResource target)public void RemoveDependency(CfnResource target)func RemoveDependency(Target CfnResource)deprecated#This can be used for resources across stacks (including nested stacks) and the dependency will automatically be removed from the relevant scope.
removeResourceDependency(target: CfnResource): voiddef remove_resource_dependency(self, target: CfnResource) -> Nonepublic void removeResourceDependency(CfnResource target)public void RemoveResourceDependency(CfnResource target)func RemoveResourceDependency(Target CfnResource)#This can be used for resources across stacks (including nested stacks) and the dependency will automatically be removed from the relevant scope.
replaceDependency(target: CfnResource, newTarget: CfnResource): voiddef replace_dependency(self, target: CfnResource, new_target: CfnResource) -> Nonepublic void replaceDependency(CfnResource target, CfnResource newTarget)public void ReplaceDependency(CfnResource target, CfnResource newTarget)func ReplaceDependency(Target CfnResource, NewTarget CfnResource)#2 parameters
Parameters
targettargettargettargetTarget— The dependency to replace.newTargetnew_targetnewTargetnewTargetNewTarget— The new dependency to add.
toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#returns
Returns: a string representation of this resource
with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.