How to connect to existing elastic beanstalk instance locally from cli? - amazon-web-services

I am very much new to aws. I have created an environment in elastic beanstalk and deployed my application there using zipped code. The application is up and running now. Now i want to stop and start my elastic beanstalk instance from cli in windows. I could not find any stop button in the aws elastic beanstalk console.
I have installed awsebcli using below command:
pip install awsebcli
Now, i want to connect to my existing environment in elastic beanstalk and stop or start the environment at my will.
How can i do that?

The way the EBCLI (awsebcli) works is that you associate an empty directory on your computer with an EB application.
go to an empty directory
eb init --region <region name>. When prompted for the application name, choose the application you created previously.
eb terminate <environment name>. This will terminate the environment.
To create a new environment, perform eb create.

Related

Install ghostscript on load balanced Aws Beanstalk

I am using ghostscript on my current server. Now I am moving to an Aws beanstalk server with Application load balancer.
How do I configure start-up script on elastic beanstalk so whenever a new instance is created by the load balancer, ghostscript is automatically installed.
You can control what's installed in ElasticBeanstalk instances with .ebextensions file.
Whenewher Elastic Beanstalk creates a new EC2 instance, it will run all commands from the file in order to provision instance.
Example of .ebextensions file for installing Ghostscript
packages:
yum:
ghostscript: []
This will install a version of ghostscript from yum repository.
If you need a never version of ghostscript - it is also possible to specify installation shell commands inside ebextensions file. For example, these commands will install Ghostscript 9.23

How can I install phpmyadmin in my beanstalk ec2 environment

I have deployed my Codeigniter app into aws beanstalk environment and then I created a RDS instance inside the environment. And I set the ingress rule into the RDS so as to allow the inbound traffic only from the beanstalk ec2 instance.
And I have checked the mysql access to RDS instance from the ec2 through ssh and run the below command and all works fine there.
"mysql -h {RDS_Host} -P 3306 -u {RDS_Username} -p"
Now I want to access the RDS database using phpmyadmin which is installed in beanstalk ec2. So can anybody please explain about how to install and configure phpmyadmin in beanstalk ec2 instance so that I can access the RDS using that.
Note: I am using the EB CLI to deploy each versions of my app.
This is how i setup my phpmyadmin on ELB instance:
1) Download PHPMyAdmin from official site: https://www.phpmyadmin.net/
2) Unzip file in your dev directory (ex: yoururl.com/phpmyadmin)
3) Open the config.sample.inc.php, edit with your RDS credentials, save and rename to config.inc.php
4) Delete /setup dir
5) Deploy with the new archives
6) Be happy! :)

How can automatic deploy yii2 app when Elastic Beanstalk instance is terminated and created a new instance

Currently I have setup my yii2 website on AWS Elastic beanstalk. I followed following steps :
Created Elastic Beanstalk app and environment : Platform PHP 7.0, RDS database
Created SSH connection from EC2 instance of elastic beanstalk using putty with .pem file
In Apache folder I have cloned my yii2 git repo using (sudo git clone repo_url) command
Installed composer using this link https://gist.github.com/asugai/6694502
Run command : (sudo composer install) in my repo folder
Edited common/config/main-local.php and made db connection
And run migration using (sudo php yii migrate)
Setup a domain for this elastic beanstalk app
Now I don't know how should I proceed further and I am facing following problems :
Elastic Balance loader is creating new instance and terminating current one when it fails or health goes in severe.
Due this, my all data in that instance is lost. To make it work I am doing all steps again and again manually.
How can I make my domain https (SSL certified)
How can make easy process to pull new changes from git
I already have a working site in nodeJS. which is using elastic beanstalk, elastic balance loader, RDS(postgres), S3 bucket, cloudfront for Route 53, SSL certificate (https), code pipeline, code commit. And AWSCLI at local to deploy nodeJS app.
my question is about I want to use same flow for yii2 advance app.
Can anyone please help me here?
Thanks in advance :)

How can I get the RDS host of an elastic beanstalk environment?

How can I get the RDS host of an elastic beanstalk environment? I setup an EB env with:
eb create --database ...
Now I want to upload a SQL dump to this new environment without connecting to any server of this EB environment. Since the information is in the environment variables, I thought I could find out it with eb printenv but that does not work.
the information exists in the beanstalk web console (Data Tier section on the environment's Configuration page) as described in this document

running a docker loop device on aws

I'm new to aws and am having some issues with getting my mobile app back running again. Forgive me if this question seems vague.
For a school project we created a mobile app on aws and deployed using docker containers (another student managed these tasks). When trying to get my own key pair to ssh into my ec2 instance i detached the volume associated with my instance and reattached it after getting my own key pair. Now i can ssh into my instance but my front end cant talk to my web server.
So my question is, do i create a new application on elastic beanstalk to deploy my app? Even though when i run lsblk is shows a have a docker loop device and when i run docker images i see several that match the name of my application? or do i somehow get the container running again, docker run doesn't seem to be working.
No need, just upload a new update into Elastic Beanstalk. AWS will handle the rest.
FYI, Elastic Beanstalk - Single Docker Container update process (simple under the hood):
You upload the update into AWS.
AWS will put it on your S3.
Inside your EC2, there is an Elastic Beanstalk agent. It will check for a new update.
If there is an update, the agent will download the update file and extract it.
The agent will build a new Docker image.
If the build is success, it will generate a new config to tell Nginx (web proxy) the new web server container.
Nginx will be reloaded.
Your old docker container will be destroyed.
Don't change anything inside EC2 of Elastic Beanstalk, except you know what you do. Elastic Beanstalk is design for automate deployment and scaling. So, if you change something in your EC2 manually, it might be lost. Of course, you can modified your EC2 instance, but you need to automate it using .ebextensions or take an image.