AWS EB CLI

This is a CLI that is specific to EB (Elastic Beanstalk)

It can be installed in Powershell

https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb-cli3-install.html

https://github.com/aws/aws-elastic-beanstalk-cli-setup

https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb-cli3-configuration.html

https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb-cli3-getting-started.html


Installing video

https://www.youtube.com/watch?v=5jG-LSBJzoI



used "home-brew" on mac
brew install awsebcli


Derricks-iMac:~ derricksobrien$ python --version
Python 2.7.16
Derricks-iMac:~ derricksobrien$ cd applications
Derricks-iMac:applications derricksobrien$ pwd
/Users/derricksobrien/applications
Derricks-iMac:applications derricksobrien$ ls
Chrome Apps.localized LogMeIn Client.app
GoToMeeting nodejs-v1
Derricks-iMac:applications derricksobrien$ cd nodejs-v1
Derricks-iMac:nodejs-v1 derricksobrien$ pwd
/Users/derricksobrien/applications/nodejs-v1
Derricks-iMac:nodejs-v1 derricksobrien$ ls
app.js cron.yaml index.html package.json
Derricks-iMac:nodejs-v1 derricksobrien$ eb -version
/usr/local/Cellar/aws-elasticbeanstalk/3.17.1/libexec/lib/python3.8/site-packages/jmespath/visitor.py:32: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if x is 0 or x is 1:
/usr/local/Cellar/aws-elasticbeanstalk/3.17.1/libexec/lib/python3.8/site-packages/jmespath/visitor.py:32: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if x is 0 or x is 1:
/usr/local/Cellar/aws-elasticbeanstalk/3.17.1/libexec/lib/python3.8/site-packages/jmespath/visitor.py:34: SyntaxWarning: "is" with a literal. Did you mean "=="?
  elif y is 0 or y is 1:
/usr/local/Cellar/aws-elasticbeanstalk/3.17.1/libexec/lib/python3.8/site-packages/jmespath/visitor.py:34: SyntaxWarning: "is" with a literal. Did you mean "=="?
  elif y is 0 or y is 1:
/usr/local/Cellar/aws-elasticbeanstalk/3.17.1/libexec/lib/python3.8/site-packages/jmespath/visitor.py:260: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if original_result is 0:
/usr/local/Cellar/aws-elasticbeanstalk/3.17.1/libexec/lib/python3.8/site-packages/ebcli/display/screen.py:442: SyntaxWarning: assertion is always true, perhaps remove parentheses?
  assert(
/usr/local/Cellar/aws-elasticbeanstalk/3.17.1/libexec/lib/python3.8/site-packages/semantic_version/base.py:92: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if self.prerelease and self.minor is 0 and self.patch is 0:
/usr/local/Cellar/aws-elasticbeanstalk/3.17.1/libexec/lib/python3.8/site-packages/semantic_version/base.py:92: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if self.prerelease and self.minor is 0 and self.patch is 0:
/usr/local/Cellar/aws-elasticbeanstalk/3.17.1/libexec/lib/python3.8/site-packages/semantic_version/base.py:98: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if self.prerelease and self.patch is 0:
/usr/local/Cellar/aws-elasticbeanstalk/3.17.1/libexec/lib/python3.8/site-packages/ebcli/controllers/create.py:201: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if instance_types is "":
usage: eb (sub-commands ...) [options ...] {arguments ...}
eb: error: argument -v/--verbose: ignored explicit argument 'ersion'
Derricks-iMac:nodejs-v1 derricksobrien$ eb --version
EB CLI 3.17.1 (Python 3.8.1)
Derricks-iMac:nodejs-v1 derricksobrien$ eb init

Select a default region
1) us-east-1 : US East (N. Virginia)
2) us-west-1 : US West (N. California)
3) us-west-2 : US West (Oregon)
4) eu-west-1 : EU (Ireland)
5) eu-central-1 : EU (Frankfurt)
6) ap-south-1 : Asia Pacific (Mumbai)
7) ap-southeast-1 : Asia Pacific (Singapore)
8) ap-southeast-2 : Asia Pacific (Sydney)
9) ap-northeast-1 : Asia Pacific (Tokyo)
10) ap-northeast-2 : Asia Pacific (Seoul)
11) sa-east-1 : South America (Sao Paulo)
12) cn-north-1 : China (Beijing)
13) cn-northwest-1 : China (Ningxia)
14) us-east-2 : US East (Ohio)
15) ca-central-1 : Canada (Central)
16) eu-west-2 : EU (London)
17) eu-west-3 : EU (Paris)
18) eu-north-1 : EU (Stockholm)
19) ap-east-1 : Asia Pacific (Hong Kong)
20) me-south-1 : Middle East (Bahrain)
(default is 3): 1
You have not yet set up your credentials or your credentials are incorrect 
You must provide your credentials.
(aws-access-id): 
(aws-secret-key): 
ERROR: NotAuthorizedError - Operation Denied. The security token included in the request is invalid.
Derricks-iMac:nodejs-v1 derricksobrien$ eb init

Select a default region
1) us-east-1 : US East (N. Virginia)
2) us-west-1 : US West (N. California)
3) us-west-2 : US West (Oregon)
4) eu-west-1 : EU (Ireland)
5) eu-central-1 : EU (Frankfurt)
6) ap-south-1 : Asia Pacific (Mumbai)
7) ap-southeast-1 : Asia Pacific (Singapore)
8) ap-southeast-2 : Asia Pacific (Sydney)
9) ap-northeast-1 : Asia Pacific (Tokyo)
10) ap-northeast-2 : Asia Pacific (Seoul)
11) sa-east-1 : South America (Sao Paulo)
12) cn-north-1 : China (Beijing)
13) cn-northwest-1 : China (Ningxia)
14) us-east-2 : US East (Ohio)
15) ca-central-1 : Canada (Central)
16) eu-west-2 : EU (London)
17) eu-west-3 : EU (Paris)
18) eu-north-1 : EU (Stockholm)
19) ap-east-1 : Asia Pacific (Hong Kong)
20) me-south-1 : Middle East (Bahrain)
(default is 3): 14
ERROR: The current user does not have the correct permissions. Reason: Operation Denied. The security token included in the request is invalid.
ERROR: The current user does not have the correct permissions. Reason: Operation Denied. The security token included in the request is invalid.
You have not yet set up your credentials or your credentials are incorrect 
You must provide your credentials.
(aws-access-id): AKIAVD3P44SUZPTRJH4X
(aws-secret-key): 0WHBhP+0ntvxGiLPpL2N+J8cax/v7RcEd4Fr+Sl4

Select an application to use
1) getting-started-app
2) mokojumbie
3) [ Create new Application ]
(default is 3): 3

Enter Application Name
(default is "nodejs-v1"): 
Application nodejs-v1 has been created.

It appears you are using Node.js. Is this correct?
(Y/n): y
Cannot setup CodeCommit because there is no Source Control setup, continuing with initialization
Do you want to set up SSH for your instances?
(Y/n): 1
You did not provide a valid value. Type either "Y" or "N".
(Y/n): y

Type a keypair name.
(Default is aws-eb): 
Generating public/private rsa key pair.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /Users/derricksobrien/.ssh/aws-eb.
Your public key has been saved in /Users/derricksobrien/.ssh/aws-eb.pub.
The key fingerprint is:
SHA256:PobOTy2FNw9SPvGF/4sd7HW5Al0hnggiqApKfgXzMWs aws-eb
The key's randomart image is:
+---[RSA 2048]----+
|    .            |
|   + + . .   o . |
|  . + = . + + + .|
|.o   E   + + = . |
|*   o   S B o o  |
|o. .   o = * ....|
|  .   . * . o  ++|
|     o o o   .+ *|
|      o..    ..= |
+----[SHA256]-----+
WARNING: Uploaded SSH public key for "aws-eb" into EC2 for region us-east-2.
Derricks-iMac:nodejs-v1 derricksobrien$ ls
app.js cron.yaml index.html package.json
Derricks-iMac:nodejs-v1 derricksobrien$ eb create
Enter Environment Name
(default is nodejs-v1-dev): 
Enter DNS CNAME prefix
(default is nodejs-v1-dev): 

Select a load balancer type
1) classic
2) application
3) network
(default is 2): 1

Would you like to enable Spot Fleet requests for this environment?
(y/N): 
Creating application version archive "app-200305_173806".
Uploading nodejs-v1/app-200305_173806.zip to S3. This may take a while.
Upload Complete.
Environment details for: nodejs-v1-dev
  Application name: nodejs-v1
  Region: us-east-2
  Deployed Version: app-200305_173806
  Environment ID: e-wgptm3mcbr
  Platform: arn:aws:elasticbeanstalk:us-east-2::platform/Node.js running on 64bit Amazon Linux/4.13.1
  Tier: WebServer-Standard-1.0
  CNAME: nodejs-v1-dev.us-east-2.elasticbeanstalk.com
  Updated: 2020-03-06 00:38:09.616000+00:00
Printing Status:
2020-03-06 00:38:08    INFO    createEnvironment is starting.
2020-03-06 00:38:09    INFO    Using elasticbeanstalk-us-east-2-351885124777 as Amazon S3 storage bucket for environment data.
2020-03-06 00:38:30    INFO    Created security group named: sg-0232603115b4bda80
2020-03-06 00:38:30    INFO    Created load balancer named: awseb-e-w-AWSEBLoa-187R7BUPGAPXZ
2020-03-06 00:38:46    INFO    Created security group named: awseb-e-wgptm3mcbr-stack-AWSEBSecurityGroup-1OUWQ9WUEB1OM
2020-03-06 00:38:46    INFO    Created Auto Scaling launch configuration named: awseb-e-wgptm3mcbr-stack-AWSEBAutoScalingLaunchConfiguration-1NRSDLU4SP8U
2020-03-06 00:40:04    INFO    Created Auto Scaling group named: awseb-e-wgptm3mcbr-stack-AWSEBAutoScalingGroup-17WO6VZ95UWW
2020-03-06 00:40:04    INFO    Waiting for EC2 instances to launch. This may take a few minutes.
2020-03-06 00:40:04    INFO    Created Auto Scaling group policy named: arn:aws:autoscaling:us-east-2:351885124777:scalingPolicy:57a0f5e7-f635-48f6-b964-9126f82f5a72:autoScalingGroupName/awseb-e-wgptm3mcbr-stack-AWSEBAutoScalingGroup-17WO6VZ95UWW:policyName/awseb-e-wgptm3mcbr-stack-AWSEBAutoScalingScaleUpPolicy-NZSXJ4BVVRFL
2020-03-06 00:40:04    INFO    Created Auto Scaling group policy named: arn:aws:autoscaling:us-east-2:351885124777:scalingPolicy:ea4876e9-d9b0-448b-98f5-71792e0e4111:autoScalingGroupName/awseb-e-wgptm3mcbr-stack-AWSEBAutoScalingGroup-17WO6VZ95UWW:policyName/awseb-e-wgptm3mcbr-stack-AWSEBAutoScalingScaleDownPolicy-1VIMT66HMO9QV
2020-03-06 00:40:19    INFO    Created CloudWatch alarm named: awseb-e-wgptm3mcbr-stack-AWSEBCloudwatchAlarmHigh-117J6BQ9D8H0
2020-03-06 00:40:19    INFO    Created CloudWatch alarm named: awseb-e-wgptm3mcbr-stack-AWSEBCloudwatchAlarmLow-LM9O3QNA37E5
2020-03-06 00:40:54    INFO    Application available at nodejs-v1-dev.us-east-2.elasticbeanstalk.com.
2020-03-06 00:40:55    INFO    Successfully launched environment: nodejs-v1-dev
                                
Derricks-iMac:nodejs-v1 derricksobrien$ eb open
Derricks-iMac:nodejs-v1 derricksobrien$ h
-bash: h: command not found
Derricks-iMac:nodejs-v1 derricksobrien$ eb
usage: eb (sub-commands ...) [options ...] {arguments ...}

Welcome to the Elastic Beanstalk Command Line Interface (EB CLI). 
For more information on a specific command, type "eb {cmd} --help".

commands:
  abort        Cancels an environment update or deployment.
  appversion   Listing and managing application versions
  clone        Clones an environment.
  codesource   Configures the code source for the EB CLI to use by default.
  config       Modify an environment's configuration. Use subcommands to manage saved configurations.
  console      Opens the environment in the AWS Elastic Beanstalk Management Console.
  create       Creates a new environment.
  deploy       Deploys your source code to the environment.
  events       Gets recent events.
  health       Shows detailed environment health.
  init         Initializes your directory with the EB CLI. Creates the application.
  labs         Extra experimental commands.
  list         Lists all environments.
  local        Runs commands on your local machine.
  logs         Gets recent logs.
  open         Opens the application URL in a browser.
  platform     Commands for managing platforms.
  printenv     Shows the environment variables.
  restore      Restores a terminated environment.
  scale        Changes the number of running instances.
  setenv       Sets environment variables.
  ssh          Opens the SSH client to connect to an instance.
  status       Gets environment information and status.
  swap         Swaps two environment CNAMEs with each other.
  tags         Allows adding, deleting, updating, and listing of environment tags.
  terminate    Terminates the environment.
  upgrade      Updates the environment to the most recent platform version.
  use          Sets default environment.

optional arguments:
  -h, --help            show this help message and exit
  --debug               toggle debug output
  --quiet               suppress all output
  -v, --verbose         toggle verbose output
  --profile PROFILE     use a specific profile from your credential file
  -r REGION, --region REGION
                        use a specific region
  --no-verify-ssl       don't verify AWS SSL certificates
  --version             show application/version info

To get started type "eb init". Then type "eb create" and "eb open"
Derricks-iMac:nodejs-v1 derricksobrien$ eb --status
usage: eb (sub-commands ...) [options ...] {arguments ...}
eb: error: unrecognized arguments: --status
Derricks-iMac:nodejs-v1 derricksobrien$ eb status
Environment details for: nodejs-v1-dev
  Application name: nodejs-v1
  Region: us-east-2
  Deployed Version: app-200305_173806
  Environment ID: e-wgptm3mcbr
  Platform: arn:aws:elasticbeanstalk:us-east-2::platform/Node.js running on 64bit Amazon Linux/4.13.1
  Tier: WebServer-Standard-1.0
  CNAME: nodejs-v1-dev.us-east-2.elasticbeanstalk.com
  Updated: 2020-03-06 00:40:55.064000+00:00
  Status: Ready

  Health: Green


"eb deploy" to update

auto deploy using scripts, java SDK or nodejs SDK


---

BASH file commands
ls
pwd
tab.. autocompletes


Created a new folder with updated app (v2)

Edited the main HTML with vi

vi <filename.html>
insert mode = <shift> i
esc
write and quit = <shift>:wq

select correct folder for app and 
eb create

Get Started

  • $ mkdir HelloWorld
  • $ cd HelloWorld
  • $ eb init -p PHP
  • $ echo "Hello World" > index.html
  • $ eb create dev-env
  • $ eb open

To deploy updates to your applications, use ‘eb deploy’.
eb status dev-env (stay in the same directory)
eb health dev-env



Comments

Popular posts from this blog

AWS, Elastic Beanstalk - Answers

AWS resources

AWS CLI