Skip to content

feat: add var for volume size #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/terraform-apply.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ env:
TF_VAR_aws_region: ${{ vars.TF_AWS_REGION }}
TF_VAR_ami_id: ${{ vars.TF_AMI_ID }}
TF_VAR_instance_type: ${{ vars.TF_INSTANCE_TYPE }}
TF_VAR_volume_size: ${{ vars.TF_VOLUME_SIZE }}
TF_VAR_key_pair_name: ${{ vars.TF_KEY_PAIR_NAME }}
TF_VAR_private_key: ${{ secrets.PRIVATE_KEY }}
TF_VAR_domain_name: ${{ vars.TF_DOMAIN_NAME }}
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/terraform-plan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ env:
TF_VAR_aws_region: ${{ vars.TF_AWS_REGION }}
TF_VAR_ami_id: ${{ vars.TF_AMI_ID }}
TF_VAR_instance_type: ${{ vars.TF_INSTANCE_TYPE }}
TF_VAR_volume_size: ${{ vars.TF_VOLUME_SIZE }}
TF_VAR_key_pair_name: ${{ vars.TF_KEY_PAIR_NAME }}
TF_VAR_private_key: ${{ secrets.PRIVATE_KEY }}
TF_VAR_domain_name: ${{ vars.TF_DOMAIN_NAME }}
Expand Down Expand Up @@ -55,7 +56,8 @@ jobs:
run: |
terraform plan -out=tfplan.out \
-var="ami_id=ami-005fc0f236362e99f" \
-var="instance_type=t2.large"
-var="instance_type=t2.large" \
-var="volume_size=16"
working-directory: ./terraform

- name: Save Plan JSON
Expand Down Expand Up @@ -85,13 +87,15 @@ jobs:
run: |
infracost breakdown --path=./terraform --format=table --out-file=/tmp/infracost-new.txt \
--terraform-var "ami_id=ami-005fc0f236362e99f" \
--terraform-var "instance_type=t2.large"
--terraform-var "instance_type=t2.large" \
--terraform-var "volume_size=16"
infracost diff --path=./terraform \
--format=json \
--compare-to=/tmp/infracost-base.json \
--out-file=/tmp/infracost.json \
--terraform-var "ami_id=ami-005fc0f236362e99f" \
--terraform-var "instance_type=t2.large"
--terraform-var "instance_type=t2.large" \
--terraform-var "volume_size=16"

- name: Post Infracost Comment
run: |
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/terraform-validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ env:
TF_VAR_aws_region: ${{ vars.TF_AWS_REGION }}
TF_VAR_ami_id: ${{ vars.TF_AMI_ID }}
TF_VAR_instance_type: ${{ vars.TF_INSTANCE_TYPE }}
TF_VAR_volume_size: ${{ vars.TF_VOLUME_SIZE }}
TF_VAR_key_pair_name: ${{ vars.TF_KEY_PAIR_NAME }}
TF_VAR_private_key: ${{ secrets.PRIVATE_KEY }}
TF_VAR_domain_name: ${{ vars.TF_DOMAIN_NAME }}
Expand Down
144 changes: 0 additions & 144 deletions ansible/compose.yml.j2

This file was deleted.

4 changes: 2 additions & 2 deletions ansible/roles/docker_compose/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
- name: Run main Docker Compose
shell: |
sleep 180
docker compose -f compose.monitoring.yml up -d
sleep 80
docker compose -f compose.monitoring.yml up -d --force-recreate
args:
chdir: /home/ubuntu
13 changes: 13 additions & 0 deletions ansible/roles/docker_setup/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,19 @@
state: started
enabled: true

- name: Add user to the Docker group
command: usermod -aG docker ubuntu
become: yes # Required to ensure the command runs with elevated privileges

- name: Apply Docker group changes for the current session
shell: |
newgrp docker << END
exit
END
args:
executable: /bin/bash
become: yes

- name: Create app-network
community.docker.docker_network:
name: app-network
Expand Down
2 changes: 2 additions & 0 deletions ansible/roles/file_structure/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
path: "{{ item }}"
state: directory
mode: '0755'
owner: ubuntu
group: ubuntu
loop:
- /home/ubuntu/monitoring
- /home/ubuntu/traefik
Expand Down
1 change: 1 addition & 0 deletions terraform/bkp.terraform.tfvars.k
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ frontend_domain = "cv1.drintech.online"
db_domain = "db.cv1.drintech.online"
traefik_domain = "traefik.cv1.drintech.online"
cert_email = "admin@example.com" # replace with a valid email
volume_size = 15

Let's move on
just a test
4 changes: 4 additions & 0 deletions terraform/ec2.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ resource "aws_instance" "ec2" {
Name = var.ec2_name
}

root_block_device {
volume_size = var.volume_size
}

provisioner "local-exec" {
command = "echo 'Instance provisioned: ${self.public_ip}'"
}
Expand Down
6 changes: 6 additions & 0 deletions terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ variable "instance_type" {
default = "t2.micro"
}

variable "volume_size" {
description = "The size of the EBS volume in GB."
type = number
default = 15 # Default to 30 GB
}

variable "key_pair_name" {
description = "Key pair name for SSH access"
type = string
Expand Down
Loading