Skip to content

Add Node.js setup and update CDK workflow steps #13

Add Node.js setup and update CDK workflow steps

Add Node.js setup and update CDK workflow steps #13

Workflow file for this run

name: Validate and Deploy Python CDK
permissions:
id-token: write
contents: read
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout PR branch
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install AWS CDK CLI
run: npm install -g aws-cdk
- name: Configure AWS credentials (OIDC)
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/Github
aws-region: us-east-1
- name: Set up Python virtual environment
run: python -m venv .venv
- name: Upgrade pip and install boto3
run: |
source .venv/bin/activate
pip install --upgrade pip
pip install boto3
- name: Generate config from template
run: |
source .venv/bin/activate
python -c "
import json, boto3

Check failure on line 53 in .github/workflows/main.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/main.yml

Invalid workflow file

You have an error in your yaml syntax on line 53
from pathlib import Path
template_path = Path('.cicd/config.template')
with open(template_path) as f:
config_template = f.read()
config_template = config_template.replace('<env>', 'dev')
config_template = config_template.replace('<initial_user_email>', 'medialake+test@amazon.com')
sts = boto3.client('sts')
account_id = sts.get_caller_identity()['Account']
region = boto3.Session().region_name or 'us-west-2'
config_template = config_template.replace('<aws_account_id>', account_id)
config_template = config_template.replace('<aws_region>', region)
config = json.loads(config_template)
output_path = Path('guidance-for-medialake-on-aws/config.json')
output_path.parent.mkdir(exist_ok=True, parents=True)
with open(output_path, 'w') as f:
json.dump(config, f, indent=2)
print(f'Wrote {output_path}')
"
- name: Install CDK project dependencies
run: |
source .venv/bin/activate
pip install -r requirements.txt
- name: Synthesize CDK stacks
run: |
source .venv/bin/activate
cdk synth
- name: Deploy all CDK stacks
run: |
source .venv/bin/activate
cdk deploy --all --require-approval=never