Skip to main content

aws Command

The aws command executes an operation on an AWS resource. The command supports the same services and operations as the AWS CLI.

info

Please refer to the list of available services and their operations.

There are two modes of operation:

  1. Pipe the result of a search to the aws command. The command will be invoked on each resource returned by the search. You can template parameters to define the exact invocation arguments.
  2. Call the aws command directly (without passing a resource) to interact with AWS directly.

Usage

aws [--account <override_account>] [--role <override_role>] [--profile <override_profile>] [--region <override_region>] [service] [operation] [operation_args]

Parameters

ParameterDescriptionRequired?Default Value
serviceAWS service name✔️
operationOperation to perform✔️
operation_argsAdditional command arguments

Options

OptionDescriptionRequired?
--account <override_account>Override account
--role <override_role>Override role
--profile <override_profile>Override profile
--region <override_region>Override region

Examples

Get the calling identity for the configured access
> aws sts get-caller-identity
​UserId: AIDA42373XXXXXXXXXXXX
​Account: '882374444444'
​Arn: arn:aws:iam::882374444444:user/matthias
Call describe-volume-attribute for all EC2 volumes
​# Search for EC2 volumes and then call describe-volume-attribute on each volume.
​# Note: The aws command is invoked on each volume and replaces {id} with the volume ID.
> search is(aws_ec2_volume) | aws ec2 describe-volume-attribute --volume-id {id} --attribute autoEnableIO
​volume AutoEnableIO:
​ Value: false
​ VolumeId: vol-009b0a28d2754927e
Stop running EC2 instances with name test
​# Search for running EC2 instances with the term test in the name and stop them.
​# Note: The aws command is invoked on each instance and replaces {id} with the instance ID.
> search is(aws_ec2_instance) and instance_status=running and name~test | aws ec2 stop-instances --instance-ids {id}
​StoppingInstances:
​ - InstanceId: i-1234567890abcdef0
​ CurrentState:
​ Code: 64
​ Name: stopping
​ PreviousState:
​ Code: 16
​ Name: running
Start stopped EC2 instances with name test
​# Search for stopped EC2 instances with the term test in the name and start them.
​# Note: The aws command is invoked on each instance and replaces {id} with the instance ID.
> search is(aws_ec2_instance) and instance_status=stopped and name~test | aws ec2 start-instances --instance-ids {id}
​StartingInstances:
​ - InstanceId: i-1234567890abcdef0
​ CurrentState:
​ Code: 0
​ Name: pending
​ PreviousState:
​ Code: 80
​ Name: stopped