aws-cloudformation / aws-cloudformation-resource-providers-awsutilities-commandrunner

Apache License 2.0
81 stars 21 forks source link

Unable to run a command with my yaml file #25

Closed sanyamgrover closed 2 years ago

sanyamgrover commented 3 years ago

Hi,

I have cloned this and selected all the setting correctly as directed in the documentation. While I try to create stack from my yaml file, it creates a dependent stack which is trying to create an ec2 instance but fails to create it even though EC2 full access is provided to the role.

The error I receive is Unable to resolve following error "waitcondition timed out. received 0 conditions when expecting 1"

The following is the yaml I have used to create a stack which isn't getting created. AWSTemplateFormatVersion: 2010-09-09 Parameters: Keyid: Description: "Key Id for the KMS key to enable key rotation" Default: 8eef2781-9753-47fd-9ee4-892f16e3d973 Type: String RegionForKMSkey: Description: "Please enter the Region where your KMS key is present" Default: us-east-1 Type: String InstanceRole: Description: "Please enter the Role Name that Ec2 instance will assume to execute the command" Default: "" Type: String Resources: Commandrunner: Properties: Command: !Sub 'aws kms enable-key-rotation --key-id ${Keyid} --region ${RegionForKMSkey} && echo "Key rotation enabled successfully" > /command-output.txt' Role: !Ref InstanceRole Type: "AWSUtility::CloudFormation::CommandRunner" Outputs: Commands: Description: "Echo command Text" Value: "Fn::GetAtt": Commandrunner.Output

sanyamgrover commented 3 years ago

@craigataws @shantgup @cfn-rpdk-ci @amazon-auto @sheldonkwoodward

maslick commented 3 years ago

Please make sure you indent your yaml correctly:

AWSTemplateFormatVersion: 2010-09-09
Parameters:
  Keyid:
    Description: "Key Id for the KMS key to enable key rotation"
    Default: 8eef2781-9753-47fd-9ee4-892f16e3d973
    Type: String
  RegionForKMSkey:
    Description: "Please enter the Region where your KMS key is present"
    Default: us-east-1
    Type: String
  InstanceRole:
    Description: "Please enter the Role Name that Ec2 instance will assume to execute the command"
    Default: ""
    Type: String

Resources:
  Commandrunner:
    Type: "AWSUtility::CloudFormation::CommandRunner"
    Properties:
      Command: !Sub 'aws kms enable-key-rotation --key-id ${Keyid} --region ${RegionForKMSkey} && echo "Key rotation enabled successfully" > /command-output.txt'
    Role: !Ref InstanceRole

Outputs:
  Commands:
    Description: "Echo command Text"
    Value: 
      "Fn::GetAtt": Commandrunner.Output
sto-nith commented 2 years ago

I am facing the same issue "waitcondition timed out. received 0 conditions when expecting 1" while creating a stack with CommandRunner resource.

AWSTemplateFormatVersion: 2010-09-09
Description: >-
  RAP CloudFormation Template. This template is intended for creating stack in
  the existing VPC using current VPC,Internet Gateway and NAT Gateway etc. This
  template will create new routes, security groups, roles, policies, S3 buckets,
  MSK cluster, Redshift cluster etc.
Parameters:
  ENV:
    Type: String
    Description: Environment to run CFN template
    Default: dev
Resources:
  Command:
    Type: 'AWSUtility::CloudFormation::CommandRunner'
    Properties:
      Command: echo Testing 1..2..3 > /command-output.txt

Outputs:
    Output:
        Description: The output of the CommandRunner.
        Value: !GetAtt Command.Output

Did anyone get a resolution to this issue?

sanyamgrover commented 2 years ago

If I remember it correctly, it has something to do with the syntax of the bash command. Follow AWS format of writing the command.

On Wed, 15 Dec, 2021, 8:01 pm stonith, @.***> wrote:

I am facing the same issue "waitcondition timed out. received 0 conditions when expecting 1" while creating a stack with CommandRunner resource.

AWSTemplateFormatVersion: 2010-09-09 Description: >- RAP CloudFormation Template. This template is intended for creating stack in the existing VPC using current VPC,Internet Gateway and NAT Gateway etc. This template will create new routes, security groups, roles, policies, S3 buckets, MSK cluster, Redshift cluster etc. Parameters: ENV: Type: String Description: Environment to run CFN template Default: dev Resources: Command: Type: 'AWSUtility::CloudFormation::CommandRunner' Properties: Command: echo Testing 1..2..3 > /command-output.txt

Outputs: Output: Description: The output of the CommandRunner. Value: !GetAtt Command.Output

Did anyone get a resolution to this issue?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/aws-cloudformation/aws-cloudformation-resource-providers-awsutilities-commandrunner/issues/25#issuecomment-994846308, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABRZYFFYZTBPZHRKJBSFZ2TURCRF3ANCNFSM5BW7MYMA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.