- Newest
- Most votes
- Most comments
The Target Key and Target Value is used to identify which instance(s) to run the command against. Target Key can either be an instance tag key (e.g., environment
), or the literal value InstanceIds
to indicate that the command should be run against a specific list of instance IDs. Target Value is a list either of tag values, if a tag key was specified for the target key (e.g., production
), or a list of EC2 instance IDs.
Source: https://docs.aws.amazon.com/eventbridge/latest/APIReference/API_RunCommandTarget.html
EventBridge supports fetching data out of the event and passing it to the target via Transforms. See the transforms documentation for additional details.
I have this exact same need. I have instances in an ASG that need something to happen post-boot. Specifically, I am trying to get the CodeDeploy agent installed via the SSM Document that is used by Distributor.
Its not intuitive, but the solution to this is to create an SSM Automation and not Run/Send Command. If you use an Automation then you can write the EventBridge rule to target that then use the input transform. The automation will digest the input into a Target for the automation. Not great as it adds an obfuscating layer, but it is what it is.
For my specific use case, I have also explored: Creating an EventBridge rule for each autoscaling group (yuck) Targeting the Run Command for every piece of running equipment (yuck)
Relevant content
- asked 9 months ago
- Accepted Answerasked 5 years ago
- AWS OFFICIALUpdated 20 days ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated a year ago
Thanks for confirming what they are for.
The issue I have is that the variables declared in Transforms seems to only work for parameters besides RunCommandTarget. When I put <instanceId> in the Target Value, it seems to take it as literal.
I'll try with <instanceId> and $.detail.EC2InstanceId some more. Do you know by any chance the correct syntax?
I couldn't figure out a way to pass instanceId variable to Target Value in the console UI. To work around this, I instead opted for Event Bridge -> Lambda -> System Manager Run Command, which worked. I'll mark this question as answered, but it'll be great if anyone figures out a way to directly pass instanceId.