How to update Amazon elasticbeanstalk CLI - amazon-web-services

When running a command with eb:
It prompts me:
Alert: An update to this CLI is available.
Although I can't find any options to update from specified command line options:
$ eb -h
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:
clone Clones an environment.
config Edits the environment configuration settings or manages 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.
init Initializes your directory with the EB CLI. Creates the application.
list Lists all environments.
logs Gets recent logs.
open Opens the application URL in a browser.
printenv Shows the environment variables.
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.
terminate Terminates the environment.
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 do not verify AWS SSL certificates
--version show application/version info
To get started type 'eb init'. Then type 'eb create' and 'eb open'
It also doesn't specify how in any documentation. EB CLI 3.x.
Thanks!

You can update the CLI by running pip install --upgrade awsebcli

Sorry I installed by homebrew (OS X).
brew update && brew upgrade aws-elasticbeanstalk
Having said that, the version available via pip is more likely to stay up-to-date over time than the Homebrew version.

Related

Jenkins ecs Command not found

I installed third party tool (ecs deploy using pip install ecs-deploy) .When I try to deploy using command ecs deploy demo-cluster demo-service in command prompt its working fine when I try with jenkins to deploy getting error
/tmp/jenkins5062380414579854312.sh: line 13: ecs: command not found
Build step 'Execute shell' marked build as failure
Finished: FAILURE
The Jenkins service runs typically runs under the user jenkins.
You have installed the package as the ec2-user. This means the jenkins user may not have the package in its own path or have correct permissions to execute the file.
You can correct this one of two ways:
Use sudo to elevate permissions and install it globally. Set the path in /etc/environment
Interactively login as the jenkins user and install under that account.
You need to run the full AWS CLI command:
aws ecs deploy --cluster demo-cluster --service demo-service

TeamCity Agent - AWS CLI

I have deployed TeamCity server and Agent to AWS using JetBrains Stack Template (https://www.jetbrains.com/help/teamcity/running-teamcity-stack-in-aws.html)
All seems to be good, my server starts, agent is functional, I have created several builds, etc.
I came to a point, where I want to deploy my application to AWS environment using aws-cli commands.
I am struggling to enable/install aws-cli into agent. My build steps are erroring out with aws: command not found
Does anyone have any ideas?
My progress so far: I have connected to agent EC2 machine via ssh bastion ec2, and I am able to invoke aws --version as ec2-user, but the build agent cannot see aws.
Turns out, my TeamCity agent runs in AWS ECS via docker image https://hub.docker.com/r/jetbrains/teamcity-agent
What I ended up doing is creating my own docker image by using jetbrains one as a base.
I uploaded my docker image to AWS ECS Repository. Afterwards I created a new revision for original task definition. This new revision uses my image instead of original one, therefore I have aws-cli there.
I then added my AWS profile to EC2 host machine and added volume to docker container (via task definition) so that container would be able to access .aws/credentials file.
Dockerfile looks like this:
FROM jetbrains/teamcity-agent
RUN apt-get update && apt-get install -y python-pip
RUN pip install awscli --upgrade --user
ENV PATH="~/.local/bin:${PATH}"
I added the aws-cli in team city agent using remote desktop connection as I used window agent of team city. In the build steps I used Runner Type as command line and executed the aws commands.
for more information you can refer below link where I answered the question:
How to deploy to AWS Elastic Beanstalk on successful Teamcity build

How do I link a project source folder to an existing Elastic Beanstalk application?

I've been using the AWS console to upload a WAR file for deployment. Now I want to do it from the command line. I've been following this guide and see eb init and read the help with eb init --help and eb --help, but the only option is to create a new application.
usage: eb init <application_name> [options ...]
Initializes your directory with the EB CLI. Creates the application.
positional arguments:
application_name application name
How do I link my local source project directory to an existing application in AWS console?
I would expect a command like eb link or something, like how you can just add a Git remote with Heroku and automatically link an existing project to an existing app.
When you perform eb init in the directory containing your source code, eb will prompt you for an application name and an environment name. This way you can link your source code to what ever application/environment is deployed on Beanstalk.
It worked after I got the AWS CLI keys for the project and ran aws configure. I had old keys in ~/.aws/ from a different project from perhaps a decade ago that used a different format. Once I got new keys, that were given permission for these particular apps, and ran aws configure and set the region, then eb init would present a menu of applications to choose from. The command aws elasticbeanstalk describe-applications has to work first before eb can work. I was expecting it would ask for a username and password, like Heroku does.
Install aws and eb command line tools:
Install awscli
Get keys from AWS admin devops.
aws configure (Example Region: 'us-east-1')
aws elasticbeanstalk describe-applications
Install Python
pip install awsebcli --upgrade --user
Add eb to your PATH, probably %USERPROFILE%\AppData\Roaming\Python\Python37\Scripts
eb init
eb list / eb logs / eb ssh / eb status / eb config / eb help
Beanstalk differs from Heroku in this workflow, unless you are using CodeCommit. I am assuming you are just using S3 to store your application versions.
The EBCLI command to do this is:
eb create-application-version
You can specify an application, a version label, as well as either a CodeCommit repository, a codeBuild build, or a source bundle in S3. API docs
You will need to run a separate command before create-application-version to upload to your S3 bucket.
Using the CLI:
aws s3 cp <filename> <s3bucket>
API docs
You can also use the console.
It seems like that guide skips initializing your local git repository. For linking your local source project to beanstalk, make sure you have initialized a local git repository. Then you can link your workspace and application using eb init. more about EB CLI and Git
Based on my understanding, your question is that you had a project directory on your PC and run your app at the localhost, now you want to run it in the AWS Elastic Beanstalk to make it public.
If you have created an EB application in the EB management console and uploaded your bundled source code, the source code becomes an application version, you need to deploy it into one of your environment using the EB management console, like this:
Figure of the management console.
Then the EB platform(container) will take care of that and run your server automatically as long as you set up the command which your app uses to run the server, the proxy, and other configurations either through the EB management console -> [Your environment] -> configuration or using the .ebextensions file.
If everything is well, you can visit your app's home page through the environment URL at that time.

aws command not found error even after installing aws cli on jenkins windows slave when running a jenkins job

I have installed AWS CLI on my windows slave in Jenkins. To verify the same, I run the following command in the command line of the windows machine and get this as the output
C:> aws --version
aws-cli/1.11.122 Python/2.7.9 Windows/2008ServerR2 botocore/1.5.85
I am running an aws cli command in the execute windows batch command in the jenkins job and the job is failing for the following reason
C:\Users\ADMINI~1\AppData\Local\Temp\2\hudson1929374596375903011.sh: line 6:
aws: command not found
Build step 'Execute shell' marked build as failure
The aws command I am running is
aws cloudformation validate-template --template-body file://file1.json
I also checked the PATH variable on the windows machine and it contains AWSCLI path.
My goal is to run AWS CLI command via Jenkins job. Can somebody help me with this?
It's possible that Jenkins has a different %PATH% than when you are logged in.
Try finding your path via jenkins. Create a job and in the script that runs echo out your %PATH% to see what jenkins' thinks your path is.
You can modify Jenkins' environment variables, including %PATH%, see https://stackoverflow.com/a/5819768/8207662

eb delete not recognised by AWS Elastic Beanstalk

I'm in a virtualenv. I installed awsebcli like so: pip install awsebcli.
I then did eb init -p python3.4 django-tutorial and it said Application django-tutorial has been created.. I want to now delete this application. I tried doing eb delete but it says
usage: eb (sub-commands ...) [options ...] {arguments ...}
eb: error: unrecognized arguments: delete
I then tried eb delete -a django-tutorial and it said
usage: eb (sub-commands ...) [options ...] {arguments ...}
eb: error: unrecognized arguments: delete -a django-tutorial
I then just typed eb and "delete" was not one of the listed commands. These were the commands listed:
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 Manages 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.
terminate Terminates the environment.
upgrade Updates the environment to the most recent platform version.
use Sets default environment.
How do I delete the application I initialised and how come eb is not recognising delete as a command?
Edit: Just noticed eb stop doesn't exist either but from this link:
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/delete.html
eb stop and eb delete should both exist.
Try eb terminate --all to delete the application, and make sure you're looking at the current EB documentation.