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.
Related
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
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.
Can we set Environment variable against an EC2 instance from AWS console?
Or do we need load any other service to achieve this?
Also can we load this variable insider Docker?
That appears to be out of scope for the AWS Console. EC2 however is basically AWS hosted VMs, So anything you could do normally on that OS can be done.
Just connect to the machine and do what you would normally do. (See the AWS CLI Guide for further help)
Using the AWS Console:
Stop the ec2 instance
For that ec2 instance, from top dropdown - select Actions > Instance Settings > View/Change User Data
Create a script that would add required environment variables to init scripts.
!/bin/sh echo 'export MY_ENV_VARIABLE=value' >> ~/.bashrc
or a script to /etc/init.d or other similar locations..
Start the EC2 instance for the Environment variables to be available.
If you want to pass the EC2 instance environment variable to the Docker container environment variable:
When you start a docker instance through "docker run" you can pass the value through --env param in the command line.
eg: docker run -e DOCKER_ENV_VARIABLE=$MY_ENV_VARIABLE ...
https://docs.docker.com/engine/reference/commandline/run/#options
You can use user_data to load and afterwards pass to your docker container using docker run -e CONTAINER_ENV_VAR=$EC2_ENV_VARor put in your Dockerfile.
for keys or any sensitive data I would advise you to use the Parameter Store, you can put passwords, users, or whatever data you want and use a service call chamber
I would like to launch eb deploy from a deployment script (so non interactive mode) because it's a hell of a lot easier than using aws cli
The issue is: there seems to be no way to choose a default environment during eb init (as it used to be in older version with the -e option). So if an existing application has several environment, eb cli will prompt you to choose an environment (and there is no use to select it)...
Of course you can't do eb use or eb config before doing eb cli, that would be too easy:
ERROR: This directory has not been set up with the EB CLI
You must first run "eb init".
any way to go around this ?
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.