Skip to content
Open
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
21 changes: 18 additions & 3 deletions .github/workflows/provision_ec2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ on:
required: true
default: 'App Server'
type: string
operation:
description: 'Action to perform for the EC2 resource (select "create" or "destroy")'
required: true
default: 'create'
options:
- create
- destroy
jobs:
provision-ec2:
runs-on: ubuntu-latest
Expand All @@ -34,6 +41,14 @@ jobs:
cd tf-example/
terraform init
terraform validate
terraform plan
terraform apply -auto-approve


if [ "${{ github.event.inputs.operation }}" = "destroy" ]; then
echo "Running terraform plan (destroy) and terraform destroy..."
terraform plan -destroy -out=tfplan_destroy
terraform destroy -auto-approve
else
echo "Running terraform plan and terraform apply..."
terraform plan -out=tfplan
terraform apply -auto-approve
fi