Answers: <p>The issues were a lot, but the main one was not using Targets properly and then some YAML syntax problems.</p>
  
  <pre><code>---
  description: "Example"
  schemaVersion: "0.3"
  assumeRole: "arn:aws:iam::{ID}:role/Example"
  # parameters:
  #   InstanceId:
  #     type: "StringList"
  #     description: "(Required) EC2 Instance(s) to start"
  #   AutomationAssumeRole:
  #     type: "String"
  #     description: "(Optional) The ARN of the role that allows Automation to perform the actions on your behalf."
  #     default: ""
  mainSteps:
  ## STEP 1
  - name: StartExampleServiceOnServer1
    action: aws:runCommand
    maxAttempts: 2
    inputs:
      DocumentName: AWS-RunPowerShellScript
      Targets:
      - Key: tag:Name
        Values:
        - ExampleOne-SomeService-Dev
      Parameters:
        commands:
        # Start service for SomeService
        - Start-Service -Name "ExampleOne"
        - Start-Sleep -s 30
    nextStep: ...
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2019-07-23T21:31:47.287Z
Answers: 2019-07-23T21:31:47.287Z
Answers: Daniel Johns
Body: <p>As the title describes I want to execute a step against a resource, but I want to specify that resource not by resource id but by tags, I have tried with the below example, but it doesn't work. What is the proper syntax and is that possible at all?</p>
  
  <pre><code>---
  description: "Automation Document in YAML - version 3.0. Script to fully start instances in order respecting components dependencies. Created by - xxxx"
  schemaVersion: "0.3"
  # assumeRole: "{{ AutomationAssumeRole }}"
  # parameters:
  #   InstanceId:
  #     type: "StringList"
  #     description: "(Required) EC2 Instance(s) to start"
  #   AutomationAssumeRole:
  #     type: "String"
  #     description: "(Optional) The ARN of the role that allows Automation to perform the actions on your behalf."
  #     default: ""
  mainSteps:
  ## STEP 1
  - name: startSomeProductComponent1Test
    action: aws:runCommand
    maxAttempts: 2
    inputs:
      Tags:
      - Key: Product
        Value: SomeProduct
      - Key: Name
        Value: SomeProduct-Component1-Test
      DocumentName: AWS-RunPowerShellScript
      Parameters:
        commands:
        - Start-Service -Name "Component1"
        - Start-Sleep -s 30
    nextStep: ...
  </code></pre>
  
Tags: <amazon-web-services><automation><aws-cloudformation>
Title: AWS Automation Document Run Steps Against Different Servers Targeted By Tag
UserDisplayName: Daniel Johns
ThreadText: # AWS Automation Document Run Steps Against Different Servers Targeted By Tag
  
  (Asked by: username_0 on 2019-04-24)
  
  As the title describes I want to execute a step against a resource, but I want to specify that resource not by resource id but by tags, I have tried with the below example, but it doesn't work. What is the proper syntax and is that possible at all?
  
  ```
  ---
  description: "Automation Document in YAML - version 3.0. Script to fully start instances in order respecting components dependencies. Created by - xxxx"
  schemaVersion: "0.3"
  # assumeRole: "{{ AutomationAssumeRole }}"
  # parameters:
  #   InstanceId:
  #     type: "StringList"
  #     description: "(Required) EC2 Instance(s) to start"
  #   AutomationAssumeRole:
  #     type: "String"
  #     description: "(Optional) The ARN of the role that allows Automation to perform the actions on your behalf."
  #     default: ""
  mainSteps:
  ## STEP 1
  - name: startSomeProductComponent1Test
    action: aws:runCommand
    maxAttempts: 2
    inputs:
      Tags:
      - Key: Product
        Value: SomeProduct
      - Key: Name
        Value: SomeProduct-Component1-Test
      DocumentName: AWS-RunPowerShellScript
      Parameters:
        commands:
        - Start-Service -Name "Component1"
        - Start-Sleep -s 30
    nextStep: ...
  
  ```
  
  **Tags:** amazon-web-services, automation, aws-cloudformation
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2019-07-23. Score: 0 | Accepted answer
  
  The issues were a lot, but the main one was not using Targets properly and then some YAML syntax problems.
  
  ```
  ---
  description: "Example"
  schemaVersion: "0.3"
  assumeRole: "arn:aws:iam::{ID}:role/Example"
  # parameters:
  #   InstanceId:
  #     type: "StringList"
  #     description: "(Required) EC2 Instance(s) to start"
  #   AutomationAssumeRole:
  #     type: "String"
  #     description: "(Optional) The ARN of the role that allows Automation to perform the actions on your behalf."
  #     default: ""
  mainSteps:
  ## STEP 1
  - name: StartExampleServiceOnServer1
    action: aws:runCommand
    maxAttempts: 2
    inputs:
      DocumentName: AWS-RunPowerShellScript
      Targets:
      - Key: tag:Name
        Values:
        - ExampleOne-SomeService-Dev
      Parameters:
        commands:
        # Start service for SomeService
        - Start-Service -Name "ExampleOne"
        - Start-Sleep -s 30
    nextStep: ...
  
  ```
  
  
  ---
  
  