CfnCluster¶
-
class
aws_cdk.aws_ecs.
CfnCluster
(scope, id, *, capacity_providers=None, cluster_name=None, cluster_settings=None, configuration=None, default_capacity_provider_strategy=None, tags=None)¶ Bases:
aws_cdk.core.CfnResource
A CloudFormation
AWS::ECS::Cluster
.The
AWS::ECS::Cluster
resource creates an Amazon Elastic Container Service (Amazon ECS) cluster.- CloudformationResource
AWS::ECS::Cluster
- Link
http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ecs-cluster.html
- ExampleMetadata
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_ecs as ecs cfn_cluster = ecs.CfnCluster(self, "MyCfnCluster", capacity_providers=["capacityProviders"], cluster_name="clusterName", cluster_settings=[ecs.CfnCluster.ClusterSettingsProperty( name="name", value="value" )], configuration=ecs.CfnCluster.ClusterConfigurationProperty( execute_command_configuration=ecs.CfnCluster.ExecuteCommandConfigurationProperty( kms_key_id="kmsKeyId", log_configuration=ecs.CfnCluster.ExecuteCommandLogConfigurationProperty( cloud_watch_encryption_enabled=False, cloud_watch_log_group_name="cloudWatchLogGroupName", s3_bucket_name="s3BucketName", s3_encryption_enabled=False, s3_key_prefix="s3KeyPrefix" ), logging="logging" ) ), default_capacity_provider_strategy=[ecs.CfnCluster.CapacityProviderStrategyItemProperty( base=123, capacity_provider="capacityProvider", weight=123 )], tags=[CfnTag( key="key", value="value" )] )
Create a new
AWS::ECS::Cluster
.- Parameters
scope (
Construct
) –scope in which this resource is defined.
id (
str
) –scoped id of the resource.
capacity_providers (
Optional
[Sequence
[str
]]) – The short name of one or more capacity providers to associate with the cluster. A capacity provider must be associated with a cluster before it can be included as part of the default capacity provider strategy of the cluster or used in a capacity provider strategy. If specifying a capacity provider that uses an Auto Scaling group, the capacity provider must already be created and not already associated with another cluster. To use an AWS Fargate capacity provider, specify either theFARGATE
orFARGATE_SPOT
capacity providers. The AWS Fargate capacity providers are available to all accounts and only need to be associated with a cluster to be used.cluster_name (
Optional
[str
]) – A user-generated string that you use to identify your cluster. If you don’t specify a name, AWS CloudFormation generates a unique physical ID for the name.cluster_settings (
Union
[IResolvable
,Sequence
[Union
[IResolvable
,ClusterSettingsProperty
]],None
]) – The setting to use when creating a cluster. This parameter is used to enable CloudWatch Container Insights for a cluster. If this value is specified, it will override thecontainerInsights
value set with PutAccountSetting or PutAccountSettingDefault .configuration (
Union
[IResolvable
,ClusterConfigurationProperty
,None
]) – The execute command configuration for the cluster.default_capacity_provider_strategy (
Union
[IResolvable
,Sequence
[Union
[IResolvable
,CapacityProviderStrategyItemProperty
]],None
]) – The default capacity provider strategy for the cluster. When services or tasks are run in the cluster with no launch type or capacity provider strategy specified, the default capacity provider strategy is used.tags (
Optional
[Sequence
[CfnTag
]]) – The metadata that you apply to the cluster to help you categorize and organize them. Each tag consists of a key and an optional value. You define both. 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: + - = . _ : / @. - Tag keys and values are case-sensitive. - Do not useaws:
,AWS:
, or any upper or lowercase combination of such as a prefix for either keys or values as it is reserved for AWS use. You cannot edit or delete tag keys or values with this prefix. Tags with this prefix do not count against your tags per resource limit.
Methods
-
add_deletion_override
(path)¶ Syntactic sugar for
addOverride(path, undefined)
.- Parameters
path (
str
) – The path of the value to delete.- Return type
None
-
add_depends_on
(target)¶ 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.
- Parameters
target (
CfnResource
) –- Return type
None
-
add_metadata
(key, value)¶ Add a value to the CloudFormation Resource Metadata.
- Parameters
key (
str
) –value (
Any
) –
- See
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.
- Return type
None
-
add_override
(path, value)¶ Adds an override to the synthesized CloudFormation resource.
To add a property override, either use
addPropertyOverride
or prefixpath
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:
cfn_resource.add_override("Properties.GlobalSecondaryIndexes.0.Projection.NonKeyAttributes", ["myattribute"]) cfn_resource.add_override("Properties.GlobalSecondaryIndexes.1.ProjectionType", "INCLUDE")
would add the overrides Example:
"Properties": { "GlobalSecondaryIndexes": [ { "Projection": { "NonKeyAttributes": [ "myattribute" ] ... } ... }, { "ProjectionType": "INCLUDE" ... }, ] ... }
The
value
argument toaddOverride
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
path (
str
) –The path of the property, you can use dot notation to override values in complex types. Any intermdediate keys will be created as needed.
value (
Any
) –The value. Could be primitive or complex.
- Return type
None
-
add_property_deletion_override
(property_path)¶ Adds an override that deletes the value of a property from the resource definition.
- Parameters
property_path (
str
) – The path to the property.- Return type
None
-
add_property_override
(property_path, value)¶ Adds an override to a resource property.
Syntactic sugar for
addOverride("Properties.<...>", value)
.- Parameters
property_path (
str
) – The path of the property.value (
Any
) – The value.
- Return type
None
-
apply_removal_policy
(policy=None, *, apply_to_update_replace_policy=None, default=None)¶ 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
).- Parameters
policy (
Optional
[RemovalPolicy
]) –apply_to_update_replace_policy (
Optional
[bool
]) – Apply the same deletion policy to the resource’s “UpdateReplacePolicy”. Default: truedefault (
Optional
[RemovalPolicy
]) – The default policy to apply in case the removal policy is not defined. Default: - Default value is resource specific. To determine the default value for a resoure, please consult that specific resource’s documentation.
- Return type
None
-
get_att
(attribute_name)¶ 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.- Parameters
attribute_name (
str
) – The name of the attribute.- Return type
-
get_metadata
(key)¶ Retrieve a value value from the CloudFormation Resource Metadata.
- Parameters
key (
str
) –- See
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.
- Return type
Any
-
inspect
(inspector)¶ Examines the CloudFormation resource and discloses attributes.
- Parameters
inspector (
TreeInspector
) –tree inspector to collect and process attributes.
- Return type
None
-
override_logical_id
(new_logical_id)¶ Overrides the auto-generated logical ID with a specific ID.
- Parameters
new_logical_id (
str
) – The new logical ID to use for this stack element.- Return type
None
-
to_string
()¶ Returns a string representation of this construct.
- Return type
str
- Returns
a string representation of this resource
Attributes
-
CFN_RESOURCE_TYPE_NAME
= 'AWS::ECS::Cluster'¶
-
attr_arn
¶ The Amazon Resource Name (ARN) of the Amazon ECS cluster, such as
arn:aws:ecs:us-east-2:123456789012:cluster/MyECSCluster
.- CloudformationAttribute
Arn
- Return type
str
-
capacity_providers
¶ The short name of one or more capacity providers to associate with the cluster.
A capacity provider must be associated with a cluster before it can be included as part of the default capacity provider strategy of the cluster or used in a capacity provider strategy.
If specifying a capacity provider that uses an Auto Scaling group, the capacity provider must already be created and not already associated with another cluster.
To use an AWS Fargate capacity provider, specify either the
FARGATE
orFARGATE_SPOT
capacity providers. The AWS Fargate capacity providers are available to all accounts and only need to be associated with a cluster to be used.- Link
- Return type
Optional
[List
[str
]]
-
cfn_options
¶ Options for this resource, such as condition, update policy etc.
- Return type
-
cfn_resource_type
¶ AWS resource type.
- Return type
str
-
cluster_name
¶ A user-generated string that you use to identify your cluster.
If you don’t specify a name, AWS CloudFormation generates a unique physical ID for the name.
- Link
- Return type
Optional
[str
]
-
cluster_settings
¶ The setting to use when creating a cluster.
This parameter is used to enable CloudWatch Container Insights for a cluster. If this value is specified, it will override the
containerInsights
value set with PutAccountSetting or PutAccountSettingDefault .- Link
- Return type
Union
[IResolvable
,List
[Union
[IResolvable
,ClusterSettingsProperty
]],None
]
-
configuration
¶ The execute command configuration for the cluster.
-
creation_stack
¶ return:
the stack trace of the point where this Resource was created from, sourced from the +metadata+ entry typed +aws:cdk:logicalId+, and with the bottom-most node +internal+ entries filtered.
- Return type
List
[str
]
-
default_capacity_provider_strategy
¶ The default capacity provider strategy for the cluster.
When services or tasks are run in the cluster with no launch type or capacity provider strategy specified, the default capacity provider strategy is used.
-
logical_id
¶ 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)
.- Return type
str
- Returns
the logical ID as a stringified token. This value will only get resolved during synthesis.
-
node
¶ The construct tree node associated with this construct.
- Return type
-
ref
¶ 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 })
.- Return type
str
-
stack
¶ The stack in which this element is defined.
CfnElements must be defined within a stack scope (directly or indirectly).
- Return type
The metadata that you apply to the cluster to help you categorize and organize them.
Each tag consists of a key and an optional value. You define both.
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: + - = . _ : / @.
Tag keys and values are case-sensitive.
Do not use
aws:
,AWS:
, or any upper or lowercase combination of such as a prefix for either keys or values as it is reserved for AWS use. You cannot edit or delete tag keys or values with this prefix. Tags with this prefix do not count against your tags per resource limit.
Static Methods
-
classmethod
is_cfn_element
(x)¶ Returns
true
if a construct is a stack element (i.e. part of the synthesized cloudformation template).Uses duck-typing instead of
instanceof
to allow stack elements from different versions of this library to be included in the same stack.- Parameters
x (
Any
) –- Return type
bool
- Returns
The construct as a stack element or undefined if it is not a stack element.
-
classmethod
is_cfn_resource
(construct)¶ Check whether the given construct is a CfnResource.
- Parameters
construct (
IConstruct
) –- Return type
bool
-
classmethod
is_construct
(x)¶ Return whether the given object is a Construct.
- Parameters
x (
Any
) –- Return type
bool
CapacityProviderStrategyItemProperty¶
-
class
CfnCluster.
CapacityProviderStrategyItemProperty
(*, base=None, capacity_provider=None, weight=None)¶ Bases:
object
The
CapacityProviderStrategyItem
property specifies the details of the default capacity provider strategy for the cluster.When services or tasks are run in the cluster with no launch type or capacity provider strategy specified, the default capacity provider strategy is used.
- Parameters
base (
Union
[int
,float
,None
]) – The base value designates how many tasks, at a minimum, to run on the specified capacity provider. Only one capacity provider in a capacity provider strategy can have a base defined. If no value is specified, the default value of0
is used.capacity_provider (
Optional
[str
]) – The short name of the capacity provider.weight (
Union
[int
,float
,None
]) – The weight value designates the relative percentage of the total number of tasks launched that should use the specified capacity provider. Theweight
value is taken into consideration after thebase
value, if defined, is satisfied. If noweight
value is specified, the default value of0
is used. When multiple capacity providers are specified within a capacity provider strategy, at least one of the capacity providers must have a weight value greater than zero and any capacity providers with a weight of0
can’t be used to place tasks. If you specify multiple capacity providers in a strategy that all have a weight of0
, anyRunTask
orCreateService
actions using the capacity provider strategy will fail. An example scenario for using weights is defining a strategy that contains two capacity providers and both have a weight of1
, then when thebase
is satisfied, the tasks will be split evenly across the two capacity providers. Using that same logic, if you specify a weight of1
for capacityProviderA and a weight of4
for capacityProviderB , then for every one task that’s run using capacityProviderA , four tasks would use capacityProviderB .
- Link
- ExampleMetadata
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_ecs as ecs capacity_provider_strategy_item_property = ecs.CfnCluster.CapacityProviderStrategyItemProperty( base=123, capacity_provider="capacityProvider", weight=123 )
Attributes
-
base
¶ The base value designates how many tasks, at a minimum, to run on the specified capacity provider.
Only one capacity provider in a capacity provider strategy can have a base defined. If no value is specified, the default value of
0
is used.
-
capacity_provider
¶ The short name of the capacity provider.
-
weight
¶ The weight value designates the relative percentage of the total number of tasks launched that should use the specified capacity provider.
The
weight
value is taken into consideration after thebase
value, if defined, is satisfied.If no
weight
value is specified, the default value of0
is used. When multiple capacity providers are specified within a capacity provider strategy, at least one of the capacity providers must have a weight value greater than zero and any capacity providers with a weight of0
can’t be used to place tasks. If you specify multiple capacity providers in a strategy that all have a weight of0
, anyRunTask
orCreateService
actions using the capacity provider strategy will fail.An example scenario for using weights is defining a strategy that contains two capacity providers and both have a weight of
1
, then when thebase
is satisfied, the tasks will be split evenly across the two capacity providers. Using that same logic, if you specify a weight of1
for capacityProviderA and a weight of4
for capacityProviderB , then for every one task that’s run using capacityProviderA , four tasks would use capacityProviderB .
ClusterConfigurationProperty¶
-
class
CfnCluster.
ClusterConfigurationProperty
(*, execute_command_configuration=None)¶ Bases:
object
The execute command configuration for the cluster.
- Parameters
execute_command_configuration (
Union
[IResolvable
,ExecuteCommandConfigurationProperty
,None
]) – The details of the execute command configuration.- Link
- ExampleMetadata
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_ecs as ecs cluster_configuration_property = ecs.CfnCluster.ClusterConfigurationProperty( execute_command_configuration=ecs.CfnCluster.ExecuteCommandConfigurationProperty( kms_key_id="kmsKeyId", log_configuration=ecs.CfnCluster.ExecuteCommandLogConfigurationProperty( cloud_watch_encryption_enabled=False, cloud_watch_log_group_name="cloudWatchLogGroupName", s3_bucket_name="s3BucketName", s3_encryption_enabled=False, s3_key_prefix="s3KeyPrefix" ), logging="logging" ) )
Attributes
-
execute_command_configuration
¶ The details of the execute command configuration.
ClusterSettingsProperty¶
-
class
CfnCluster.
ClusterSettingsProperty
(*, name=None, value=None)¶ Bases:
object
The settings to use when creating a cluster.
This parameter is used to turn on CloudWatch Container Insights for a cluster.
- Parameters
name (
Optional
[str
]) – The name of the cluster setting. The only supported value iscontainerInsights
.value (
Optional
[str
]) –The value to set for the cluster setting. The supported values are
enabled
anddisabled
. Ifenabled
is specified, CloudWatch Container Insights will be enabled for the cluster, otherwise it will be disabled unless thecontainerInsights
account setting is enabled. If a cluster value is specified, it will override thecontainerInsights
value set with PutAccountSetting or PutAccountSettingDefault .
- Link
- ExampleMetadata
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_ecs as ecs cluster_settings_property = ecs.CfnCluster.ClusterSettingsProperty( name="name", value="value" )
Attributes
-
name
¶ The name of the cluster setting.
The only supported value is
containerInsights
.
-
value
¶ The value to set for the cluster setting.
The supported values are
enabled
anddisabled
. Ifenabled
is specified, CloudWatch Container Insights will be enabled for the cluster, otherwise it will be disabled unless thecontainerInsights
account setting is enabled. If a cluster value is specified, it will override thecontainerInsights
value set with PutAccountSetting or PutAccountSettingDefault .
ExecuteCommandConfigurationProperty¶
-
class
CfnCluster.
ExecuteCommandConfigurationProperty
(*, kms_key_id=None, log_configuration=None, logging=None)¶ Bases:
object
The details of the execute command configuration.
- Parameters
kms_key_id (
Optional
[str
]) – Specify an AWS Key Management Service key ID to encrypt the data between the local client and the container.log_configuration (
Union
[IResolvable
,ExecuteCommandLogConfigurationProperty
,None
]) – The log configuration for the results of the execute command actions. The logs can be sent to CloudWatch Logs or an Amazon S3 bucket. Whenlogging=OVERRIDE
is specified, alogConfiguration
must be provided.logging (
Optional
[str
]) – The log setting to use for redirecting logs for your execute command results. The following log settings are available. -NONE
: The execute command session is not logged. -DEFAULT
: Theawslogs
configuration in the task definition is used. If no logging parameter is specified, it defaults to this value. If noawslogs
log driver is configured in the task definition, the output won’t be logged. -OVERRIDE
: Specify the logging details as a part oflogConfiguration
. If theOVERRIDE
logging option is specified, thelogConfiguration
is required.
- Link
- ExampleMetadata
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_ecs as ecs execute_command_configuration_property = ecs.CfnCluster.ExecuteCommandConfigurationProperty( kms_key_id="kmsKeyId", log_configuration=ecs.CfnCluster.ExecuteCommandLogConfigurationProperty( cloud_watch_encryption_enabled=False, cloud_watch_log_group_name="cloudWatchLogGroupName", s3_bucket_name="s3BucketName", s3_encryption_enabled=False, s3_key_prefix="s3KeyPrefix" ), logging="logging" )
Attributes
-
kms_key_id
¶ Specify an AWS Key Management Service key ID to encrypt the data between the local client and the container.
-
log_configuration
¶ The log configuration for the results of the execute command actions.
The logs can be sent to CloudWatch Logs or an Amazon S3 bucket. When
logging=OVERRIDE
is specified, alogConfiguration
must be provided.
-
logging
¶ The log setting to use for redirecting logs for your execute command results. The following log settings are available.
NONE
: The execute command session is not logged.DEFAULT
: Theawslogs
configuration in the task definition is used. If no logging parameter is specified, it defaults to this value. If noawslogs
log driver is configured in the task definition, the output won’t be logged.OVERRIDE
: Specify the logging details as a part oflogConfiguration
. If theOVERRIDE
logging option is specified, thelogConfiguration
is required.
ExecuteCommandLogConfigurationProperty¶
-
class
CfnCluster.
ExecuteCommandLogConfigurationProperty
(*, cloud_watch_encryption_enabled=None, cloud_watch_log_group_name=None, s3_bucket_name=None, s3_encryption_enabled=None, s3_key_prefix=None)¶ Bases:
object
The log configuration for the results of the execute command actions.
The logs can be sent to CloudWatch Logs or an Amazon S3 bucket.
- Parameters
cloud_watch_encryption_enabled (
Union
[bool
,IResolvable
,None
]) – Determines whether to use encryption on the CloudWatch logs. If not specified, encryption will be disabled.cloud_watch_log_group_name (
Optional
[str
]) – The name of the CloudWatch log group to send logs to. .. epigraph:: The CloudWatch log group must already be created.s3_bucket_name (
Optional
[str
]) – The name of the S3 bucket to send logs to. .. epigraph:: The S3 bucket must already be created.s3_encryption_enabled (
Union
[bool
,IResolvable
,None
]) – Determines whether to use encryption on the S3 logs. If not specified, encryption is not used.s3_key_prefix (
Optional
[str
]) – An optional folder in the S3 bucket to place logs in.
- Link
- ExampleMetadata
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_ecs as ecs execute_command_log_configuration_property = ecs.CfnCluster.ExecuteCommandLogConfigurationProperty( cloud_watch_encryption_enabled=False, cloud_watch_log_group_name="cloudWatchLogGroupName", s3_bucket_name="s3BucketName", s3_encryption_enabled=False, s3_key_prefix="s3KeyPrefix" )
Attributes
-
cloud_watch_encryption_enabled
¶ Determines whether to use encryption on the CloudWatch logs.
If not specified, encryption will be disabled.
-
cloud_watch_log_group_name
¶ The name of the CloudWatch log group to send logs to.
The CloudWatch log group must already be created.
-
s3_bucket_name
¶ The name of the S3 bucket to send logs to.
The S3 bucket must already be created.
-
s3_encryption_enabled
¶ Determines whether to use encryption on the S3 logs.
If not specified, encryption is not used.
-
s3_key_prefix
¶ An optional folder in the S3 bucket to place logs in.