Skip to content

4._Introduction_ _Command_Line

Ahmad Abdo edited this page Jun 26, 2017 · 2 revisions

Introduction - Command Line

Before we dive into using awsm, it would be helpful to get more familiar with the CLI and its options.


Global Flags

Global flags apply to all commands, and are passed to awsm to the left of commands (i.e. $ awsm --dry-run commandName).

--dry-run

Runs through the command actions and tests, but either does not send the command to AWS, or sends it with the DryRun option so that no changes are actually made to your AWS services. This is particularly helpful in testing Class changes.

--help

Displays the main help screen or a help screen specific to the action you are interested in performing.

--version

Returns the current version of awsm.


Main Help Screen

Assuming you've properly installed the awsm cli, entering the command awsm --help into your terminal will show a list of all available awsm commands, and a short description of what each command does:

$ awsm --help
NAME:
   awsm - AWS Interface

USAGE:
   awsm [global options] command [command options] [arguments...]

COMMANDS:
     check                       Check / repair the awsm config
     api                         Start the awsm api server
     dashboard                   Launch the awsm Dashboard GUI
     attachIAMRolePolicy         Attach an IAM Policy to a IAM Role
     attachVolume                Attach an EBS Volume to an EC2 Instance
     installKeyPair              Installs a Key Pair locally
     copyImage                   Copy a Machine Image to another region
     copySnapshot                Copy an EBS Snapshot to another region
     createAddress               Create an Elastic IP Address
     createAutoScaleGroups       Create an AutoScaling Groups
     createIAMUser               Create an IAM User
     createIAMPolicy             Create an IAM Policy
     createImage                 Create a Machine Image from a running instance
     createLaunchConfigurations  Create an AutoScaling Launch Configurations
     createLoadBalancer          Create a Load Balancer
     createKeyPair               Create a Key Pair in the specified region
     createResourceRecord        Create a Route53 Resource Record
     createSecurityGroup         Create a Security Groups
     createSimpleDBDomain        Create a SimpleDB Domain
     createSnapshot              Create an EBS snapshot of a volume
     createVolume                Create an EBS volume
     createVpc                   Create a VPC
     createSubnet                Create a VPC Subnet
     deleteAddresses             Delete Elastic IP Addresses
     deleteAutoScaleGroups       Delete AutoScaling Groups
     deleteIAMInstanceProfiles   Delete IAM Instance Profiles
     deleteIAMPolicies           Delete IAM Policies
     deleteIAMRoles              Delete IAM Roles
     deleteIAMUsers              Delete IAM Users
     deleteImages                Delete Machine Images
     deleteKeyPairs              Delete KeyPairs
     deleteLaunchConfigurations  Delete AutoScaling Launch Configurations
     deleteLoadBalancers         Delete Load Balancer(s)
     deleteResourceRecords       Delete Route53 Resource Records
     deleteSecurityGroups        Delete Security Groups
     deleteSnapshots             Delete EBS Snapshots
     deleteSimpleDBDomains       Delete SimpleDB Domains
     deleteVolumes               Delete EBS Volumes
     deleteSubnets               Delete VPC Subnets
     deleteVpcs                  Delete VPCs
     deregisterInstances         Deregister an Instance from SSM Inventory
     detachVolume                Detach an EBS Volume
     getIAMInstanceProfile       Get an IAM Instance Profile
     getIAMPolicy                Get an IAM Policy
     getIAMUser                  Get an IAM User
     getInventory                Get SSM Inventory
     stopInstances               Stop instances
     startInstances              Start instances
     rebootInstances             Reboot instances
     refreshVolume               Refreshe an EBS Volume on an EC2 Instance
     terminateInstances          Terminate instances
     launchInstance              Launch an EC2 instance
     listAddresses               List Elastic IP Addresses
     listAlarms                  List CloudWatch Alarms
     listAutoScaleGroups         List AutoScale Groups
     listBuckets                 List S3 Buckets
     listCommandInvocations      List SSM Command Invocations
     listHostedZones             List Route53 Hosted Zones
     listIAMInstanceProfiles     List IAM Instance Profiles
     listIAMPolicies             List IAM Policies
     listIAMRoles                List IAM Roles
     listIAMUsers                List IAM Users
     listImages                  List Machine Images owned by us
     listInstances               List EC2 Instances
     listKeyPairs                List Key Pairs
     listLaunchConfigurations    List Launch Configurations
     listLoadBalancers           List Elastic Load Balancers
     listResourceRecords         List Route53 Resource Records
     listScalingPolicies         List Scaling Policies
     listSecurityGroups          List Security Groups
     listSnapshots               List EBS Snapshots
     listSSMInstances            List SSM Instances
     listSubnets                 List Subnets
     listSimpleDBDomains         List SimpleDB Domains
     listVolumes                 List EBS Volumes
     listVpcs                    List Vpcs
     resumeProcesses             Resume scaling processes on Autoscaling Groups
     runCommand                  Run a command on a set of EC2 Instances
     suspendProcesses            Suspend scaling processes on Autoscaling Groups
     updateAutoScaleGroups       Update AutoScaling Groups
     updateLoadBalancers         Update Load Balancers
     updateSecurityGroups        Update Security Groups
     installAutocomplete         Install awsm autocomplete
     help, h                     Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --dry-run      dry-run (Don't make any real changes)
   --help, -h     show help
   --version, -v  print the version


Command Help Screens

The majority of awsm commands require arguments after them. To see the required/optional arguments and the help screen for a specific argument, append --help to it:

$ awsm launchInstance --help
NAME:
   awsm launchInstance - Launch an EC2 instance

USAGE:
   awsm launchInstance [arguments...]

ARGUMENTS:
   class - The class of the instance (dev, stage, etc)
   sequence - The sequence of the instance (1...100)
   az - The availability zone to launch the instance in (us-west-2a, us-east-1a, etc)

Command Arguments

Since awsm uses Classes to store configuration details, most awsm commands will require only a few user inputs inorder to build, create, or destroy AWS services. Because of this, all command arguments are required, unless they are listed within square brackets:

$ awsm createSnapshot --help

NAME:
   awsm createSnapshot - Create an EBS snapshot of a volume

USAGE:
   awsm createSnapshot [arguments...]

ARGUMENTS:
   class - The class of the new snapshot
   [search] - The volume to create the snapshot from (optional, defaults setting in class configuration)

Search

Many of the commands have one or more search arguments. These can accept either a plain string or regex - and are used to find one or more AWS asset when performing certain commands. For example, the listInstances command can locate instances that match a particular string, in this case: "dev":

$ awsm listInstances dev
+-------+-------+------------+-----------+---------------------+--------------+------+----------+---------+------------+-------------------+---------------+---------+----------------------+
| NAME  | CLASS | PRIVATE IP | PUBLIC IP |     INSTANCE ID     |     AMI      | ROOT |   SIZE   |  STATE  |  KEYPAIR   | AVAILABILITY ZONE |      VPC      | SUBNET  | IAM INSTANCE PROFILE |
+-------+-------+------------+-----------+---------------------+--------------+------+----------+---------+------------+-------------------+---------------+---------+----------------------+
| dev1  | dev   | 10.0.2.125 |           | i-0775d2b53b99b437c | awsm-init-v3 | ebs  | r3.large | running | awsm       | us-west-2a        | us-west-2-vpc | Private | awsm                 |
| dev2  | dev   | 10.0.2.147 |           | i-04643fac08a34815d | awsm-init-v3 | ebs  | r3.large | running | awsm       | us-west-2a        | us-west-2-vpc | Private |                      |
+-------+-------+------------+-----------+---------------------+--------------+------+----------+---------+------------+-------------------+---------------+---------+----------------------+

Or you could be more specific and pass it the instance ID's via regex:

$ awsm listInstances "i-0775d2b53b99b437c|i-04643fac08a34815d"
+-------+-------+------------+-----------+---------------------+--------------+------+----------+---------+------------+-------------------+---------------+---------+----------------------+
| NAME  | CLASS | PRIVATE IP | PUBLIC IP |     INSTANCE ID     |     AMI      | ROOT |   SIZE   |  STATE  |  KEYPAIR   | AVAILABILITY ZONE |      VPC      | SUBNET  | IAM INSTANCE PROFILE |
+-------+-------+------------+-----------+---------------------+--------------+------+----------+---------+------------+-------------------+---------------+---------+----------------------+
| dev1  | dev   | 10.0.2.125 |           | i-0775d2b53b99b437c | awsm-init-v3 | ebs  | r3.large | running | awsm       | us-west-2a        | us-west-2-vpc | Private | awsm                 |
| dev2  | dev   | 10.0.2.147 |           | i-04643fac08a34815d | awsm-init-v3 | ebs  | r3.large | running | awsm       | us-west-2a        | us-west-2-vpc | Private |                      |
+-------+-------+------------+-----------+---------------------+--------------+------+----------+---------+------------+-------------------+---------------+---------+----------------------+

Next

Now that we're more familiar with the available commands, you should have enough information to explore the available commands and the types of arguments that they expect.