I am trying to call run instances and pass the resulting instance identifiers as input to create tags as a single-line image as follows:
aws ec2 run-instances \ --image-id ami-1234 \ --output text \ --query Instances[*].InstanceId | \ aws ec2 create-tags \ --tags 'Key="foo",Value="bar"'
When I try this, I get the following:
usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters] To see help text, you can run: aws help aws <command> help aws <command> <subcommand> help aws: error: argument --resources is required
Is something like this possible or need to resort to using variables (or in some other way that I don't think about)?
Additional background
The motivation for asking this question is that something similar is possible with AWS Tools for Windows PowerShell; I was hoping to do the same with the CLI AWS.
An equivalent PowerShell example:
New-EC2Instance -ImageId ami-1234 | ForEach-Object Instances | ForEach-Object InstanceId | New-EC2Tag -Tag @{key='foo';value='bar'}
source share