overexchange
overexchange

Reputation: 1

Invalid template resource property "Tags"

For the below cloudformation template:

{
    "AWSTemplateFormatVersion": "2010-09-09",
    "Description": "Some Stack",
    "Parameters":{
        "VpcId":{
            "Type": "AWS::EC2::VPC::Id",
            "Description": "The target VPC Id"
        },
        "SubnetId":{
            "Type": "AWS::EC2::Subnet::Id",
            "Description": "The target subnet Id"
        },
        "KeyName": {
            "Type": "String",
            "Description": "The key pair that is allowed SSH access"
        }
    },
    "Resources":{
        "EcsCluster":{
            "Type": "AWS::ECS::Cluster",
            "Tags": [ 
                        {
                            "Key": "Name",
                            "Value": { "Fn::Join": ["", [ { "Ref": "AWS::StackName" }, "-ecs-cluster" ] ] }     
                        },
                        {
                            "Key": "workenv",
                            "Value": "dev"
                        },
                        {
                            "Key": "abc",
                            "Value": "some_value"
                        },
                        {
                            "Key": "function",
                            "Value": "someapp"
                        },
                        {
                            "Key": "owner",
                            "Value": "[email protected]"
                        }
            ]
        }
    },
    "Outputs":{
        "ElbDomainName":{
            "Description": "Public DNS name of Elastic Load Balancer",
            "Value": {
                "Fn::GetAtt": [
                    "ElasticLoadBalancer",
                    "DNSName"
                ]
            }
        }
    }
}

Below is the error:

   Invalid template resource property 'Tags'

Am following the below documentation to add tags:

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-resource-tags.html


Why CloudFormation service does not accept Tags defined on every resource? something to do with indentation?

Upvotes: 2

Views: 4418

Answers (2)

Arun Kamalanathan
Arun Kamalanathan

Reputation: 8593

It is because the Tags are not defined correctly for EcsCluster resource. The Tags property should be defined inside the Properties section as how you defined Tags for other resources.

"EcsCluster": {
  "Type": "AWS::ECS::Cluster",
  "Properties": {
    "Tags": []
  }
}

Hope this helps.

Upvotes: 4

Jason Wadsworth
Jason Wadsworth

Reputation: 8885

Not all resource types support tags. Check the documentation for each resource type.

Upvotes: 1

Related Questions