This project is a solution to the Eficode DevOps challenge task.
To run this project, you will need to add the following environment variables to your .env file:
-
ENDPOINT
-
APPID
-
TARGET_CITY
(optional)
Refer to .env.example for more information.
To deploy this project follow below instructions:
-
In AWS Console: Services > IAM > Users > Create user
-
User name: efi-recruitment-user, then next.
-
Create group efi-recruitment-group with AdministratorAccess permission policy, then select it from the list and click next.
-
Review user details, then Create user.
-
Click on newly created user to open it.
-
In summary section click Create access key.
-
Select Command Line Interface (CLI) as use case and check the confirmation box, then next.
-
Set description tag to efi-recruitment-key, then create access key.
-
Open the terminal and run the following command:
aws configure -------------- AWS Access Key ID: # paste from AWS console AWS Secret Access Key: # paste from AWS console Default region name: # eu-central-1 Default output format: # yaml
-
Run the following command:
aws-vault add efi-recruitment-user -------------- Enter Access Key ID: # paste from AWS console Enter Secret Access Key: # paste from AWS console
-
Run the following command:
aws-vault exec efi-recruitment-user
- In AWS Console: Services > EC2 > Key pairs > Create key pair
- Set name to efi-recruitment-key and leave default settings (RSA, .pem), then Create key pair.
- Download the key and note its location for later use.
-
Open the terminal and
cd
into./terraform
. -
Make sure you are authenticated by running the command:
aws-vault exec efi-recruitment-user
-
Run the following command to initialize:
terraform init
-
Run the following command to set up infrastructure:
terraform apply
... then specify values of the required variables (region, key_name, instance_name, sg_name). You may follow the given suggestions for each of them.
-
Enter
yes
to confirm the operation.
-
Update
ENDPOINT
environment variable in.env
to reflect your instance's public IPv4 address. -
Create
hosts.ini
inside./ansible
. Refer tohosts.ini.example
and remember to replace placeholder values with your EC2 instance's public IPv4 address and a path to your key. -
Run the following command inside
./ansible
to execute the playbook:sudo ansible-playbook provision_efi.yaml -i hosts.ini
-
Specify path to local project directory when prompted.
To see your deployment live, copy the public IPv4 address of your EC2 instance and open it in the browser.
-
Install and start Docker Desktop.
-
From project root directory run:
docker compose up --build
-
Open http://localhost:8000 to see it live.
-
Find the current IP address of my deployment inside the About section at the top of this repository.
-
Execute the following command:
ssh -i /path/to/id_rsa_internship.pem ubuntu@<IPv4>
... replacing the placeholder with the appropriate IP address.