-
Notifications
You must be signed in to change notification settings - Fork 12
Draft: switch AWS deployment from Serverless to CDK #121
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
Open
colorchestra
wants to merge
36
commits into
develop
Choose a base branch
from
deploy-2026
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
2db73b0
init: new CDK deployment
a5d374b
fix Lambda deployment
05597ca
add Api Gateway for Lambdas and Cloudfront; update config for dev
f10d031
actually add config this time
542ec9c
autoformat CDK files
807ea0b
Code-Cleanup CDK
374658d
better document distribution methods
479d725
CDK-Dokumentation hinzugefügt
4370d83
AWS-Account immer aus Config nehmen
436dbb3
Aktualisierung Bucket Suffix
e98ae6f
Update auf neues ACM-Cert in Zielaccount
37ac4f0
don't share project buckets between dev and staging environments
e9c2833
add esbuild to yarn build process for lambdas
35a89c8
feat(deploy): allow uploading new assets to dev projects bucket from …
jh0ker 284ac39
update Readme and autogenerated deployment.md
b83603c
Add initial gated deploy pipeline for dev
66136f3
Move / disable old workflows
cd2d911
add deploy workflow for dev and workflows for deploy and staging
6ea9d55
Disable hosted zones / Route53 for now
58bf37c
Update deployment workflows and documentation
babc5ae
set AWS account ID for all environments
7749790
Add BRANCH variable and bash shell features to workflows
df7eb84
Change allowedMethods from Cloudfront to project bucket
2a84c66
Bundle dependencies in Lambda with esbuild
463a036
Add entrypoint rewriting for /settings and /teilen, both for CloudFro…
3f6beef
Remove *.js from CDK .gitignore for Cloudfront Functions
e81eaeb
Route all page requests in the CloudFront Function, remove global err…
c4ac5ca
Add frontend deployment order, disable pruning for static assets but …
8f8f0c2
Fix Lambda memory size
534de3a
document Cloudfront Function
db61163
Update README.md and DEPLOYMENT.md
2cbe9d1
Add some useful CFN Outputs
b229325
Fix typo in workflow environemnt variable name
35a8cf9
Install optional Yarn dependencies to fix pr-checks
75d4ec7
Remove Netlify stuff to fix build
2234b38
add todo item
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| S3_BUCKET_PREFIX=hackingstudio-code4maus-projects | ||
| S3_BUCKET_PREFIX=pmdm-projectbucket | ||
| AWS_REGION=eu-central-1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| # Deployment-Workflow mit Bestätigung, angedacht für staging und prod | ||
| # Job "plan": führt `cdk synth` aus und schreibt die Ánderungen bzw. das Diff in den Job-Output. | ||
| # cdk.out wird als Artefakt gespeichert | ||
| # Job "apply": lädt das neue Template (bzw. cdk.out) herunter und deployt es | ||
|
|
||
| name: deploy (gated) | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| stage: | ||
| description: CDK-Stage (staging | prod) | ||
| required: true | ||
| type: string | ||
| environment: | ||
| description: Github-Environment (Approval-Gate + Secrets) | ||
| required: true | ||
| type: string | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| env: | ||
| AWS_REGION: eu-central-1 | ||
| NODE_OPTIONS: --max-old-space-size=4096 | ||
|
|
||
| jobs: | ||
| # ---- Plan: synth + diff, ohne etwas zu verändern ------------------------- | ||
| plan: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Node 24 einrichten | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 24 | ||
| cache: yarn | ||
|
|
||
| - name: AWS-Credentials | ||
| uses: aws-actions/configure-aws-credentials@v4 | ||
| with: | ||
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_2026 }} | ||
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_2026 }} | ||
| aws-region: ${{ env.AWS_REGION }} | ||
|
|
||
| - name: Frontend-Dependencies installieren | ||
| run: yarn install --frozen-lockfile | ||
|
|
||
| - name: Frontend bauen | ||
| run: yarn build | ||
| env: | ||
| NODE_ENV: production | ||
| BRANCH: ${{ github.ref_name }} | ||
|
|
||
| - name: CDK-Dependencies installieren | ||
| run: npm ci | ||
| working-directory: cdk | ||
|
|
||
| - name: CDK synth | ||
| run: npx cdk synth --context stage=${{ inputs.stage }} | ||
| working-directory: cdk | ||
|
|
||
| # diff gegen den deployten Stack (change-set-basiert = autoritativ) in die | ||
| # Run-Summary schreiben, damit Reviewer:innen es VOR der Freigabe sehen. | ||
| - name: CDK diff → Summary | ||
| working-directory: cdk | ||
| shell: bash | ||
| run: | | ||
| npx cdk diff --app cdk.out "MausApp-${{ inputs.stage }}" 2>&1 | tee diff.txt | ||
| { | ||
| echo "## CDK diff (${{ inputs.stage }})" | ||
| echo '```' | ||
| cat diff.txt | ||
| echo '```' | ||
| } >> "$GITHUB_STEP_SUMMARY" | ||
|
|
||
| - name: Cloud Assembly sichern | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: cloud-assembly-${{ inputs.stage }} | ||
| path: cdk/cdk.out | ||
| retention-days: 5 | ||
|
|
||
| # ---- Apply: deployt exakt das geplante Assembly, nach Approval ------------ | ||
| apply: | ||
| needs: plan | ||
| runs-on: ubuntu-latest | ||
| # Das Environment ist das Gate: hat es einen Required Reviewer (prod), | ||
| # pausiert der Run hier, bis freigegeben wird. | ||
| environment: ${{ inputs.environment }} | ||
| concurrency: | ||
| group: deploy-${{ inputs.stage }} | ||
| cancel-in-progress: false | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Node 24 einrichten | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 24 | ||
| cache: yarn | ||
|
|
||
| - name: AWS-Credentials | ||
| uses: aws-actions/configure-aws-credentials@v4 | ||
| with: | ||
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_2026 }} | ||
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_2026 }} | ||
| aws-region: ${{ env.AWS_REGION }} | ||
|
|
||
| # Nur die CDK-CLI wird gebraucht; nicht neu bauen/synthen. | ||
| - name: CDK-Dependencies installieren | ||
| run: npm ci | ||
| working-directory: cdk | ||
|
|
||
| - name: Cloud Assembly laden | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: cloud-assembly-${{ inputs.stage }} | ||
| path: cdk/cdk.out | ||
|
|
||
| - name: CDK deploy (exakt das reviewte Assembly) | ||
| working-directory: cdk | ||
| run: npx cdk deploy --app cdk.out "MausApp-${{ inputs.stage }}" --require-approval never | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| # Baut Assets und `cdk deploy`t direkt, ohne Bestätigung | ||
|
jh0ker marked this conversation as resolved.
|
||
| # intendiert für dev | ||
| name: deploy | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| stage: | ||
| description: CDK-Stage (dev / staging / prod) | ||
| required: true | ||
| type: string | ||
| environment: | ||
| description: GitHub-Environment | ||
| required: true | ||
| type: string | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| deploy: | ||
| runs-on: ubuntu-26.04 # noch in Test -> latest lieber vermeiden | ||
| #runs-on: ubuntu-latest | ||
| environment: ${{ inputs.environment }} | ||
| # verhindert überlappende Deploys auf dieselbe Stage | ||
| concurrency: | ||
| group: deploy-${{ inputs.stage }} | ||
| cancel-in-progress: false | ||
| env: | ||
|
jh0ker marked this conversation as resolved.
|
||
| AWS_REGION: eu-central-1 | ||
| NODE_OPTIONS: --max-old-space-size=4096 | ||
| BRANCH: ${{ github.ref_name }} | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Node 24 einrichten | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 24 | ||
| cache: yarn | ||
|
|
||
| - name: AWS-Credentials | ||
| uses: aws-actions/configure-aws-credentials@v4 | ||
| with: | ||
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_2026 }} | ||
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_2026 }} | ||
| aws-region: ${{ env.AWS_REGION }} | ||
|
|
||
| - name: Frontend-Dependencies installieren | ||
| run: yarn install --frozen-lockfile | ||
|
|
||
| - name: Frontend bauen | ||
| run: yarn build | ||
| env: | ||
| NODE_ENV: production | ||
|
|
||
| # CDK-Projekt (npm). esbuild für das Lambda-Bundling wird aus dem | ||
| # Repo-Root (yarn) aufgelöst und muss dort nicht erneut installiert werden | ||
| - name: CDK-Dependencies installieren | ||
| run: npm ci | ||
| working-directory: cdk | ||
|
|
||
| # Loggt das diff -> keine Bestätigung nötig | ||
| - name: CDK diff | ||
| run: npx cdk diff --context stage=${{ inputs.stage }} | ||
| working-directory: cdk | ||
|
|
||
| - name: CDK deploy | ||
| run: npx cdk deploy --context stage=${{ inputs.stage }} --require-approval never | ||
| working-directory: cdk | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # Push auf develop -> Deploy auf Stage dev. Zusätzlich manuell per | ||
| # workflow_dispatch (praktisch, um einen Feature-Branch gegen dev zu testen). | ||
| name: Deploy dev | ||
|
|
||
| on: | ||
| push: | ||
| branches: [develop] | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| deploy: | ||
| uses: ./.github/workflows/_deploy.yml | ||
| with: | ||
| stage: dev | ||
| environment: dev | ||
| secrets: inherit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # Push auf production -> Plan/Approve/Apply auf Stage prod. | ||
| # Das GitHub-Environment "prod" braucht einen Required Reviewer, damit der | ||
| # Apply-Job erst nach manueller Freigabe läuft. | ||
| name: Deploy production | ||
|
|
||
| on: | ||
| push: | ||
| branches: [production] | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| deploy: | ||
| uses: ./.github/workflows/_deploy-gated.yml | ||
| with: | ||
| stage: prod | ||
| environment: prod | ||
| secrets: inherit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| # Push auf staging -> Plan/Approve/Apply auf Stage staging. | ||
| name: Deploy staging | ||
|
|
||
| on: | ||
| push: | ||
| branches: [staging] | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| deploy: | ||
| uses: ./.github/workflows/_deploy-gated.yml | ||
| with: | ||
| stage: staging | ||
| environment: staging | ||
| secrets: inherit |
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # Validierung für Pull Requests gegen develop/staging/production – OHNE Deploy und ohne | ||
| # AWS-Credentials. Baut das Frontend und synthetisiert den CDK-Stack, um Bundling-, | ||
| # Config- und Template-Fehler vor dem Merge zu fangen. | ||
| name: PR checks | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: [develop, staging, production] | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| validate: | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| NODE_OPTIONS: --max-old-space-size=4096 | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Node 24 einrichten | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 24 | ||
| cache: yarn | ||
|
|
||
| - name: Frontend-Dependencies installieren | ||
| run: yarn install --frozen-lockfile | ||
|
|
||
| - name: Frontend bauen | ||
| run: yarn build | ||
| env: | ||
| NODE_ENV: production | ||
|
|
||
| - name: CDK-Dependencies installieren | ||
| run: npm ci | ||
| working-directory: cdk | ||
|
|
||
| # synth braucht keine AWS-Credentials (keine fromLookup-Aufrufe im Stack). | ||
| # dev ist vollständig konfiguriert und dient hier als Validierungs-Stage. | ||
| - name: CDK synth | ||
| run: npx cdk synth --context stage=dev | ||
| working-directory: cdk |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| !jest.config.js | ||
| *.d.ts | ||
| node_modules | ||
|
|
||
| # CDK asset staging directory | ||
| .cdk.staging | ||
| cdk.out |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| *.ts | ||
| !*.d.ts | ||
|
|
||
| # CDK asset staging directory | ||
| .cdk.staging | ||
| cdk.out |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.