Add GitHub Actions workflow for CDK deployment
This commit is contained in:
parent
5cef51b0f6
commit
cc819fbce5
1 changed files with 47 additions and 0 deletions
47
.github/workflows/deploy.yml
vendored
Normal file
47
.github/workflows/deploy.yml
vendored
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
name: Deploy AWS CDK Stack
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
permissions:
|
||||
id-token: write # Required for OIDC role assumption
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: 'npm'
|
||||
cache-dependency-path: 'aws_cdk/package-lock.json'
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
cd aws_cdk
|
||||
npm ci
|
||||
|
||||
- name: Configure AWS Credentials
|
||||
uses: aws-actions/configure-aws-credentials@v4
|
||||
with:
|
||||
# OIDC Authentication (Recommended & secure: no long-lived secrets)
|
||||
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
|
||||
aws-region: ${{ secrets.AWS_REGION || 'us-east-1' }}
|
||||
# Fallback: uncomment below if using access keys instead of OIDC
|
||||
# aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
# aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
|
||||
- name: Deploy CDK Stack
|
||||
run: |
|
||||
cd aws_cdk
|
||||
npx cdk deploy --require-approval never
|
||||
env:
|
||||
CDK_DEFAULT_ACCOUNT: ${{ secrets.AWS_ACCOUNT_ID }}
|
||||
CDK_DEFAULT_REGION: ${{ secrets.AWS_REGION || 'us-east-1' }}
|
||||
Loading…
Reference in a new issue