Creating an App on Elastic Beanstalk from Terminal
Tags: aws, docker
Published: 2020-09-24 09:28:29

# Prerequisites

- MacOS Catalina
- Have the ebcli installed

# Initialize the elastic beanstalk application

We will choose docker for the platform.

```
$ 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) eu-south-1 : EU (Milano)
20) ap-east-1 : Asia Pacific (Hong Kong)
21) me-south-1 : Middle East (Bahrain)
22) af-south-1 : Africa (Cape Town)
(default is 3): 1


Select an application to use
1) eb-https
2) Up
3) [ Create new Application ]
(default is 3):


Enter Application Name
(default is "eb-https2"):
Application eb-https2 has been created.
Select a platform.
1) .NET Core on Linux
2) .NET on Windows Server
3) Docker
4) GlassFish
5) Go
6) Java
7) Node.js
8) PHP
9) Packer
10) Python
11) Ruby
12) Tomcat
(make a selection): 3

Select a platform branch.
1) Docker running on 64bit Amazon Linux 2
2) Multi-container Docker running on 64bit Amazon Linux
3) Docker running on 64bit Amazon Linux
(default is 1): 1

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): n
```

# Create the environment

We will add the --vpc option to create the virtual private cloud.

```
$ eb create --vpc
// press enter
Enter Environment Name
(default is eb-https2-dev):
//press enter
Enter DNS CNAME prefix
(default is eb-https2-dev):

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

Would you like to enable Spot Fleet requests for this environment?
(y/N): N

Enter the VPC ID: vpc-e3e2079e
Do you want to associate a public IP address? (Y/n): Y

// I entered the same subnets for both the EC2 and ELB subnets.
Enter a comma-separated list of Amazon EC2 subnets: subnet-416eba60, subnet-764a8029
Enter a comma-separated list of Amazon ELB subnets: subnet-416eba60, subnet-764a8029
Do you want the load balancer to be public? (Select no for internal) (Y/n): Y
Enter a comma-separated list of Amazon VPC security groups: sg-01475203460d2c24b
NOTE: The current directory does not contain any source code. Elastic Beanstalk is launching the sample application instead.
Do you want to download the sample application into the current directory?
(Y/n): Y
```

After about 10 minutes, if you are successful, you should see the environment built in your console.
When you access the url, you should see the sample page here.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/tyf5ryttala7nklh5odd.png)

If you chose `Y` and downloaded the sample application into the current directory, your folder should look like this.

```
$ tree
.
├── Dockerfile
├── Dockerrun.aws.json
├── application.py
└── cron.yaml

0 directories, 4 files
```