different versions of eb cli if running under super user - amazon-web-services

If I run in the shell (Ubuntu):
sudo eb --version
I get
EB CLI 3.4.5 (Python 2.7.6)
However, if I run
eb --version
I get
AWS Elastic Beanstalk Command Line Interface v2.6.3
I wonder why it happens?

Related

Why is the aws cli not found on amazonlinux2 ami?

The AmazonLinux2 AMI I am using for my Docker hosts does not appear to have the AWS CLI installed. The log has an error from the user data script that tries to run an aws command:
/var/lib/cloud/instance/scripts/part-001: line 7: aws: command not found
Then I connected with SSH to the instance for a sanity check, and aws is definitely not found:
[ec2-user#ip-X-X-X-X ~]$ cat /etc/os-release
NAME="Amazon Linux"
VERSION="2"
ID="amzn"
ID_LIKE="centos rhel fedora"
VERSION_ID="2"
PRETTY_NAME="Amazon Linux 2"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2"
HOME_URL="https://amazonlinux.com/"
[ec2-user#ip-X-X-X-X ~]$ aws --version
-bash: aws: command not found
I thought the AWS CLI was installed by default on all AmazonLinux AMIs? I don't remember ever having to install it myself before.
This article even says that the CLI v1 is installed by default on AmazonLinux2:
AWS Docs Link
So how is it possible that it's not found on this stock AMI? Do only some of the AmazonLinux2 AMIs have the CLI pre-installed? For reference, I am using this AMI:
amzn2-ami-minimal-hvm-2.0.20200917.0-x86_64-ebs (ami-0a6993b2978bd23cb)
From this post on AWS forum:
Minimal has a smaller set of packages installed by default. For example, a lot of AWS specific packages are installed on the default for easy integration to other AWS services. The minimal do not have these installed. This gives a much lower footprint for those who are not directly interacting with other AWS services, or who want to cherry-pick which ones they install.
If you want awscli, you can install it:
sudo yum install -y awscli
to install the latest version of the awscli (v2) see this doc
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install

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

How can i Configure aws cli profile with Elastic Beanstack?

I am using Elastic Beanstack for deploying my application. During deploying I have to run some command. So I have prepare .ebextensions script for it. which my script does
python (pip)
aws cli
and some aws command which i need to configure the aws profile (aws configure)
So how can I configure the aws profile with Elastic Beanstack in batch script in .ebextensions.
Elastic Beanstalk uses a different program for the command line interface.
To install awsebcli for Linux:
pip install awsebcli --upgrade --user
For Windows:
Install Python, pip, and the EB CLI on Windows

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

How to update Amazon elasticbeanstalk CLI

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.