Resource: awsEcsCluster
Provides an ECS cluster.
\~> NOTE on Clusters and Cluster Capacity Providers: Terraform provides both a standalone awsEcsClusterCapacityProviders
resource, as well as allowing the capacity providers and default strategies to be managed in-line by the awsEcsCluster
resource. You cannot use a Cluster with in-line capacity providers in conjunction with the Capacity Providers resource, nor use more than one Capacity Providers resource with a single Cluster, as doing so will cause a conflict and will lead to mutual overwrites.
Example Usage
/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.ecsCluster.EcsCluster(this, "foo", {
name: "white-hart",
setting: [
{
name: "containerInsights",
value: "enabled",
},
],
});
Example with Log Configuration
/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
const awsCloudwatchLogGroupExample =
new aws.cloudwatchLogGroup.CloudwatchLogGroup(this, "example", {
name: "example",
});
const awsKmsKeyExample = new aws.kmsKey.KmsKey(this, "example_1", {
deletionWindowInDays: 7,
description: "example",
});
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
awsKmsKeyExample.overrideLogicalId("example");
new aws.ecsCluster.EcsCluster(this, "test", {
configuration: {
executeCommandConfiguration: {
kmsKeyId: awsKmsKeyExample.arn,
logConfiguration: {
cloudWatchEncryptionEnabled: true,
cloudWatchLogGroupName: awsCloudwatchLogGroupExample.name,
},
logging: "OVERRIDE",
},
},
name: "example",
});
Example with Capacity Providers
/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
const awsEcsCapacityProviderExample =
new aws.ecsCapacityProvider.EcsCapacityProvider(this, "example", {
autoScalingGroupProvider: {
autoScalingGroupArn: "${aws_autoscaling_group.example.arn}",
},
name: "example",
});
const awsEcsClusterExample = new aws.ecsCluster.EcsCluster(this, "example_1", {
name: "example",
});
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
awsEcsClusterExample.overrideLogicalId("example");
const awsEcsClusterCapacityProvidersExample =
new aws.ecsClusterCapacityProviders.EcsClusterCapacityProviders(
this,
"example_2",
{
capacityProviders: [awsEcsCapacityProviderExample.name],
clusterName: awsEcsClusterExample.name,
defaultCapacityProviderStrategy: [
{
base: 1,
capacityProvider: awsEcsCapacityProviderExample.name,
weight: 100,
},
],
}
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
awsEcsClusterCapacityProvidersExample.overrideLogicalId("example");
Argument Reference
The following arguments are supported:
capacityProviders
- (Optional, Deprecated use theawsEcsClusterCapacityProviders
resource instead) List of short names of one or more capacity providers to associate with the cluster. Valid values also includefargate
andFARGATE_SPOT
.configuration
- (Optional) The execute command configuration for the cluster. Detailed below.defaultCapacityProviderStrategy
- (Optional, Deprecated use theawsEcsClusterCapacityProviders
resource instead) Configuration block for capacity provider strategy to use by default for the cluster. Can be one or more. Detailed below.name
- (Required) Name of the cluster (up to 255 letters, numbers, hyphens, and underscores)serviceConnectDefaults
- (Optional) Configures a default Service Connect namespace. Detailed below.setting
- (Optional) Configuration block(s) with cluster settings. For example, this can be used to enable CloudWatch Container Insights for a cluster. Detailed below.tags
- (Optional) Key-value map of resource tags. If configured with a providerdefaultTags
configuration block present, tags with matching keys will overwrite those defined at the provider-level.
configuration
executeCommandConfiguration
- (Optional) The details of the execute command configuration. Detailed below.
executeCommandConfiguration
kmsKeyId
- (Optional) The AWS Key Management Service key ID to encrypt the data between the local client and the container.logConfiguration
- (Optional) The log configuration for the results of the execute command actions Required whenlogging
isoverride
. Detailed below.logging
- (Optional) The log setting to use for redirecting logs for your execute command results. Valid values arenone
,default
, andoverride
.
logConfiguration
cloudWatchEncryptionEnabled
- (Optional) Whether or not to enable encryption on the CloudWatch logs. If not specified, encryption will be disabled.cloudWatchLogGroupName
- (Optional) The name of the CloudWatch log group to send logs to.s3BucketName
- (Optional) The name of the S3 bucket to send logs to.s3BucketEncryptionEnabled
- (Optional) Whether or not to enable encryption on the logs sent to S3. If not specified, encryption will be disabled.s3KeyPrefix
- (Optional) An optional folder in the S3 bucket to place logs in.
defaultCapacityProviderStrategy
capacityProvider
- (Required) The short name of the capacity provider.weight
- (Optional) The relative percentage of the total number of launched tasks that should use the specified capacity provider.base
- (Optional) The number of 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.
setting
name
- (Required) Name of the setting to manage. Valid values:containerInsights
.value
- (Required) The value to assign to the setting. Valid values areenabled
anddisabled
.
serviceConnectDefaults
namespace
- (Required) The ARN of theawsServiceDiscoveryHttpNamespace
that's used when you create a service and don't specify a Service Connect configuration.
Attributes Reference
In addition to all arguments above, the following attributes are exported:
arn
- ARN that identifies the cluster.id
- ARN that identifies the cluster.tagsAll
- Map of tags assigned to the resource, including those inherited from the providerdefaultTags
configuration block.
Import
ECS clusters can be imported using the name
, e.g.,