AWS Cloudformation: Invalid template resource property error

8,514

You have set "BambooInstanceProfile" as an attribute of "BambooAgentRole" instead of it's own resource. One more } needs to come before your "BambooInstanceProfile".

Share:
8,514

Related videos on Youtube

deadf1sh
Author by

deadf1sh

Updated on September 18, 2022

Comments

  • deadf1sh
    deadf1sh over 1 year

    I am attempting to create a Cloudformation template to configure an IAM role.

    As far as I can tell my JSON is 100% valid but apparently I'm overlooking something else because it's not able to be validated:

    A client error (ValidationError) occurred when calling the ValidateTemplate operation: Invalid template resource property 'BambooInstanceProfile'

    My code:

    {
      "Description" : "Bamboo IAM role",
    
      "Parameters" : {
    
      },
    
    
    
      "Resources" : {  
    
    
        "BambooAgentRole" : {
             "Type": "AWS::IAM::Role",
             "Properties": {
                "AssumeRolePolicyDocument": {
                   "Version" : "2012-10-17",
                   "Statement": [ {
                      "Effect": "Allow",
                      "Principal": {
                         "Service": [ "ec2.amazonaws.com" ]
                      },
                      "Action": [ "sts:AssumeRole" ]
                   }  ]
    
                },
                "Path": "/devtools/bamboo/",
                "Policies": [ {
                   "PolicyName": "ec2_bamboo",
                   "PolicyDocument": {
                      "Version" : "2012-10-17",
                      "Statement": [ {
                        "Effect": "Allow",
                        "Action": [
                          "ec2:DescribeTags",
                          "ec2:DescribeInstances"
                          ],
                          "Resource": "*"
                      } ]
                  }
                  } ]
          },
          "BambooInstanceProfile": {
            "Type": "AWS::IAM::InstanceProfile",
            "Properties": {
               "Path": "/devtools/bamboo/",
               "Roles": [ {
                  "Ref": "BambooAgentRole"
               } ]
            }  
          }
        }  
      },
    
    
    
    
    
    
    
      "Outputs" : {
        "IAM" : { "Value" : { "Ref" : "BambooInstanceProfile" }}
      }
    
    
    }
    

    What am I overlooking here?

  • Jose Dzireh Chong
    Jose Dzireh Chong over 7 years
    Yep, it's probably linting as valid JSON because there are too many closing curly brackets at the end of the Instance Profile Resource. Looks like your opening and closing brackets got out of line.
  • Daniel Farrell
    Daniel Farrell almost 4 years
    In my case I had accidentally put my "Conditions" inside my "Resources". D'oh! "Conditions" is a valid resource name, but a condition definition isn't a valid resource. Pro tip: don't name your conditions the same thing as a valid resource property for your resources!