From 9e37e101cb92520fe972dfac85488d3a9ac1f59e Mon Sep 17 00:00:00 2001 From: addis-samtek <155009976+addis-samtek@users.noreply.github.com> Date: Wed, 11 Dec 2024 12:15:33 -0500 Subject: [PATCH 1/2] add app context for removal --- .github/workflows/remove-experimental.yml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/workflows/remove-experimental.yml b/.github/workflows/remove-experimental.yml index 27d06c3a3..0b06633d2 100644 --- a/.github/workflows/remove-experimental.yml +++ b/.github/workflows/remove-experimental.yml @@ -110,7 +110,9 @@ jobs: echo "Destroying PR-specific stack: ${STACK_NAME}" cdk destroy "${STACK_NAME}" \ -c environment=${{ env.ENVIRONMENT_NAME }} \ - --force + --force \ + --exclusively \ + --app "npx ts-node bin/zip-lambdas.ts" echo "Cleanup completed for stack: ${STACK_NAME}" popd @@ -132,7 +134,9 @@ jobs: echo "Destroying PR-specific stack: ${STACK_NAME}" cdk destroy "${STACK_NAME}" \ -c environment=${{ env.ENVIRONMENT_NAME }} \ - --force + --force \ + --exclusively \ + --app "npx ts-node bin/zip-lambdas.ts" echo "Cleanup completed for stack: ${STACK_NAME}" popd @@ -158,18 +162,24 @@ jobs: cdk destroy "${TEXT_EXTRACTOR_STACK}" \ -c environment=${{ env.ENVIRONMENT_NAME }} \ --force + --exclusively \ + --app "npx ts-node bin/docker-lambdas.ts" # Destroy fr-parser stack echo "Destroying PR-specific stack: ${FR_PARSER_STACK}" cdk destroy "${FR_PARSER_STACK}" \ -c environment=${{ env.ENVIRONMENT_NAME }} \ - --force + --force \ + --exclusively \ + --app "npx ts-node bin/docker-lambdas.ts" # Destroy ecfr-parser stack echo "Destroying PR-specific stack: ${ECFR_PARSER_STACK}" cdk destroy "${ECFR_PARSER_STACK}" \ -c environment=${{ env.ENVIRONMENT_NAME }} \ --force + --exclusively \ + --app "npx ts-node bin/docker-lambdas.ts" echo "Cleanup completed for all Docker-based stacks" popd From a3115b673a7482ac18705121c92c7193eb2193bc Mon Sep 17 00:00:00 2001 From: addis-samtek <155009976+addis-samtek@users.noreply.github.com> Date: Thu, 12 Dec 2024 10:20:23 -0500 Subject: [PATCH 2/2] Add CDK deployment to dev env --- .github/workflows/deploy-cdk-dev.yml | 173 +++++++++++++++++++++++++++ 1 file changed, 173 insertions(+) create mode 100644 .github/workflows/deploy-cdk-dev.yml diff --git a/.github/workflows/deploy-cdk-dev.yml b/.github/workflows/deploy-cdk-dev.yml new file mode 100644 index 000000000..db79f8eb8 --- /dev/null +++ b/.github/workflows/deploy-cdk-dev.yml @@ -0,0 +1,173 @@ +name: Deploy CDK to DEV + +on: + workflow_dispatch: + push: + branches: + - main + +permissions: + id-token: write + contents: read + actions: read + +concurrency: ${{ github.workflow }}-${{ github.ref }} + +jobs: + deploy-zip-lambdas-cdk: + strategy: + max-parallel: 1 + matrix: + environment: ["dev"] + runs-on: ubuntu-22.04 + environment: + name: ${{ matrix.environment }} + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: true + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: ${{ secrets.AWS_OIDC_ROLE_TO_ASSUME }} + aws-region: us-east-1 + + - name: Deploy ZIP-based Lambdas + env: + AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }} + AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }} + CDK_DEBUG: true + run: | + pushd cdk-eregs + npm install -g aws-cdk@latest @aws-sdk/client-ssm + npm install + + # Get exact stack names + REDIRECT_STACK="cms-eregs-${{ matrix.environment }}-redirect-api" + MAINTENANCE_STACK="cms-eregs-${{ matrix.environment }}-maintenance-api" + + cdk deploy ${REDIRECT_STACK} ${MAINTENANCE_STACK} \ + -c environment=${{ matrix.environment }} \ + --require-approval never \ + --exclusively \ + --app "npx ts-node bin/zip-lambdas.ts" + popd + + deploy-text-extractor-cdk: + needs: deploy-zip-lambdas-cdk + strategy: + max-parallel: 1 + matrix: + environment: ["dev"] + runs-on: ubuntu-22.04 + environment: + name: ${{ matrix.environment }} + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: true + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: ${{ secrets.AWS_OIDC_ROLE_TO_ASSUME }} + aws-region: us-east-1 + + - name: Deploy Text Extractor + env: + AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }} + AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }} + CDK_DEBUG: true + run: | + pushd cdk-eregs + npm install -g aws-cdk@latest @aws-sdk/client-ssm + npm install + + TEXT_EXTRACTOR_STACK="cms-eregs-${{ matrix.environment }}-text-extractor" + + cdk deploy $TEXT_EXTRACTOR_STACK \ + -c environment=${{ matrix.environment }} \ + --require-approval never \ + --exclusively \ + --app "npx ts-node bin/docker-lambdas.ts" + popd + + deploy-fr-parser-cdk: + needs: [deploy-zip-lambdas-cdk, deploy-text-extractor-cdk] + strategy: + max-parallel: 1 + matrix: + environment: ["dev"] + runs-on: ubuntu-22.04 + environment: + name: ${{ matrix.environment }} + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: true + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: ${{ secrets.AWS_OIDC_ROLE_TO_ASSUME }} + aws-region: us-east-1 + + - name: Deploy FR Parser + env: + AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }} + AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }} + CDK_DEBUG: true + run: | + pushd cdk-eregs + npm install -g aws-cdk@latest @aws-sdk/client-ssm + npm install + + FR_PARSER_STACK="cms-eregs-${{ matrix.environment }}-fr-parser" + + cdk deploy $FR_PARSER_STACK \ + -c environment=${{ matrix.environment }} \ + --require-approval never \ + --exclusively \ + --app "npx ts-node bin/docker-lambdas.ts" + popd + + deploy-ecfr-parser-cdk: + needs: [deploy-zip-lambdas-cdk, deploy-text-extractor-cdk, deploy-fr-parser-cdk] + strategy: + max-parallel: 1 + matrix: + environment: ["dev"] + runs-on: ubuntu-22.04 + environment: + name: ${{ matrix.environment }} + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: true + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: ${{ secrets.AWS_OIDC_ROLE_TO_ASSUME }} + aws-region: us-east-1 + + - name: Deploy ECFR Parser + env: + AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }} + AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }} + CDK_DEBUG: true + run: | + pushd cdk-eregs + npm install -g aws-cdk@latest @aws-sdk/client-ssm + npm install + + ECFR_PARSER_STACK="cms-eregs-${{ matrix.environment }}-ecfr-parser" + + cdk deploy $ECFR_PARSER_STACK \ + -c environment=${{ matrix.environment }} \ + --require-approval never \ + --exclusively \ + --app "npx ts-node bin/docker-lambdas.ts" + popd \ No newline at end of file