To configure AWS CLI

aws configure

To configure to use Localstack, you simply need to do the following, where replace the URL with the one provided by the localstack when you ran it. If you want to setup localstack first, visit here

aws configure set aws_access_key_id test
aws configure set aws_secret_access_key test
aws configure set region us-east-1
aws configure set endpoint_url http://localhost:<port> --profile <service>

Create an S3 bucket:

aws s3api create-bucket --bucket mybucket

List S3 buckets:

aws s3 ls

Describe EC2 instances:

aws ec2 describe-instances

Start an EC2 instance:

aws ec2 start-instances --instance-ids i-1234567890abcdef0

List DynamoDB tables:

aws dynamodb list-tables

Create a DynamoDB table:

aws dynamodb create-table --table-name MyTable --attribute-definitions AttributeName=MyKey,AttributeType=S --key-schema AttributeName=MyKey,KeyType=HASH --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5

List Lambda functions:

aws lambda list-functions

Create a Lambda function:

aws lambda create-function --function-name MyFunction --runtime nodejs14.x --role arn:aws:iam::123456789012:role/MyRole --handler index.handler --code S3Bucket=mybucket,S3Key=mycode.zip

Create an SNS topic:

aws sns create-topic --name MyTopic

List SNS topics:

aws sns list-topics

Create an SQS queue:

aws sqs create-queue --queue-name MyQueue

List SQS queues:

aws sqs list-queues

Create an IAM user:

aws iam create-user --user-name MyUser

List IAM users:

aws iam list-users

Create a Kinesis stream:

aws kinesis create-stream --stream-name MyStream --shard-count 1

List Kinesis streams:

aws kinesis list-streams

List RDS DB instances:

aws rds describe-db-instances

Create an RDS DB instance (requires more detailed configuration):

aws rds create-db-instance ...

List Elasticsearch domains:

aws es list-domain-names 

Create an Elasticsearch domain (requires more detailed configuration):

aws es create-elasticsearch-domain ... 

Upload a file to an S3 bucket:

aws s3 cp /path/to/localfile s3://mybucket/myfile

Download file from s3 bucket:

aws s3 cp  s3://mybucket/myfile /path/to/folder

List objects in an S3 bucket:

aws s3 ls mybucket

List CloudWatch alarms:

aws cloudwatch describe-alarms

Put metric data (simulating metrics):

aws cloudwatch put-metric-data --namespace MyNamespace --metric-name MyMetric --value 1 

List ECS clusters:

aws ecs list-clusters

Create an ECS cluster:

aws ecs create-cluster --cluster-name MyCluster

List EKS clusters:

aws eks list-clusters

Create an EKS cluster (requires more detailed configuration):

aws eks create-cluster ...

Create an SNS subscription for a topic:

aws sns subscribe --topic-arn arn:aws:sns:us-east-1:123456789012:MyTopic --protocol email --notification-endpoint your@email.com

Publish a message to an SNS topic:

aws sns publish --topic-arn arn:aws:sns:us-east-1:123456789012:MyTopic --message "Hello, world!"

Send a message to an SQS queue:

aws sqs send-message --queue-url http://localhost:4576/queue/MyQueue --message-body "Hello, SQS!"

Receive a message from an SQS queue:

aws sqs receive-message --queue-url http://localhost:4576/queue/MyQueue

List ElastiCache clusters:

aws elasticache describe-cache-clusters

Create an ElastiCache cluster (requires more detailed configuration):

aws elasticache create-cache-cluster ...

List KMS keys:

aws kms list-keys

Create a KMS key (requires more detailed configuration):

aws kms create-key ...

Create a CloudFormation stack (requires a CloudFormation template):

aws cloudformation create-stack --stack-name MyStack --template-body file://my-template.json 

List CloudFormation stacks:

aws cloudformation list-stacks

List hosted zones:

aws route53 list-hosted-zones

Create a hosted zone:

aws route53 create-hosted-zone --name example.com --caller-reference example-001

Describe ElastiCache clusters:

aws elasticache describe-cache-clusters

Create an ElastiCache replication group (requires more detailed configuration):

aws elasticache create-replication-group ...

List state machines:

aws stepfunctions list-state-machines --endpoint-url http://localhost:4585

Create a state machine (requires a Step Functions definition):

aws stepfunctions create-state-machine --name MyStateMachine --definition file://state-machine-definition.json --role-arn arn:aws:iam::123456789012:role/MyRole

List ElastiCache Redis clusters:

aws elasticache describe-replication-groups

Create an ElastiCache Redis cluster (cluster mode enabled):

aws elasticache create-replication-group ... --replication-group-description "My Redis Cluster"

List App Runner services:

aws apprunner list-services

Create an App Runner service (requires more detailed configuration):

aws apprunner create-service ... --source-code file://apprunner-source-code.json

List Pinpoint projects:

aws pinpoint list-projects

Create a Pinpoint project (requires more detailed configuration):

aws pinpoint create-app ...

Update an App Runner service:

aws apprunner update-service --service-id MyServiceID --source-code file://updated-source-code.json

Delete an App Runner service:

aws apprunner delete-service --service-id MyServiceID

List MediaConvert jobs:

aws mediaconvert list-jobs

Create a MediaConvert job (requires a job JSON configuration):

aws mediaconvert create-job --cli-parameters file://mediaconvert-job.json

List Fargate clusters:

aws ecs list-clusters

Create a Fargate cluster:

aws ecs create-cluster --cluster-name MyFargateCluster --capacity-providers FARGATE

Describe a state machine:

aws stepfunctions describe-state-machine --state-machine-arn arn:aws:states:us-east-1:123456789012:stateMachine:MyStateMachine

Delete a state machine:

aws stepfunctions delete-state-machine --state-machine-arn arn:aws:states:us-east-1:123456789012:stateMachine:MyStateMachine

List Cognito user pools:

aws cognito-idp list-user-pools

Create a Cognito user pool:

aws cognito-idp create-user-pool --pool-name MyUserPool

Describe Elasticsearch domains:

aws es describe-elasticsearch-domain --domain-name MyElasticsearchDomain 

Delete an Elasticsearch domain:

aws es delete-elasticsearch-domain --domain-name MyElasticsearchDomain 

List DataSync tasks:

aws datasync list-tasks

Create a DataSync task (requires more detailed configuration):

aws datasync create-task ...

Related Posts