From 35978502fd89eab22ef0f86e23b5910ec84d0e0f Mon Sep 17 00:00:00 2001 From: Okesanya Odunayo <94924061+DrInTech22@users.noreply.github.com> Date: Mon, 16 Dec 2024 10:57:32 +0100 Subject: [PATCH] chore: add variables to terraform config --- .github/workflows/terraform-plan.yml | 6 +++--- terraform/ec2.tf | 1 + terraform/variables.tf | 6 ++++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/terraform-plan.yml b/.github/workflows/terraform-plan.yml index e735abb..dc427f9 100644 --- a/.github/workflows/terraform-plan.yml +++ b/.github/workflows/terraform-plan.yml @@ -57,7 +57,7 @@ jobs: terraform plan -out=tfplan.out \ -var="ami_id=ami-005fc0f236362e99f" \ -var="instance_type=t2.large" \ - -var="volume_size=16" + -var="volume_size=20" working-directory: ./terraform - name: Save Plan JSON @@ -88,14 +88,14 @@ jobs: 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 "volume_size=16" + --terraform-var "volume_size=20" 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 "volume_size=16" + --terraform-var "volume_size=20" - name: Post Infracost Comment run: | diff --git a/terraform/ec2.tf b/terraform/ec2.tf index 5fb0ffa..875d801 100644 --- a/terraform/ec2.tf +++ b/terraform/ec2.tf @@ -4,6 +4,7 @@ resource "aws_instance" "ec2" { key_name = var.key_pair_name subnet_id = aws_subnet.public_subnet.id vpc_security_group_ids = [aws_security_group.sg.id] + availability_zone = var.availability_zone # Set the AZ dynamically tags = { Name = var.ec2_name } diff --git a/terraform/variables.tf b/terraform/variables.tf index bf16846..faf9ac1 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -44,6 +44,12 @@ variable "volume_size" { default = 15 # Default to 30 GB } +variable "availability_zone" { + description = "The availability zone where the EC2 instance will be deployed." + type = string + default = "us-east-1a" # Default value, can be overridden +} + variable "key_pair_name" { description = "Key pair name for SSH access" type = string