Skip to content

Commit

Permalink
chore: add variables to terraform config
Browse files Browse the repository at this point in the history
  • Loading branch information
DrInTech22 authored Dec 16, 2024
1 parent 5a07766 commit 3597850
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/terraform-plan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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: |
Expand Down
1 change: 1 addition & 0 deletions terraform/ec2.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
6 changes: 6 additions & 0 deletions terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3597850

Please sign in to comment.