Skip to content

AWS CLI

92 commands

Amazon’s official command line for AWS: manage IAM, S3, EC2, Lambda and every other service, and audit an account’s configuration.

  • AWS
  • cloud
  • IAM

Install AWS CLI

brew install awscli

Basic Syntax & Version1

aws --version

Outputs the installed AWS CLI version, Python runtime, and host operating system details for environment verification.

Use this command to ensure your local installation meets the minimum requirements for specific service features or scripts.

Configuration3

aws configure

Initiates an interactive setup to define your Access Key ID, Secret Access Key, default region, and preferred output format.

Run this as a first-time setup step to establish the local credentials and configuration files required for authenticated API calls.

aws configure list

Displays a structured summary of current configuration data and identifies the source, such as environment variables or config files.

Utilize this for troubleshooting to determine which specific profile or credential source is currently being prioritized by the CLI.

aws configure list-profiles

Enumerates all named profiles configured within your local credentials file to provide a clear view of available identity contexts.

Apply this to quickly verify the aliases of different AWS accounts or roles you have saved for use with the --profile flag.

Identity (STS)2

aws sts get-caller-identity

Retrieves details about the active IAM identity, including the Account ID, User/Role ARN, and unique identifier.

Perform this check as a security best practice to confirm you are operating under the correct identity before executing cloud operations.

aws sts decode-authorization-message

Translates the encrypted error message from a denied API request into a readable format to reveal the specific policy violation.

Execute this command to identify which IAM policy, permission boundary, or SCP is preventing a specific action from succeeding.

Link

IAM (Users)2

aws iam list-users

Lists all IAM users within the current AWS account and organizes the data into a readable table for administrative review.

Use this to audit existing user identities and track metadata such as account creation dates and unique user paths.

Link
aws iam get-user

Retrieves comprehensive details for a specific IAM user, including their ARN, creation date, and current tags.

Employ this command to verify the specific configuration of an identity or to fetch the exact ARN needed for resource-based policies.

Link

IAM (Roles)1

aws iam list-roles

Enumerates all IAM roles in the account and applies a JMESPath filter to isolate and display only the role names.

Use this for high-level auditing of existing service and user roles to ensure naming conventions and role sprawl are managed.

Link

IAM (Policies)1

aws iam list-attached-user-policies

Identifies all managed IAM policies directly attached to a specified user to verify their current permission set.

Apply this to perform security gap analysis and ensure that users are not granted excessive permissions through direct attachments.

Link

IAM (Security)2

aws iam get-account-password-policy

Retrieves the global password complexity and rotation requirements defined for the entire AWS account.

Utilize this command to verify that your account's security posture aligns with industry compliance standards and internal audit policies.

Link
aws iam generate-credential-report

Initiates the generation of a comprehensive account-wide report detailing the status of every user's credentials and MFA settings.

Run this periodically to perform security audits, identifying inactive users or credentials that require rotation or deletion.

Link

S3 (Storage)2

aws s3 ls

Lists all S3 buckets available in the current account or the contents of a specific bucket if a path is provided.

Use this for quick navigation and verification of storage resources before initiating file transfers or management tasks.

Link
aws s3 mb

Creates a new S3 bucket in the default or specified region to provide a storage container for cloud data.

Ensure bucket names are globally unique to avoid naming conflicts during the creation of new storage resources.

Link

S3 (Operations)2

aws s3 cp

Copies local files to S3, from S3 to local, or between two S3 buckets while maintaining data integrity.

Utilize this command for manual uploads or downloads of critical assets and configuration files to and from the cloud.

Link
aws s3 sync

Synchronizes a local directory with an S3 prefix by only transferring new or modified files to optimize bandwidth.

Incorporate the --delete flag to mirror environments exactly, removing files from the destination that no longer exist in the source.

Link

S3 (Management)1

aws s3api list-buckets

Accesses the low-level S3 control plane to list buckets and enables advanced filtering via the --query parameter.

Use the s3api variant when you require raw JSON output for programmatic integration or complex filtering of bucket metadata.

Link

S3 (Security)2

aws s3api get-bucket-encryption

Retrieves the server-side encryption (SSE) configuration for a bucket to verify that data-at-rest is properly protected.

Employ this during security audits to ensure all storage buckets comply with encryption mandates using either AES-256 or AWS KMS.

Link
aws s3api get-public-access-block

Checks the status of the Public Access Block settings to ensure a bucket is protected against accidental public exposure.

Apply this check as a fundamental security control to prevent sensitive data leaks caused by misconfigured bucket ACLs or policies.

Link

EC2 (Compute)2

aws ec2 describe-regions

Lists all available AWS regions along with their respective endpoints to determine where resources can be deployed.

Use the --all-regions flag to see both enabled and disabled regions for comprehensive account availability mapping.

Link
aws ec2 describe-instances

Retrieves detailed metadata for EC2 instances, with the ability to filter based on state, instance type, or tags.

Use this to generate an inventory of active compute resources and to check the status of instances during deployment cycles.

Link

EC2 (JMESPath Query)1

aws ec2 describe-instances --query

Performs complex server-side filtering to extract specific fields like Public IP and Name tags into a custom JSON or table output.

Leverage this advanced query capability to create concise reports for DevOps teams without parsing large amounts of unnecessary metadata.

Link

EC2 (Management)2

aws ec2 start-instances

Initiates the boot sequence for one or more stopped, EBS-backed EC2 instances to bring them into a running state.

Utilize this command to resume workloads or re-enable development environments that were stopped to save on compute costs.

Link
aws ec2 stop-instances

Sends a shutdown signal to specified EBS-backed instances, moving them to a 'stopped' state while preserving the disk state.

Apply this command as a cost-saving measure for non-production instances or during scheduled maintenance windows.

Link

VPC (Networking)2

aws ec2 describe-vpcs

Returns a list of Virtual Private Clouds within the region, providing CIDR blocks, tenancy info, and VPC state.

Use this to map out the network architecture of your account and verify the availability of specific VPC environments.

Link
aws ec2 describe-subnets

Lists the subnets associated with a specific VPC, including Availability Zone mappings and available IP counts.

Employ this command to ensure resources are being deployed into the correct network tier and to audit available subnet capacity.

Link

VPC (Security Groups)1

aws ec2 describe-security-groups

Retrieves the ingress and egress rules for security groups to audit virtual firewall configurations.

Use this to inspect which traffic patterns are permitted for your resources and to identify unused or misconfigured security groups.

Link

VPC (Security Audit)1

aws ec2 describe-security-group-rules

Provides a granular view of specific security group rules, including port ranges and CIDR descriptions.

Leverage this command to perform precise security audits and identify overly permissive rules that may violate compliance standards.

Link

RDS (Database)2

aws rds describe-db-instances

Returns detailed information about all provisioned RDS instances, including database engine, status, and endpoint details.

Utilize this to monitor database health and retrieve the connection strings required for application configuration.

Link
aws rds describe-db-snapshots

Lists both automated and manual snapshots for a specific RDS database to verify backup availability.

Use this command to identify recovery points for restoration and to audit your database backup and retention policy.

Link

DynamoDB (Database)1

aws dynamodb list-tables

Returns a simple list of all DynamoDB table names created within the current region.

Employ this for high-level inventory management and to confirm the existence of NoSQL tables before performing data operations.

Link

DynamoDB (Data)1

aws dynamodb scan

Iterates through all items in a DynamoDB table and returns the results up to the specified limit.

Exercise caution with this command on large tables to avoid consuming excessive Read Capacity Units (RCUs).

Link

Lambda (Serverless)2

aws lambda list-functions

Provides an inventory of all deployed Lambda functions, including runtime environments and memory configurations.

Use this to audit serverless workloads and track the various microservices deployed across your account.

Link
aws lambda get-function

Retrieves the configuration metadata and a temporary download link for the function's deployment package.

Utilize this to inspect the current code version or to retrieve a package for local debugging and reverse engineering.

Link

Lambda (Execution)1

aws lambda invoke

Triggers the execution of a Lambda function and captures the output payload in a specified local file.

Use this for testing serverless logic or for manual triggering of backend processes during development and troubleshooting.

Link

ECS (Containers)2

aws ecs list-clusters

Lists all Amazon ECS clusters configured in the current region to provide an overview of container orchestration environments.

Apply this to identify active compute clusters before managing tasks, services, or container instances.

Link
aws ecs list-tasks

Enumerates the task IDs running within a specific ECS cluster to monitor active container deployments.

Employ this command to track the lifecycle of containers and to identify specific task ARNs for further inspection or termination.

Link

EKS (Kubernetes)2

aws eks list-clusters

Lists all Amazon EKS (Kubernetes) managed clusters available in the specified region.

Use this to confirm cluster availability and retrieve the names needed for updating local kubernetes configurations.

Link
aws eks update-kubeconfig

Automatically updates your local ~/.kube/config file with the necessary credentials to interact with an EKS cluster via kubectl.

Run this after creating or joining a new cluster to enable standard Kubernetes CLI management tools.

Link

CloudWatch (Monitoring)1

aws cloudwatch list-metrics

Lists the available metrics for a specific namespace, such as CPU, disk, or network metrics for EC2.

Utilize this to identify the exact metric names and dimensions required for creating custom CloudWatch alarms.

Link

CloudWatch (Logs)2

aws logs describe-log-groups

Provides a list of all log groups in CloudWatch, showing retention policies and stored data sizes.

Use this for administrative oversight of application and system logging to ensure proper data retention and cost management.

Link
aws logs filter-log-events

Searches through log events using specific patterns to quickly isolate errors or specific transaction IDs.

Apply this command during incident response to perform rapid log analysis without manually downloading large log files.

Link

CloudTrail (Auditing)2

aws cloudtrail describe-trails

Retrieves the configuration settings for CloudTrail instances to verify that API logging is active in the region.

Use this to ensure that your governance and auditing trails are correctly logging to the intended S3 buckets.

Link
aws cloudtrail get-event-selectors

Displays the specific data and management events that a trail is configured to capture for audit purposes.

Check these settings to verify that critical data operations, such as S3 object access or Lambda executions, are being logged.

Link

CloudTrail (Investigation)1

aws cloudtrail lookup-events

Searches the last 90 days of API activity for specific attributes like Username, Event Name, or Resource ID.

Employ this during security investigations to trace the actions of a specific user or to see who modified a particular resource.

Link

Secrets Manager1

aws secretsmanager list-secrets

Lists the metadata of all secrets managed in the account, including rotation status and last accessed dates.

Use this to audit your secret storage and ensure that sensitive credentials are not being hardcoded in applications.

Link

Systems Manager (SSM)2

aws ssm describe-parameters

Returns a list of all parameters stored in the SSM Parameter Store, including their types and last modified dates.

Utilize this to manage application configuration settings and to audit the usage of SecureString parameters.

Link
aws ssm start-session

Establishes a secure, encrypted shell connection to an EC2 instance via the SSM agent, bypassing the need for SSH keys.

Leverage this for secure instance management to eliminate the need for opening port 22 in your security groups.

Link

KMS (Encryption)2

aws kms list-keys

Lists the unique identifiers for all Customer Master Keys (CMKs) available in the account and region.

Use this to verify your encryption keys and to retrieve IDs for managing key policies or performing cryptographic operations.

Link
aws kms list-aliases

Displays the friendly names (aliases) mapped to KMS keys, making it easier to identify keys by purpose.

Apply this to map human-readable names to cryptic Key IDs for better management of encryption resources.

Link

Resource Groups (Tagging)1

aws resourcegroupstaggingapi get-resources

Queries the account for all resources that match specific tag criteria across multiple AWS services.

Use this for cross-service inventory management and to ensure all resources comply with organizational tagging policies.

Link

Security (GuardDuty)2

aws guardduty list-detectors

Lists the unique detector IDs for GuardDuty instances to verify that threat detection is enabled in the region.

Use this ID as a prerequisite for querying findings or managing threat intelligence sets.

Link
aws guardduty list-findings

Retrieves security finding IDs from GuardDuty, filtered by severity or finding type to prioritize response.

Focus on high-severity findings (7.0 - 8.9) to rapidly identify and remediate potential security breaches or compromises.

Link

Security (Inspector)1

aws inspector2 list-findings

Lists vulnerability findings across EC2, Lambda, and ECR resources based on continuous scanning.

Utilize this to identify software vulnerabilities and network reachability issues that require patching or configuration changes.

Link

Security (Security Hub)1

aws securityhub get-findings

Aggregates and retrieves active security alerts and compliance checks from multiple AWS security services.

Use this as a centralized dashboard for managing your overall security posture and remediating non-compliant resources.

Link

Blue Team (Audit)2

aws ec2 describe-security-groups --filters Name=ip-permission.cidr,Values=0.0.0.0/0

Identifies all security groups containing rules that allow inbound traffic from any IP address on the internet.

Run this frequently as a critical security audit to close unintended exposure points and maintain a hardened perimeter.

Link
aws iam list-mfa-devices

Checks if a specific user has at least one active Multi-Factor Authentication (MFA) device configured.

Use this to enforce MFA compliance and identify high-privilege users who are lacking an essential layer of security.

Link

WAF (Web Application Firewall)1

aws wafv2 list-web-acls

Lists all Web Access Control Lists (Web ACLs) used to protect regional resources like ALBs or API Gateways.

Apply this to manage your web application firewalls and verify that your public endpoints are protected by appropriate rule sets.

Link

Route53 (DNS)2

aws route53 list-hosted-zones

Enumerates all public and private DNS hosted zones associated with your AWS account.

Use this to manage your domain portfolio and verify the availability of DNS management zones for your applications.

Link
aws route53 list-resource-record-sets

Lists the specific DNS records (A, CNAME, TXT, etc.) contained within a designated hosted zone.

Utilize this to audit your DNS infrastructure and verify that domain routing is correctly configured for your services.

Link

Incident Response (Snapshot)1

aws ec2 create-snapshot

Captures a point-in-time backup of an EBS volume to preserve data for forensic investigation or recovery.

Execute this immediately during an incident to ensure you have a static copy of a potentially compromised system's filesystem.

Link

Incident Response (Isolation)1

aws ec2 modify-instance-attribute

Replaces the existing security groups of an instance with a restricted 'isolation' group to cut off network access.

Apply this during an active compromise to stop data exfiltration or lateral movement while keeping the instance running for analysis.

Link

Incident Response (Logs)1

aws ec2 create-flow-logs

Enables the capture of IP traffic data for network interfaces within a VPC for monitoring and troubleshooting.

Use flow logs to analyze traffic patterns, identify malicious connections, and audit network compliance across your infrastructure.

Link

Advanced Filtering (JMESPath)2

aws ec2 describe-volumes --query

Filters and lists all EBS volumes that are not currently attached to an instance, identifying potential waste.

Run this regularly to find and delete orphaned volumes, helping to reduce unnecessary storage costs in your AWS bill.

Link
aws iam list-users --query

Generates a filtered list of users who have actively used their passwords, showing their names and last login dates.

Use this to identify stale IAM users who have not logged in recently and may be candidates for credential deactivation.

Link

Cost Management1

aws ce get-cost-and-usage

Retrieves detailed cost and usage metrics from the AWS Cost Explorer API for a defined time window.

Employ this command to programmatically monitor spending trends and generate monthly financial reports for your cloud resources.

Link

Organization1

aws organizations list-accounts

Provides a list of all AWS accounts that are members of your current AWS Organization.

Use this from the management account to map your multi-account structure and track Account IDs across the enterprise.

Link

Auto Scaling2

aws autoscaling describe-auto-scaling-groups

Describes the configurations of your Auto Scaling groups, including capacity limits and health check settings.

Utilize this to monitor the scaling state of your applications and ensure that your high-availability targets are met.

Link
aws autoscaling set-desired-capacity

Manually adjusts the desired number of instances in an Auto Scaling group to scale the environment up or down.

Apply this for manual capacity adjustments during expected traffic spikes or to reduce costs during low-demand periods.

Link

Elastic Load Balancing2

aws elbv2 describe-load-balancers

Returns information about Application, Network, and Gateway Load Balancers in your environment.

Use this to retrieve the DNS names of your load balancers and to verify their operational state.

Link
aws elbv2 describe-target-health

Reports the health status of backend targets (such as EC2 instances) registered to a specific load balancer target group.

Use this for troubleshooting application availability issues by identifying which instances are failing health checks.

Link

CloudFormation (IaC)2

aws cloudformation list-stacks

Lists CloudFormation stacks based on their current status to provide an overview of deployed infrastructure.

Employ this to track the state of your Infrastructure as Code deployments and identify stacks that require cleanup or updates.

Link
aws cloudformation describe-stack-resources

Lists every AWS resource created and managed by a specific CloudFormation stack for detailed inventory mapping.

Utilize this to trace which physical resources (e.g., specific EC2 IDs or S3 buckets) belong to a logical stack.

Link

Cleanup3

aws s3 rb

Deletes an S3 bucket and uses the --force flag to remove all contained objects simultaneously.

Exercise extreme caution as this operation is permanent and cannot be undone; always verify bucket names before execution.

Link
aws ec2 terminate-instances

Permanently shuts down and deletes specified EC2 instances, releasing all associated hardware resources.

Use this only when you no longer require the instance, as termination usually results in the deletion of the root EBS volume.

Link
aws cloudformation delete-stack

Initiates the removal of a CloudFormation stack along with all the resources it previously provisioned.

Apply this for efficient environment decommissioning to ensure no orphaned resources continue to incur costs.

Link

Dry Run (Testing)1

aws ec2 run-instances --dry-run

Validates that you have the required permissions and that the parameters are correct without actually launching an instance.

Incorporate this into scripts and automation to prevent failed deployments and verify IAM authorization before runtime.

Link

Advanced Workflow (MFA)1

aws sts get-session-token

Generates temporary security credentials that include an MFA-authenticated session for an IAM user.

Use these credentials to perform actions that are protected by policies requiring Multi-Factor Authentication.

Link

Advanced Workflow (Assume Role)1

aws sts assume-role

Requests temporary security credentials for an IAM role to perform cross-account or cross-service operations.

Utilize this to adopt a different permission set without sharing long-term access keys, enhancing overall security.

Link

Backup (EBS)1

aws ec2 create-image

Creates a machine image (AMI) from an existing instance, capturing both the root and data volumes for disaster recovery.

Use the --no-reboot flag if you need to create the image while the instance is running, though this may affect filesystem consistency.

Link

Advanced Route53 & DNS1

aws route53 list-resource-record-sets

Extracts the absolute raw DNS routing matrices enabling deep auditing of CNAME, A, and TXT configurations.

Link

API Gateway & Edge2

aws apigateway get-rest-apis

Inventories all serverless REST architectures currently mapped and proxying inbound HTTP requests to Lambda endpoints.

Link
aws apigateway create-deployment

Compiles and physically pushes staged API routing changes into the live, publicly reachable requested stage.

Link

CloudFront CDN2

aws cloudfront create-invalidation

Forces Edge locations worldwide to instantly dump their localized cached versions and re-pull fresh assets from the backend origin.

Link
aws cloudfront get-distribution-config

Pulls the complex raw JSON ETag configurations managing WAF attachments, SSL certificates, and origin routing constraints.

Link

SQS Messaging2

aws sqs receive-message

Reaches into an operational SQS Queue pulling raw asynchronous message payloads for debugging broken consumer services.

Link
aws sqs purge-queue

Immediately burns down and obliterates all pending unread messages idling inside an SQS queue structure.

Link

SNS Notifications1

aws sns publish

Infects an SNS topic with a raw broadcast message, instantly triggering all associated fan-out targets (Email, SMS, Lambda hooks).

Link

Step Functions1

aws stepfunctions start-execution

Triggers complex automated multi-lambda state machine architectures providing seed JSON structures to begin algorithmic executions.

Link

Elasticache (Redis)1

aws elasticache describe-cache-clusters

Uncovers the internal DNS endpoints, instance classes, and replication structures of extremely high-speed memory cache architectures.

Link

Athena (Data Lake)1

aws athena start-query-execution

Executes raw distributed Serverless SQL queries directly against flat cold-storage S3 JSON/CSV data files.

Link

SSM Incident Manager1

aws ssm-incidents start-incident

Invokes maximum-level AWS runbook automation triggering global organizational alerts natively bypassing standard pagers.

Link