-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from Odraxs/v0.2
Release v0.2
- Loading branch information
Showing
13 changed files
with
264 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
credentials.sh | ||
terraform.tfstate* | ||
.terraform* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
## Terraform | ||
|
||
This directory contains the terraform code that allows to deploy the project to an aws EC2 instance. | ||
|
||
### Instructions | ||
|
||
- Get into the terraform directory | ||
```bash | ||
cd terraform | ||
``` | ||
|
||
- Set your aws IAM credentials of a user with programmatic access. | ||
```bash | ||
cp credentials.example credentials.sh | ||
##Set your credentials in the created file | ||
chmod +x credentials.sh | ||
. credentials.sh | ||
``` | ||
|
||
- Create your ssh key-pair | ||
```bash | ||
ssh-keygen -t rsa -b 2048 | ||
... | ||
Generating public/private RSA key pair. | ||
Enter file in which to save the key (/home/path_to_ssh/.ssh/id_rsa): /home/path/to/save/keys/aws_key | ||
... | ||
``` | ||
|
||
> [!NOTE] | ||
> Change your own path in the line 27 of the `main.tf` and line 3 of the `security.tf` files. | ||
|
||
- Start terraform | ||
```bash | ||
terraform init | ||
``` | ||
|
||
- Look the terraform plan and deploy | ||
```bash | ||
terraform plan | ||
... | ||
terraform apply | ||
... | ||
``` | ||
|
||
- Connect to the instance and check if the images are running | ||
```bash | ||
ssh -i "your/private/key/path" ubuntu@your_instance_ip | ||
sudo docker ps -a | ||
... | ||
``` | ||
If everything went right all the images should be shown by the last command. | ||
|
||
### Additional notes | ||
|
||
Everything was done having in mind a free plan deployment, so the images of the project are in a docker repository, IMO the best way should be by creating the images directly in the EC2 instance, because with that way we can modify the `.evn` file of the web application so it sends the requests to the correct endpoint, but with a `t2.micro` is was impossible to build the images on the EC2 instance. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export AWS_SECRET_ACCESS_KEY=SECERT_ACCES_KEY_EXAMPLE | ||
export AWS_ACCESS_KEY_ID=ACCESS_KEY_ID_EXAMPLE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
provider "aws" { | ||
region = "us-east-1" | ||
} | ||
|
||
resource "aws_instance" "ec2_example" { | ||
ami = "ami-080e1f13689e07408" | ||
instance_type = "t2.micro" | ||
key_name = "aws_key" | ||
vpc_security_group_ids = [aws_security_group.main.id] | ||
user_data = file("${path.module}/userdata.tpl") | ||
|
||
root_block_device { | ||
volume_size = 8 | ||
} | ||
|
||
provisioner "remote-exec" { | ||
inline = [ | ||
"touch hello.txt", | ||
"echo helloworld remote provisioner >> hello.txt", | ||
] | ||
} | ||
|
||
connection { | ||
type = "ssh" | ||
host = self.public_ip | ||
user = "ubuntu" | ||
private_key = file("/home/david/.ssh/aws_key") | ||
timeout = "4m" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
resource "aws_key_pair" "deployer" { | ||
key_name = "aws_key" | ||
public_key = file("/home/david/.ssh/aws_key.pub") | ||
} | ||
|
||
resource "aws_security_group" "main" { | ||
egress = [ | ||
{ | ||
cidr_blocks = ["0.0.0.0/0", ] | ||
description = "" | ||
from_port = 0 | ||
ipv6_cidr_blocks = [] | ||
prefix_list_ids = [] | ||
protocol = "-1" | ||
security_groups = [] | ||
self = false | ||
to_port = 0 | ||
} | ||
] | ||
ingress = [ | ||
{ | ||
cidr_blocks = ["0.0.0.0/0", ] | ||
description = "" | ||
from_port = 22 | ||
ipv6_cidr_blocks = [] | ||
prefix_list_ids = [] | ||
protocol = "tcp" | ||
security_groups = [] | ||
self = false | ||
to_port = 22 | ||
}, | ||
{ | ||
cidr_blocks = ["0.0.0.0/0", ] | ||
description = "Vue page" | ||
from_port = 5173 | ||
ipv6_cidr_blocks = [] | ||
prefix_list_ids = [] | ||
protocol = "tcp" | ||
security_groups = [] | ||
self = false | ||
to_port = 5173 | ||
}, | ||
{ | ||
cidr_blocks = ["0.0.0.0/0", ] | ||
description = "Server" | ||
from_port = 3001 | ||
ipv6_cidr_blocks = [] | ||
prefix_list_ids = [] | ||
protocol = "tcp" | ||
security_groups = [] | ||
self = false | ||
to_port = 3001 | ||
}, | ||
{ | ||
cidr_blocks = ["0.0.0.0/0", ] | ||
description = "Zincsearch" | ||
from_port = 4080 | ||
ipv6_cidr_blocks = [] | ||
prefix_list_ids = [] | ||
protocol = "tcp" | ||
security_groups = [] | ||
self = false | ||
to_port = 4080 | ||
} | ||
] | ||
} |
Oops, something went wrong.