Skip to content

Commit a05f97e

Browse files
committed
portfolio: initial release
1 parent de87dfe commit a05f97e

32 files changed

+1286
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Terraform Destroy (Manually Triggered)
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
confirm:
7+
description: "Type 'DESTROY' to confirm you really want to destroy infrastructure"
8+
required: true
9+
10+
env:
11+
TF_ROOT: project1_refactor
12+
TF_VERSION: 1.13.0
13+
AWS_REGION: eu-west-2
14+
15+
concurrency:
16+
group: terraform-destroy-${{ github.ref }}
17+
cancel-in-progress: false
18+
19+
jobs:
20+
destroy:
21+
runs-on: ubuntu-latest
22+
23+
permissions:
24+
id-token: write # Required for OIDC
25+
contents: read # To checkout repo
26+
27+
steps:
28+
- name: ⛔ Validate destroy confirmation
29+
if: ${{ github.event.inputs.confirm != 'DESTROY' }}
30+
run: |
31+
echo "❌ Destroy not confirmed. Type 'DESTROY' in the workflow input."
32+
exit 1
33+
34+
- name: 📥 Checkout repo
35+
uses: actions/checkout@v4
36+
37+
- name: 🔐 Configure AWS credentials (OIDC)
38+
uses: aws-actions/configure-aws-credentials@v4
39+
with:
40+
role-to-assume: ${{ secrets.AWS_OIDC_ROLE }}
41+
aws-region: ${{ env.AWS_REGION }}
42+
43+
- name: 🧪 Verify Remote State S3 Backend
44+
run: |
45+
aws s3api head-bucket \
46+
--bucket my-eu-tf-state-bucket
47+
48+
- name: 🧪 Verify DynamoDB Lock Table
49+
run: |
50+
aws dynamodb describe-table \
51+
--table-name terraform-locks
52+
53+
- name: 🛠️ Setup Terraform
54+
uses: hashicorp/setup-terraform@v3
55+
with:
56+
terraform_version: ${{ env.TF_VERSION }}
57+
58+
- name: 📄 Terraform Init
59+
run: |
60+
terraform -chdir=${{ env.TF_ROOT }} \
61+
init \
62+
-input=false \
63+
-backend-config="region=${{ env.AWS_REGION }}"
64+
65+
- name: 💣 Terraform Destroy
66+
run: |
67+
terraform -chdir=${{ env.TF_ROOT }} \
68+
destroy \
69+
-auto-approve
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
name: Terraform Provision (EC2 S3 VPC)
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
push:
7+
branches: [ main ]
8+
workflow_dispatch:
9+
10+
env:
11+
TF_ROOT: project1_refactor
12+
TF_VERSION: 1.13.0
13+
AWS_REGION: eu-west-2
14+
15+
concurrency:
16+
group: terraform-${{ github.ref }}
17+
cancel-in-progress: false
18+
19+
jobs:
20+
terraform-provision:
21+
runs-on: ubuntu-latest
22+
23+
permissions:
24+
id-token: write # Required for OIDC
25+
contents: read # To checkout repo
26+
27+
steps:
28+
- name: 📥 Checkout repo
29+
uses: actions/checkout@v4
30+
31+
- name: 🔐 Configure AWS credentials (OIDC)
32+
uses: aws-actions/configure-aws-credentials@v4
33+
with:
34+
role-to-assume: ${{ secrets.AWS_OIDC_ROLE }}
35+
aws-region: ${{ env.AWS_REGION }}
36+
37+
- name: 🧪 Verify Remote State S3 Backend
38+
run: |
39+
aws s3api head-bucket \
40+
--bucket my-eu-tf-state-bucket
41+
42+
- name: 🧪 Verify DynamoDB Lock Table
43+
run: |
44+
aws dynamodb describe-table \
45+
--table-name terraform-locks
46+
47+
- name: 🛠️ Setup Terraform
48+
uses: hashicorp/setup-terraform@v3
49+
with:
50+
terraform_version: ${{ env.TF_VERSION }}
51+
52+
# Pre-merge checks:
53+
# (uncomment to enable formatting check)
54+
# - name: 🧼 Terraform Format
55+
# run: |
56+
# terraform -chdir=${{ env.TF_ROOT }} \
57+
# fmt -check -recursive
58+
59+
- name: 📄 Terraform Init
60+
run: |
61+
terraform -chdir=${{ env.TF_ROOT }} \
62+
init \
63+
-input=false \
64+
-backend-config="region=${{ env.AWS_REGION }}"
65+
66+
- name: 🔎 Terraform Validate
67+
run: |
68+
terraform -chdir=${{ env.TF_ROOT }} \
69+
validate
70+
71+
# Optional: Security linting with tfsec (uncomment to enable)
72+
# - name: 🔐 tfsec (Terraform security scan)
73+
# uses: aquasecurity/tfsec-pr-commenter-action@v1.4.0
74+
# with:
75+
# working_directory: ${{ env.TF_ROOT }}
76+
# github_token: ${{ secrets.GITHUB_TOKEN }}
77+
78+
- name: 📊 Terraform Plan
79+
run: |
80+
terraform -chdir=${{ env.TF_ROOT }} \
81+
plan \
82+
-out=tfplan
83+
84+
# Post-merge checks
85+
# Manually triggered for main branch (workflow_dispatch)
86+
- name: 🚀 Terraform Apply
87+
if: github.event_name == 'workflow_dispatch'
88+
run: |
89+
terraform -chdir=${{ env.TF_ROOT }} \
90+
apply \
91+
-auto-approve \
92+
tfplan
93+
94+
# Auto apply on main branch
95+
# - name: 🚀 Terraform Apply
96+
# if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
97+
# run: |
98+
# terraform -chdir=${{ env.TF_ROOT }} \
99+
# apply -auto-approve tfplan
100+
101+
# Output Terraform outputs
102+
- name: 📤 Terraform Output
103+
if: github.event_name == 'workflow_dispatch'
104+
run: |
105+
terraform -chdir=${{ env.TF_ROOT }} \
106+
output -json

.gitignore

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# .gitignore
2+
####################################
3+
###### COMMENT OUT FOR PROD ########
4+
####################################
5+
# terraform.tfvars
6+
# *.tfstate
7+
# *.tfstate.backup
8+
# .terraform/
9+
# .terraform.lock.hcl
10+
11+
# Sensitive keys
12+
# *.pem
13+
# *.key
14+
# *.crt
15+
16+
# Local overrides (never commit env-specific tweaks)
17+
# override.tf
18+
# override.tf.json
19+
# *_override.tf
20+
# *_override.tf.json
21+
22+
# Ignore backend config with real values
23+
# backend.tf
24+
25+
# OS Metadata
26+
*.DS_STORE
27+
Thumbs.db
28+
desktop.ini

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Zepher Ashe
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)