AWS Amazon ECS Tag
This page shows how to write Terraform and CloudFormation for Amazon ECS Tag and write them securely.
aws_ecs_tag (Terraform)
The Tag in Amazon ECS can be configured in Terraform with the resource name aws_ecs_tag
. The following sections describe how to use the resource and its parameters.
Example Usage from GitHub
An example could not be found in GitHub.
Parameters
The following arguments are supported:
resource_arn
- (Required) Amazon Resource Name (ARN) of the ECS resource to tag.key
- (Required) Tag name.value
- (Required) Tag value.
In addition to all arguments above, the following attributes are exported:
id
- ECS resource identifier and key, separated by a comma (,
)
Explanation in Terraform Registry
Manages an individual ECS resource tag. This resource should only be used in cases where ECS resources are created outside Terraform (e.g., ECS Clusters implicitly created by Batch Compute Environments).
NOTE: This tagging resource should not be combined with the Terraform resource for managing the parent resource. For example, using
aws_ecs_cluster
andaws_ecs_tag
to manage tags of the same ECS Cluster will cause a perpetual difference where theaws_ecs_cluster
resource will try to remove the tag being added by theaws_ecs_tag
resource. NOTE: This tagging resource does not use the providerignore_tags
configuration.
Tips: Best Practices for The Other AWS Amazon ECS Resources
In addition to the aws_ecs_cluster, AWS Amazon ECS has the other resources that should be configured for security reasons. Please check some examples of those resources and precautions.
aws_ecs_cluster
Ensure to enable CloudWatch Container Insights
It's better to enable CloudWatch Container Insights to gain a better perspective on cluster applications. CloudWatch Container Insights collects, aggregates, and summarizes ECS metrics and logs.
aws_ecs_task_definition
Ensure to enable in-transit encryption of EFS volume
It is better to enable in-transit encryption of EFS volume for the protection of data in transit more.
AWS::ECS::Cluster (CloudFormation)
The Cluster in ECS can be configured in CloudFormation with the resource name AWS::ECS::Cluster
. The following sections describe 10 examples of how to use the resource and its parameters.
Example Usage from GitHub
Type: AWS::ECS::Cluster
Properties:
ClusterName: jonathans-cluster
# AWS::ECS::Cluster for DEVELOP
# ------------------------------------------------------------#
ECSClusterForDevelop:
Type: 'AWS::ECS::Cluster'
Properties:
ClusterName: !Sub ${ProjectName}-develop
Type: 'AWS::ECS::Cluster'
Properties:
ClusterName: !Sub '${EnvironmentName}_${AppClusterName}'
ClusterSettings:
- Name: 'containerInsights'
Value: 'disabled'
Type: 'AWS::ECS::Cluster'
Properties:
ClusterName: !Sub '${EnvironmentName}_${AppClusterName}'
ClusterSettings:
- Name: 'containerInsights'
Value: 'disabled'
Type: AWS::ECS::Cluster
Properties:
CapacityProviders: ['FARGATE', 'FARGATE_SPOT']
Tags:
- Key: Name
Value: !Sub "${PJPrefix}-${TagSuffix}-production"
"ResourceType": "AWS::ECS::Cluster",
"StackId": "arn:aws:cloudformation:%AWS_REGION%:%AWS_ACC_ID%:stack/stastest-%SCENARIO_ID%/e4606190-b6bc-11ea-91d5-0ac92d082ee0",
"StackName": "stastest-%SCENARIO_ID%",
"Timestamp": "2020-06-25T08:22:18.299Z"
},
{
"ResourceType": "AWS::ECS::Cluster",
"StackId": "arn:aws:cloudformation:%AWS_REGION%:%AWS_ACC_ID%:stack/stastest-param-%SCENARIO_ID%/301220b0-b6bd-11ea-8e93-0ad4772b7a1e",
"StackName": "stastest-param-%SCENARIO_ID%",
"Timestamp": "2020-06-25T08:24:00.723Z"
},
{
"ResourceType": "AWS::ECS::Cluster",
"StackId": "arn:aws:cloudformation:%AWS_REGION%:%AWS_ACC_ID%:stack/stastest-param-%SCENARIO_ID%/301220b0-b6bd-11ea-8e93-0ad4772b7a1e",
"StackName": "stastest-param-%SCENARIO_ID%",
"Timestamp": "2020-06-25T08:24:00.723Z"
},
{
"ResourceType": "AWS::ECS::Cluster",
"StackId": "arn:aws:cloudformation:%AWS_REGION%:%AWS_ACC_ID%:stack/stastest-%SCENARIO_ID%/e4606190-b6bc-11ea-91d5-0ac92d082ee0",
"StackName": "stastest-%SCENARIO_ID%",
"Timestamp": "2020-06-25T08:22:18.299Z"
},
{
"ResourceType": "AWS::ECS::Cluster",
"StackId": "arn:aws:cloudformation:%AWS_REGION%:%AWS_ACC_ID%:stack/stastest-param-%SCENARIO_ID%/301220b0-b6bd-11ea-8e93-0ad4772b7a1e",
"StackName": "stastest-param-%SCENARIO_ID%",
"Timestamp": "2020-06-25T08:24:00.723Z"
},
{
Parameters
-
Tags
optional - List of Tag -
ClusterName
optional - String -
ClusterSettings
optional - List of ClusterSettings -
Configuration
optional - ClusterConfiguration -
CapacityProviders
optional - List -
DefaultCapacityProviderStrategy
optional - List of CapacityProviderStrategyItem
Explanation in CloudFormation Registry
The
AWS::ECS::Cluster
resource creates an Amazon Elastic Container Service (Amazon ECS) cluster.
Frequently asked questions
What is AWS Amazon ECS Tag?
AWS Amazon ECS Tag is a resource for Amazon ECS of Amazon Web Service. Settings can be wrote in Terraform and CloudFormation.
Where can I find the example code for the AWS Amazon ECS Tag?
For CloudFormation, the jonathanschoeller/jonathan-aws, TheGK-rh/CloudFormation and kybrdbnd/devops-hiring-challenge source code examples are useful. See the CloudFormation Example section for further details.