0

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: ...
0

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: ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.