Skip to content

Commit d1bce8e

Browse files
davwysJohann SchwabeMarinolino
authored
feat: Terraform & GitHub Actions (#351)
* More backend module setup * Move RDS * Serverless DB config * Scaling config * Setup lambda * Lambda setup * More setup * Build setup * Move S3 * Lambda terraform * Lambda stuff * Variables for lambda deploy * Unquote vars * Add iam * TF cleanup, path fixes * TF vars * Fix lambda build * Fix build script * More lambda setup * version missmatch: apollo-server-fastify doesn't support fastify v4 * Move to express from fastify * Express serverless initial setup * fixed destroy script * Express fixes * Set up listener * Fix express deploy * Lambda URL setup * Fix endpoint record for serverless * Start API gateway setup * API Gateway setup * Add comments * Regional module setup * Separate VPC for lambda * Add separate cert module * API Gateway contents setup * Fix API Gateway * Working link from API gateway to domain * Improve serverless API deploy * Initial CORS setup for API gateway * Fix dependencies, still issues on POST * CORS stuff * Docs * Fix weird dependencies * Resource changes & logging for API gateway * Fix cyclic dependency * Fix API gateway logging * JWTStrategy fix for serverless * Logging for testing * Switch to serverless RDS v1 * Add optional serverless v2 * Fix v2 * Fix v2 * JWT testing setup * Current state * Make lambda private * Move options cors to proxy * Remove cors * Serverless update * Fix zip path * Add hash output * Fix update script * More update script fixes * Fix lambda redeploy * Cleanup * Cleanup * Add webpack for lambda, not done yet * Basic webpack config * Webpack cleanup * Change lambda memory * Lambda optimization * Set up per-mode configuration of infrastructure * Fix db config * Prepare setup * Major script cleanup * Fix type * Remove todo * Fix update, fix caching * Add invalidation to cloudfront distribution * Add dev update github action * Fix script path * Add commands * switch invalidation to null resource * step 1 is now also applied for dev * added workflow images * added better images * Fix cache invalidation * Fix cache invalidation * Fix SPA frontend redeploy * Fix template * Config * Fix destroy script * Fix path in action * Add login * RM login * Add inits * rm id * Remove init * Fix zsh * use bash * Add ts-node dep, use sudo for bash * Sudo node-prune * ts-node * Add typescript * More sudo * Test init * Validate * Login * Use setup v2 * use setup * test init * test config * Try explicit shell * Manual login * LS test * cat file * Test file path * Log test * logging * Move export * add token * test log * Add more test content * more test * Folder test * Add ls * multi ls * fix * Add sudo * config file location echo * config file location echo * Add tf cli config file * Remove quotes * Try with no sudo * Cleanup * remove wrapper * Add existence check in script * Package * fix force * shorten desc * Fix online status check * Add https check * add error codes * Fix config * Per-mode backup manager name * Destroy script * more logs * condition fix * Fix ordering * Fix destroy script for action * Add init * fix output path * Fix paths * Fix final snapshot skip * Fix order of build in destroy script * Switch redirect-record config * Make build sudo in destroy * Better error message * Fix depends-on * Fix log exporter naming * Modularize frontend subnet, chmod node_modules * change package.json * Change webpack config * move lambda entrypoint * Fix lambda path * change webpack config * Try other config * Test don't use webpack * main path * Revert "main path" This reverts commit 2f13df2. * Revert "Test don't use webpack" This reverts commit 10edbb6. * Revert "Try other config" This reverts commit faf67aa. * Revert "change webpack config" This reverts commit 6fbddaf. * Revert "Fix lambda path" This reverts commit da22c0f. * Revert "move lambda entrypoint" This reverts commit dd0e6ff. * Revert "Change webpack config" This reverts commit 155a8f1. * Revert "change package.json" This reverts commit d995a28. * Revert "Modularize frontend subnet, chmod node_modules" This reverts commit 415bcc4. * cleanup * Remove webpack * Add more confirmation for force deployment * Confirm not required * Fix path in live mode * Fix typo in path * Change live path for testing * Fix security groups * add echo * Fix text entry * fix input more * Update node * Correct subnets for API EBS * Enable destruction of live system * Change test config * Fix destroy action input * Remove online check for customer-facing systems * live/test check on initial deploy as well * Release scripts setup * Update deployment actions * Test update * Fix path * Fix shell * Update setup terraform * remove sudo in actions * sudo * Test update * Try modifying cert * Docs, fix cert * Add log * remove automation on branch * Fix jq path * use actual cert * feat: Change from vuex to pinia (#353) * Placeholder workflow * Placeholder workflow contents * Add files via upload (#352) * Add workflow * reÃplaced vuex with pinia * fixed quote issue * Removed vue app email Co-authored-by: David Wyss <[email protected]> * PR fixes * Update frontend/src/stores/index.ts Co-authored-by: davwys <[email protected]> * Update backend/src/flox/modules/auth/auth.guard.ts Co-authored-by: Marinolino <[email protected]> * Update frontend/src/data/readme.md Co-authored-by: Marinolino <[email protected]> * Update scripts/aws-update/aws-update.sh Co-authored-by: Marinolino <[email protected]> * Update scripts/aws-update/aws-update.sh Co-authored-by: Marinolino <[email protected]> * Update scripts/aws-initial-setup/2_main-setup/api-ebs/variables.tf Co-authored-by: Marinolino <[email protected]> * Update scripts/aws-initial-setup/2_main-setup/api-ebs/variables.tf Co-authored-by: Marinolino <[email protected]> * Update scripts/support/destroy-system.sh Co-authored-by: Marinolino <[email protected]> * Update scripts/support/destroy-system.sh Co-authored-by: Marinolino <[email protected]> * Update scripts/support/destroy-system.sh Co-authored-by: Marinolino <[email protected]> * Update scripts/aws-initial-setup/2_main-setup/api-serverless/variables.tf Co-authored-by: Marinolino <[email protected]> * Update scripts/aws-initial-setup/2_main-setup/api-serverless/variables.tf Co-authored-by: Marinolino <[email protected]> * Update scripts/aws-initial-setup/initial-aws-setup.sh Co-authored-by: Marinolino <[email protected]> * Update scripts/aws-initial-setup/initial-aws-setup.sh Co-authored-by: Marinolino <[email protected]> * PR changes * Fix tests for user module * Centralize test utils * Remove required keys, add TODO * feat: GitHub Actions for Staging Workflow (#354) * staging workflows * Update .github/workflows/remove-stage.yml Co-authored-by: David Wyss <[email protected]> * PR fixes * PR final fixes * Update .github/workflows/initial-setup.yml Co-authored-by: David Wyss <[email protected]> * Fix type * Fix order * Remove fastify * Fix import * shorten bucket-prefix * changed stage branch name generation to fewer chars * Fix regex * Fix script modes * Fix destroy scripts * comment * remove destroy config Co-authored-by: Johann Schwabe <[email protected]> Co-authored-by: Marinolino <[email protected]> Co-authored-by: Marinolino <[email protected]>
1 parent b374b28 commit d1bce8e

File tree

170 files changed

+11445
-5453
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

170 files changed

+11445
-5453
lines changed

.env

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
PROJECT_NAME=flox
12
SERVER_PORT=3000
23
FRONTEND_PORT=3001
34
DB_DATABASE=app_db # TODO: Application specific

.github/workflows/destroy-system.yml

+41-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
name: Destroy AWS
1+
name: Destroy AWS infrastructure
22

3+
# Should only be run manually from the Actions tab
4+
# ATTENTION: this system may destroy infrastructure seen by customers!
35
on:
4-
# Testing only
56
workflow_dispatch:
67
inputs:
78
mode:
@@ -11,9 +12,44 @@ on:
1112
options:
1213
- test
1314
- dev
15+
- live
16+
- stage
17+
force:
18+
required: false
19+
type: boolean
20+
description: Force destruction
21+
default: false
22+
confirm:
23+
required: false
24+
type: string
25+
description: Enter "confirm" to confirm you are aware that DATA LOSS, INCLUDING ACCOUNTS, will occur when forcing destruction!
26+
stage-branch-name:
27+
required: false
28+
type: string
29+
description: Name of the staging branch to destroy in 'stage' mode
30+
1431
jobs:
15-
setup-aws:
32+
destroy-aws:
1633
runs-on: ubuntu-latest
1734
steps:
18-
- name: Test
19-
run: echo "Testing!"
35+
- name: Checkout 🛎
36+
uses: actions/checkout@v3
37+
38+
- name: Make scripts executable
39+
run: |
40+
sudo chmod +x ./scripts/support/build.sh
41+
sudo chmod +x ./scripts/support/destroy-system.sh
42+
43+
- name: Set up Terraform
44+
uses: hashicorp/setup-terraform@v2
45+
with:
46+
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
47+
terraform_wrapper: false
48+
49+
- name: Validate Terraform
50+
working-directory: ./scripts/support
51+
run: terraform validate
52+
53+
- name: Destroy AWS infrastructure
54+
working-directory: ./scripts/support
55+
run: bash destroy-system.sh ${{ github.event.inputs.mode }} false ${{ github.event.inputs.force }} ${{ github.event.inputs.confirm }} ${{ github.event.inputs.stage-branch-name }}

.github/workflows/initial-setup.yml

+34-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
name: Initial AWS setup
1+
name: Set up AWS infrastructure
22

3+
# Should only be run manually from the Actions tab (only once!)
34
on:
4-
# Testing only
55
workflow_dispatch:
66
inputs:
77
mode:
@@ -10,11 +10,40 @@ on:
1010
description: System deployment mode
1111
options:
1212
- test
13-
- live
1413
- dev
14+
- live
15+
- stage
16+
force:
17+
required: false
18+
type: boolean
19+
description: Force deployment
20+
default: false
21+
confirm:
22+
required: false
23+
type: string
24+
description: Enter "confirm" to confirm you are aware that DATA LOSS, INCLUDING ACCOUNTS, may occur when forcing deployment!
1525
jobs:
1626
setup-aws:
1727
runs-on: ubuntu-latest
1828
steps:
19-
- name: Test
20-
run: echo "Testing!"
29+
- name: Checkout 🛎
30+
uses: actions/checkout@v3
31+
32+
- name: Make scripts executable
33+
run: |
34+
sudo chmod +x ./scripts/support/build.sh
35+
sudo chmod +x ./scripts/aws-initial-setup/initial-aws-setup.sh
36+
37+
- name: Set up Terraform
38+
uses: hashicorp/setup-terraform@v2
39+
with:
40+
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
41+
terraform_wrapper: false
42+
43+
- name: Validate Terraform
44+
working-directory: ./scripts/aws-initial-setup
45+
run: terraform validate
46+
47+
- name: Build & set up AWS infrastructure
48+
working-directory: ./scripts/aws-initial-setup
49+
run: bash initial-aws-setup.sh ${{ github.event.inputs.mode }} false ${{ github.event.inputs.force }} ${{ github.event.inputs.confirm }}
+25-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,31 @@
1-
name: Create draft release
1+
name: "Stage 3: Manually Tag a branch as release, which will result in an automated draft Release"
22

33
on:
4-
# Testing only
54
workflow_dispatch:
5+
inputs:
6+
logLevel:
7+
description: 'Log level'
8+
required: true
9+
default: 'warning'
10+
version:
11+
description: 'Version for release draft. Example: "1.2203.1" -> v1.2203.1'
12+
required: true
13+
postfix:
14+
description: 'Optional postfix. Example: "-beta-1" -> v1.2203.1-beta-1'
15+
required: false
16+
617
jobs:
7-
setup-aws:
18+
add-tag:
19+
name: "Add tag to specified branch, triggering a release draft"
820
runs-on: ubuntu-latest
921
steps:
10-
- name: Test
11-
run: echo "Testing!"
22+
- name: Checkout
23+
uses: actions/checkout@v3
24+
with:
25+
token: ${{ secrets.TAG_TOKEN }}
26+
27+
- name: Create and push new Tag
28+
run: |
29+
echo "Log level: v${{ github.event.inputs.version }}${{ github.event.inputs.postfix }}"
30+
git tag v${{ github.event.inputs.version }}${{ github.event.inputs.postfix }}
31+
git push origin v${{ github.event.inputs.version }}${{ github.event.inputs.postfix }}
+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: "Merges Master into Dev on update, will open a PR if a merge conflict exists"
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
merge-master-to-dev:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout 🛎
14+
- uses: actions/checkout@v3
15+
16+
- name: Make scripts executable
17+
run: sudo chmod +x ./scripts/support/merge-master-into-dev.sh
18+
19+
- name: Set Git config
20+
id: setup
21+
run: |
22+
git config --local user.email "[email protected]"
23+
git config --local user.name "GitHub Action"
24+
25+
- name: Merge master back to dev
26+
id: merge
27+
continue-on-error: true
28+
run: bash merge-master-into-dev.sh
29+
30+
- name: Merge successful
31+
id: push
32+
if: steps.merge.conclusion == success
33+
run: git push
34+
35+
- name: Merge conflict
36+
id: solve_conflict
37+
if: steps.merge.conclusion != success
38+
run: 'gh pr create -B "dev" -t "stage: Auto-update dev from master" -b "Resolve merge conflict" -r polygon-software/team/developers'
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
42+
- name: PR already exists
43+
id: error
44+
if: steps.solve_conflict.conclusion != success
45+
run: echo A PR from master to dev already exists!
+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: "PR: Update Label on monday.com items based on PR Status"
2+
3+
on:
4+
pull_request_review:
5+
types: [submitted, edited]
6+
7+
jobs:
8+
set-status:
9+
name: "Update monday.com Labels to 'PR: Commented' / 'PR: Approved' / 'PR: Rejected'"
10+
runs-on: ubuntu-latest
11+
steps:
12+
# If PR was 'COMMENTED'
13+
- name: "Update state of monday.com items to 'PR: Commented'"
14+
uses: polygon-software/action-monday-state@main
15+
if: ${{ github.event.review.state == 'commented' && github.base_ref != 'master' }}
16+
with:
17+
monday-token: ${{ secrets.MONDAY_TOKEN }}
18+
allow-no-item-id: true
19+
multiple: true
20+
text: ${{ github.event.pull_request.title }}
21+
prefix: '#'
22+
status-column-title: 'Item Status!'
23+
set-status: 'PR: Commented'
24+
25+
# If PR was 'APPROVED'
26+
- name: "Update state of monday.com items to 'PR: Approved'"
27+
uses: polygon-software/action-monday-state@main
28+
if: ${{ github.event.review.state == 'approved' && github.base_ref != 'master' }}
29+
with:
30+
monday-token: ${{ secrets.MONDAY_TOKEN }}
31+
multiple: true
32+
allow-no-item-id: true
33+
text: ${{ github.event.pull_request.title }}
34+
prefix: '#'
35+
status-column-title: 'Item Status!'
36+
set-status: 'PR: Approved'
37+
38+
# If PR was 'REJECTED'
39+
- name: "Update state of monday.com items to 'PR: Rejected'"
40+
uses: polygon-software/action-monday-state@main
41+
if: ${{ github.event.review.state == 'rejected' && github.base_ref != 'master' }}
42+
with:
43+
monday-token: ${{ secrets.MONDAY_TOKEN }}
44+
multiple: true
45+
allow-no-item-id: true
46+
text: ${{ github.event.pull_request.title }}
47+
prefix: '#'
48+
status-column-title: 'Item Status!'
49+
set-status: 'PR: Rejected'
50+

.github/workflows/monday-dev-pr.yml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: "PR: Label monday.com items in a dev PR as 'PR: In Review'"
2+
3+
on:
4+
pull_request:
5+
branches: [dev]
6+
7+
jobs:
8+
set-status:
9+
runs-on: ubuntu-latest
10+
steps:
11+
# Set status to 'PR: In Review' if base branch is not 'master' branch
12+
- name: "Update state of monday.com items to 'PR: In Review'"
13+
id: monday-state
14+
uses: polygon-software/action-monday-state@main
15+
if: ${{ github.base_ref != 'master' }}
16+
with:
17+
monday-token: ${{ secrets.MONDAY_TOKEN }}
18+
multiple: true
19+
allow-no-item-id: true
20+
monday-organization: polygonsoftware
21+
text: ${{ github.event.pull_request.title }}
22+
prefix: '#'
23+
status-column-title: 'Item Status!'
24+
set-status: 'PR: In Review'
25+
26+
- name: Comment PR
27+
uses: polygon-software/actions-comment-pull-request@v1
28+
if: ${{ github.base_ref != 'master' }}
29+
with:
30+
message: ${{ steps.monday-state.outputs.message }}
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: "Stage 1: Label monday.com items in a master PR as 'Stage 1: Staged'"
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
jobs:
8+
set-status:
9+
runs-on: ubuntu-latest
10+
steps:
11+
# The monday.com item IDs must appear in the Pull-Requests Body / Description. Take the commit messages
12+
- name: "Update state of monday.com items to 'Stage 1: Staged'"
13+
id: monday-state
14+
uses: polygon-software/action-monday-state@main
15+
with:
16+
monday-token: ${{ secrets.MONDAY_TOKEN }}
17+
allow-no-item-id: true
18+
multiple: true
19+
monday-organization: polygonsoftware
20+
text: ${{ github.event.pull_request.body }}
21+
prefix: '#'
22+
status-column-title: 'Item Status!'
23+
set-status: 'Stage 1: Staged'
24+
25+
- name: Comment PR
26+
uses: polygon-software/actions-comment-pull-request@v1
27+
with:
28+
message: ${{ steps.monday-state.outputs.message }}
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/monday-push-dev.yml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: "Stage 0: Label monday.com items arriving in DEV as 'Stage 0: Dev'"
2+
3+
on:
4+
push:
5+
branches:
6+
- dev
7+
8+
jobs:
9+
set-status:
10+
name: Set monday.com Item Status
11+
runs-on: ubuntu-latest
12+
steps:
13+
# Set status on-dev for items that appear in a commit message in DEV
14+
- name: "Update state of monday.com items to 'State 0: Dev'"
15+
uses: polygon-software/action-monday-state@main
16+
with:
17+
monday-token: ${{ secrets.MONDAY_TOKEN }}
18+
allow-no-item-id: true
19+
multiple: true
20+
text: ${{ join(github.event.commits.*.message, ', ') }}
21+
prefix: '#'
22+
status-column-title: 'Item Status!'
23+
set-status: 'State 0: Dev'
24+
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: "Stage 2: Label monday.com items arriving in DEV as 'Stage 2: Master'"
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
set-status:
10+
name: Set monday.com Item Status
11+
runs-on: ubuntu-latest
12+
steps:
13+
# Set status on-dev for items that appear in a commit message in DEV
14+
- name: "Update state of monday.com items to 'Stage 2: Master'"
15+
uses: polygon-software/action-monday-state@main
16+
with:
17+
monday-token: ${{ secrets.MONDAY_TOKEN }}
18+
allow-no-item-id: true
19+
multiple: true
20+
text: ${{ join(github.event.commits.*.message, ', ') }}
21+
prefix: '#'
22+
status-column-title: 'Item Status!'
23+
set-status: 'Stage 2: Master'
24+
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: "Stage 1: Label monday.com items arriving in stage as 'Stage 1: Staged'"
2+
3+
on:
4+
push:
5+
branches:
6+
- stage
7+
8+
jobs:
9+
set-status:
10+
name: Set monday.com Item Status
11+
runs-on: ubuntu-latest
12+
steps:
13+
# Set status on-stage for items that appear in a commit message in stage
14+
- name: "Update state of monday.com items to 'State 1: Staged'"
15+
uses: polygon-software/action-monday-state@main
16+
with:
17+
monday-token: ${{ secrets.MONDAY_TOKEN }}
18+
allow-no-item-id: true
19+
multiple: true
20+
text: ${{ join(github.event.commits.*.message, ', ') }}
21+
prefix: '#'
22+
status-column-title: 'Item Status!'
23+
set-status: 'State 1: Staged'
24+

0 commit comments

Comments
 (0)