'Deploying angular application with aws-cdk on github actions
I am not much of devops person so looking for some help. I have tried a few different things here. So I have a single AWS account which I created access tokens for with correct permissions and am looking to have github actions build and deploy this pretty small angular app into an S3 bucket
name: Deployment
on:
push:
branches:
- main
workflow_dispatch:
env:
AWS_ACCOUNT: ${{ secrets.AWS_ACCOUNT }}
jobs:
build:
name: Build Angular project
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: "16.x"
registry-url: "https://npm.pkg.github.com"
cache: "npm"
- name: Compile client code
run: |
npm ci
npm run build
rm -f dist/*.map
cd ./cdk
npm ci
cd ..
- name: Upload build artifact
uses: actions/upload-artifact@v3
with:
name: build
path: |
${{ inputs.ng_directory }}/dist
${{ inputs.ng_directory }}/src/configs
retention-days: 1
- name: cdk bootstrap
uses: youyo/[email protected]
with:
cdk_subcommand: "bootstrap"
cdk_stack: "aws:// ${{ secrets.AWS_ACCOUNT }}/us-east-1"
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: "us-east-1"
- name: cdk synth
uses: youyo/[email protected]
with:
cdk_subcommand: "synth"
working_dir: "./cdk"
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: "us-east-1"
- name: cdk deploy
uses: youyo/[email protected]
with:
cdk_subcommand: "deploy"
cdk_stack: "frontend-appName"
cdk_args: "--require-approval never"
working_dir: "./cdk"
actions_comment: false
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: "us-east-1"
build is right now failing at
Install aws-cdk latest
Successful install aws-cdk latest
Run cdk bootstrap "aws:// ***/us-east-1"
⏳ Bootstrapping environment aws:// ***/us-east-1...
❌ Environment aws:// ***/us-east-1 failed bootstrapping: Error: Need to perform AWS calls for account ***, but the current credentials are for ***
at SdkProvider.forEnvironment (/usr/lib/node_modules/aws-cdk/lib/api/aws-auth/sdk-provider.ts:184:60)
at Function.lookup (/usr/lib/node_modules/aws-cdk/lib/api/bootstrap/deploy-bootstrap.ts:31:18)
at Bootstrapper.modernBootstrap (/usr/lib/node_modules/aws-cdk/lib/api/bootstrap/bootstrap-environment.ts:81:21)
at /usr/lib/node_modules/aws-cdk/lib/cdk-toolkit.ts:575:24
at async Promise.all (index 0)
at CdkToolkit.bootstrap (/usr/lib/node_modules/aws-cdk/lib/cdk-toolkit.ts:572:5)
at initCommandLine (/usr/lib/node_modules/aws-cdk/lib/cli.ts:341:12)
I have added the extra step "cdk bootstrap" because previous runs had a failure stating the application was not bootstrapped
Can someone help me troubleshoot this? I am not sure my specific issue but feel like I am very close.
Solution 1:[1]
Your machine needs to have the access & secret keys of the account which you're trying to bootstrap, but it seems they're incorrectly configured.
I suggest log into the AWS account which you're trying to bootstrap and generate fresh secret & access keys for your user, and then configure AWS CLI your machine to use those keys.
This article explains how to do the same, hope this helps.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Vijay Chavda |
