Skip to content

CI: update var in terraform workflow #21

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 4 commits 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
2 changes: 1 addition & 1 deletion .github/workflows/terraform-apply.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ jobs:
- name: Save Public IP
if: steps.terraform-operation.outcome == 'success' && github.event.inputs.operation != 'destroy'
run: |
echo "public_ip=$(terraform output -raw instance_public_ip)" > public_ip_env.txt
terraform output instance_public_ip > public_ip_env.txt
cat public_ip_env.txt
working-directory: ./terraform

Expand Down
17 changes: 12 additions & 5 deletions .github/workflows/terraform-plan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ jobs:

- name: Terraform Plan
id: plan
run: terraform plan -out=tfplan.out
run: |
terraform plan -out=tfplan.out \
-var="ami_id=ami-005fc0f236362e99f" \
-var="instance_type=t2.large"
working-directory: ./terraform

- name: Save Plan JSON
Expand All @@ -73,18 +76,22 @@ jobs:

- name: Run Infracost
run: |
infracost breakdown --path=./terraform --format=json --out-file=/tmp/infracost-base.json
infracost breakdown --path=./terraform --format=json --out-file=/tmp/infracost-base.json

# Checkout the current PR branch so we can create a diff.
- name: Checkout PR branch
uses: actions/checkout@v4
- name: Generate Infracost diff
run: |
infracost breakdown --path=./terraform --format=table --out-file=/tmp/infracost-new.txt
infracost diff --path=./terraform \
infracost breakdown --path=./terraform --format=table --out-file=/tmp/infracost-new.txt \
--terraform-var "ami_id=ami-005fc0f236362e99f" \
--terraform-var "instance_type=t2.large"
infracost diff --path=./terraform \
--format=json \
--compare-to=/tmp/infracost-base.json \
--out-file=/tmp/infracost.json
--out-file=/tmp/infracost.json \
--terraform-var "ami_id=ami-005fc0f236362e99f" \
--terraform-var "instance_type=t2.large"

- name: Post Infracost Comment
run: |
Expand Down
1 change: 1 addition & 0 deletions ansible/compose.monitoring.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ services:
- monitor-network
volumes:
- ./monitoring/promtail-config.yml:/etc/promtail/promtail-config.yaml
- /var/log:/var/log
depends_on:
- loki

Expand Down
11 changes: 0 additions & 11 deletions terraform/ec2.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,4 @@ resource "aws_instance" "ec2" {
provisioner "local-exec" {
command = "echo 'Instance provisioned: ${self.public_ip}'"
}
}

resource "aws_instance" "ec2-2" {
ami = var.ami_id
instance_type = var.instance_type
key_name = var.key_pair_name
subnet_id = aws_subnet.public_subnet.id
vpc_security_group_ids = [aws_security_group.sg.id]
tags = {
Name = var.ec2_name
}
}
Loading