Showing posts with label AWS CLI. Show all posts
Showing posts with label AWS CLI. Show all posts

AWS CLI Elastic Beanstalk cheat sheet

In our last post we have seen how to use EB CLI for managing elastic beanstalk through command line.  But, you can also manage elastic beanstalk using traditional AWS CLI. In this post you will find  AWS CLI cheat sheet for the same.
If you are new to Elastic Beanstalk, it’s recommended that you go through this free AWS Elastic Beanstalk crash course.
Below are the major commands used frequently while managing the elastic beanstalk environment.
To check the availability of a CNAME
aws elasticbeanstalk check-dns-availability --cname-prefix my-cname
To create a new application
aws elasticbeanstalk create-application --application-name CldVdsApp --description "my application"
Compose Environments
 aws elasticbeanstalk compose-environments --application-name media-library --group-name dev --version-labels front-v1 worker-v1
To create a new environment for an application
The following command creates a new environment for version “v1” of a java application named “CldVdsApp”:
aws elasticbeanstalk create-environment --application-name CldVdsApp --environment-name my-env --cname-prefix CldVdsApp --version-label v1 --solution-stack-name "64bit Amazon Linux 2015.03 v2.0.0 running Tomcat 8 Java 8"
To specify a JSON file to define environment configuration options
The following create-environment command specifies that a JSON file with the name myoptions.jsonshould be used to override values obtained from the solution stack or the configuration template:
aws elasticbeanstalk create-environment --environment-name sample-env --application-name CldVdsApp --option-settings file://myoptions.json
To create a storage location
The following command creates a storage location in Amazon S3:
aws elasticbeanstalk create-storage-location
To abort a deployment
aws elasticbeanstalk abort-environment-update --environment-name my-env
To delete an application
The following command deletes an application named CldVdsApp:
aws elasticbeanstalk delete-application --application-name CldVdsApp
You can refer the complete set of AWS CLI for elastic beanstalk on this link.
Note:- All the above commands are taken from different AWS CLI reference guides and put in one place over here. Please run the commands after due diligence as we won’t be responsible for any mistakes in executing the commands and it’s consequences.  If you have any concern or query feel free to contact us or comment below.

AWS EB CLI Cheat Sheet - Elastic Beanstalk

In this post we will discuss about the Elastic Beanstalk CLI called EB CLI.
If you are new to Elastic Beanstalk, it’s recommended that you go through this free AWS Elastic Beanstalk crash course.
If you want to manage Elastic Beanstalk using traditional AWS CLI follow this post .
Installation
Follow these guides to install eb cli on Windows, Linux and MacOS .
Get help
eb -h
Initialize eb cli
eb init
It will ask questions:-
  • Default region
  • Access key details
  • Select existing application or create new.
  • Application name
  • Platform e.g. PHP, Python etc.
  • Setup ssh
  • Select keypair or create one.
Create environment
eb create
Check status
eb status
Check health information
eb health
Check events
eb events
Pull logs
eb logs
Open environment website in browser
eb open
Deploy Update
eb deploy
Check configuration options
eb config
Terminate environment
eb terminate
List  environments
eb list
Change current environment
eb use cldvds-env
Below are some other useful commands
eb abortCancel deployment
eb appversionManage EB application versions
eb cloneCreate clone of environment
eb consoleOpen environment in AWS console
eb labsExtra commands for experiment
eb localRun commands on local machine
eb platformManage platform
eb printenvShow environment variables
eb restorerebuild a terminated environment
eb scaleScaling the number of instances.
eb setenvSet environment variables
eb sshConnect to instance via ssh
eb swapSwap CNAME of two environments
eb tagsModify environment tags
eb upgradeUpdate the platform to most recent version
Above list is created by referring the AWS doc for elastic beanstalk cli . If you have any query or concern please feel free to contact us.

AWS S3 CLI - Cheat sheet

Below is the cheat sheet of AWS CLI commands for S3.
If you are new to S3 it’s recommended that you go through this free AWS S3 crash course.
If you want to know how to install AWS CLI, follow steps on this post.
Get help
aws s3 help
or
aws s3api help
Create bucket
aws s3 mb s3://bucket-name 
Removing bucket
aws s3 rb s3://bucket-name
To remove a non-empty bucket (Extremely careful while running this). This will remove all contents in the bucket including subfolders and data in them.
aws s3 rb s3://bucket-name --force
Copy object
aws s3 cp mypic.png s3://mybucket/
Copy buckets
aws s3 cp myfolder s3://mybucket/myfolder --recursive
(Note: –recursive will copy recursively everything including the subfolders)
Sync buckets
 aws s3 sync <source> <target> [--options]

List buckets
aws s3 ls
List specific bucket
aws s3 ls s3://mybucket
Bucket location
aws s3api get-bucket-location --bucket <bucket-name>
Logging status
aws s3api get-bucket-logging --bucket <bucket-name>
ACL (Access Control List)
The following example copies an object into a bucket. It grants read permissions on the object to everyone and full permissions (read, readacl, and writeacl) to the account associated with user@example.com.
aws s3 cp file.txt s3://my-bucket/ --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers full=emailaddress=user@example.com

Solved: How to download a complete S3 bucket or a S3 folder?

If you ever want to download an entire S3 folder you can do it with CLI.
You can download the AWS CLI from this page. AWS CLI Download
Download the AWS CLI as per your system Window, Linux or Mac.
In our case we use Windows 64 bit. Once you donwload the .exe simply double click on it to install the AWS CLI.
Once the AWS CLI is installed go to windows command prompt(CMD) and enter command
aws configure
It will ask for the AWS user details with which you want to login and region name. Check this post to know How to create an IAM user.
You can get the AWS IAM user access details from IAM console .
Get Region name here .
Fill in the user details as below:

AWS Access Key ID: <Key ID of the user>
AWS Secret Access Key: <Secret key of the user>D
region Name : <us-east-1> 
Default output format: None

Once you have downloaded and configured AWS CLI on your machine you have to exceute “sync” command as shown below.
aws s3 sync s3://mybucket/dir  /local/folder
You can also do the same with “cp” command. It will need –recursive option to recursively copy the contents of subdirectories also.
aws s3 cp s3://myBucket/dir /local/folder --recursive
Refer to this S3 cheat sheet to learn more tricks.