19 Commits

Author SHA1 Message Date
max
69718dd467 feat: added cache
All checks were successful
Build & Deploy / Build Infrastructure (pull_request) Successful in 58s
Build & Deploy / Deploy Application (pull_request) Successful in 24s
2025-02-18 22:24:18 -05:00
max
db288c1f06 feat: run playbook action 2025-02-18 22:20:37 -05:00
max
2de880fb4c style: install requirements name 2025-02-18 21:45:15 -05:00
max
ab324b6b1c fix: using native python for running ansible lint 2025-02-18 21:44:47 -05:00
max
f4fee8521e fix: use any instance to run ansible job 2025-02-18 21:32:06 -05:00
max
76db2c3dd3 feat: added ansible-lint 2025-02-18 21:29:01 -05:00
max
14fa6c4052 fix: renamed action 2025-02-18 21:24:26 -05:00
max
0a3be5336b fix: main, not master 2025-02-18 21:21:44 -05:00
max
804743d2df feat: added deploy option when on the main branch 2025-02-18 21:20:03 -05:00
max
7992362abc style: emojis are too much 2025-02-18 21:04:59 -05:00
max
1beac34439 style: linting github action 2025-02-18 21:02:37 -05:00
max
e46795fd57 fix: aws credentials for plan 2025-02-18 20:56:18 -05:00
max
eb91cf5052 fix: using secrets for aws login 2025-02-18 20:55:13 -05:00
max
554525c287 fix: removed exposable backend config 2025-02-18 20:48:32 -05:00
max
73fa413df8 style: formatting terraform 2025-02-18 20:47:25 -05:00
max
93dbac9692 fix: hopefully we don't leak anymore 2025-02-18 20:46:34 -05:00
max
1ef8c9c173 feat: added backend config secret 2025-02-18 20:30:19 -05:00
max
384815b4a4 feat: added init and plan 2025-02-18 20:19:47 -05:00
max
5c3adaa624 feat: tf lint
All checks were successful
⭐ Quality Assurance / Terraform Lint (push) Successful in 47s
2025-02-18 15:44:47 -05:00
5 changed files with 92 additions and 20 deletions

84
.github/workflows/deployment.yml vendored Normal file
View File

@@ -0,0 +1,84 @@
name: Build & Deploy
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
infrastructure:
name: Build Infrastructure
runs-on: ubuntu-latest
env:
RUNNER_TOOL_CACHE: /toolcache
steps:
- name: Checkout to Repository
uses: actions/checkout@v2
- name: Set-up Terraform
uses: hashicorp/setup-terraform@v2
- name: Format Terraform
run: terraform fmt -check
working-directory: ./terraform
- name: Initialize Terraform Back-end
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: terraform init
working-directory: ./terraform
- name: Terraform Plan
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: terraform plan -out=tfplan -no-color
working-directory: ./terraform
- name: Check if there are changes
id: check_changes
run: |
if [ -n "$(terraform show -no-color tfplan | grep -E 'No changes.')" ]; then
echo "No changes detected."
echo "::set-output name=changes::false"
else
echo "Changes detected."
echo "::set-output name=changes::true"
fi
working-directory: ./terraform
- name: Terraform Apply
if: ${{ (steps.check_changes.outputs.changes == 'true') && (github.ref == 'refs/heads/main') }}
run: terraform apply -auto-approve tfplan
working-directory: ./terraform
build:
name: Deploy Application
runs-on: ubuntu-latest
env:
RUNNER_TOOL_CACHE: /toolcache
steps:
- name: Checkout to Repository
uses: actions/checkout@v4
- name: Use Python 3.13
uses: actions/setup-python@v5
with:
python-version: '3.13'
cache: pip
- name: Install Dependencies
run: pip install -r requirements.txt
- name: Lint Playbooks
run: ansible-lint
working-directory: ./playbooks
- name: Run Playbook
if: ${{ github.ref == 'refs/heads/main' }}
run: ansible-playbook deployment.yml
working-directory: ./playbooks

View File

@@ -1,3 +1,3 @@
# proxy # proxy
How all other applications interact with the web. How all other applications interact with the web.

View File

@@ -1,7 +1,7 @@
- name: Deploy artifact to instance. - name: Deploy artifact to instance.
hosts: localhost hosts: localhost
vars_files: vars_files:
- ../config/proxy.json - ../config/ansible.secret.json
- ../secrets/infrastructure.secret.json - ../secrets/infrastructure.secret.json
vars: vars:
ansible_connection: aws_ssm ansible_connection: aws_ssm

View File

@@ -1,11 +1,13 @@
terraform { terraform {
# The backend is stored in an S3 bucket. # The backend is stored in an S3 bucket.
backend "s3" {} backend "s3" {
bucket = "tsuga-sieboldii"
key = "proxy"
region = "us-east-1"
}
} }
# Access AWS through the IaC roles. # Access AWS through the IaC roles.
provider "aws" { provider "aws" {
region = var.aws_region region = "us-east-1"
access_key = var.aws_access
secret_key = var.aws_secret
} }

View File

@@ -1,14 +0,0 @@
variable "aws_region" {
type = string
description = "The AWS region things are created in."
}
variable "aws_access" {
type = string
description = "The access key to generate the Gitea instance."
}
variable "aws_secret" {
type = string
description = "The access secret to generate the Gitea instance."
}