Running aws cli command in Cloudformation fails

0

Hi,

In Cloudformation I keep getting this error when trying to run a AWS CLI command

Template` contains errors.: Template format error: Unrecognized resource types: `[AWSUtility::CloudFormation::CommandRunner]

This is my CloudFormation template

AWSTemplateFormatVersion: 2010-09-09
Resources:
  Command:
    Type: 'AWSUtility::CloudFormation::Command'
    Properties:
      Command: aws s3 ls | sed -n 1p | cut -d " " -f3 > /command-output.txt
      Role: <ADDED_IAM_ROLE>
Outputs:
    Output:
        Description: The output of the CommandRunner.
        Value: !GetAtt Command.Output

I have added IAM permissions as per documentation https://github.com/aws-cloudformation/aws-cloudformation-resource-providers-awsutilities-commandrunner


                  "cloudformation:ValidateTemplate",
                  "cloudformation:GetTemplateSummary",
                  "cloudformation:*",
                  "s3:CreateBucket",
                  "s3:DeleteBucket",
                  "s3:PutBucketPolicy",
                  "s3:PutObject",
                  "cloudformation:RegisterType",
                  "cloudformation:DescribeTypeRegistration",
                  "iam:createRole"
                ],
                "Resource": ["*"]

Tried Role ARN as well

Any help appreciated :)

AzCodez
gefragt vor 2 Jahren1674 Aufrufe
1 Antwort
2
Akzeptierte Antwort

Hi Please see this article for the usage, and pay close attention to the section below

https://aws.amazon.com/premiumsupport/knowledge-center/cloudformation-commandrunner-stack/

Important: If you haven't already registered the AWSUtility::CloudFormation::CommandRunner resource, then run the following commands. The register.sh script uses the awsutility-cloudformation-commandrunner.zip to register the resource type in your AWS Region.

See this GitHub repo for the install instructions

https://github.com/aws-cloudformation/aws-cloudformation-resource-providers-awsutilities-commandrunner#user-installation-steps

Also, your template shows

Resources:
  Command:
    Type: 'AWSUtility::CloudFormation::Command'

Should be

Type: 'AWSUtility::CloudFormation::CommandRunner

profile pictureAWS
EXPERTE
Matt-B
beantwortet vor 2 Jahren

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen