diff --git a/.github/workflows/autobuild.yml b/.github/workflows/autobuild.yml index 7866de86f2..0101988147 100644 --- a/.github/workflows/autobuild.yml +++ b/.github/workflows/autobuild.yml @@ -17,10 +17,11 @@ jobs: architecture: [x86_64, arm64] uses: ./.github/workflows/push-to-s3.yml with: - region: 'us-east-1' + environment: PROD architecture: ${{ matrix.architecture }} secrets: role: ${{ secrets.AWS_ROLE_TO_ASSUME }} + prodRegion: ${{ secrets.AWS_PROD_REGION }} trigger-push-to-ecr: needs: trigger-push-to-s3 @@ -30,8 +31,9 @@ jobs: architecture: [x86_64, arm64] uses: ./.github/workflows/push-to-ecr.yml with: - region: 'us-east-1' + environment: PROD architecture: ${{ matrix.architecture }} secrets: role: ${{ secrets.AWS_ROLE_TO_ASSUME }} - account_id: ${{ secrets.AWS_ACCOUNT_ID }} \ No newline at end of file + account_id: ${{ secrets.AWS_ACCOUNT_ID }} + prodRegion: ${{ secrets.AWS_PROD_REGION }} \ No newline at end of file diff --git a/.github/workflows/aws-deploy.yml b/.github/workflows/aws-deploy.yml index 07c0550e30..8516f68685 100644 --- a/.github/workflows/aws-deploy.yml +++ b/.github/workflows/aws-deploy.yml @@ -7,19 +7,12 @@ permissions: on: workflow_dispatch: inputs: - region: - description: 'region on which you want to deploy' + environment: + description: 'Environment to deploy' type: choice options: - - eu-west-1 - - us-east-1 - required: true - lambdaPerfEnv: - description: 'environment on which you want to deploy' - type: choice - options: - - staging - - production + - DEV + - PROD required: true jobs: @@ -62,12 +55,12 @@ jobs: with: role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} role-session-name: GitHub_Action_LambdaPerf_Session - aws-region: ${{ inputs.region }} + aws-region: ${{ inputs.environment == 'DEV' && secrets.AWS_DEV_REGION || inputs.environment == 'PROD' && secrets.AWS_PROD_REGION }} - name: deploy env: - AWS_REGION: ${{ inputs.region }} - LAMBDA_PERF_ENV: ${{ inputs.lambdaPerfEnv }} - SKIP_SNAPSTART: ${{ (inputs.region == 'eu-west-1') && secrets.SKIP_SNAPSTART_DEV || 'false' }} - GITHUB_AUTH_TOKEN: ${{ secrets.GH_AUTH_TOKEN }} + AWS_REGION: ${{ inputs.environment == 'DEV' && secrets.AWS_DEV_REGION || inputs.environment == 'PROD' && secrets.AWS_PROD_REGION }} + LAMBDA_PERF_ENV: ${{ inputs.environment == 'PROD' && 'production' || 'dev' }} + SKIP_SNAPSTART: ${{ (inputs.environment == 'DEV') && secrets.SKIP_SNAPSTART_DEV || 'false' }} + GITHUB_AUTH_TOKEN: ${{ inputs.environment == 'PROD' && secrets.GH_AUTH_TOKEN || 'no-token-needed' }} AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }} run: cd cdk && yarn install && cdk bootstrap && cdk deploy LambdaPerfStack --require-approval never \ No newline at end of file diff --git a/.github/workflows/aws-publish-artifact-to-ecr.yml b/.github/workflows/aws-publish-artifact-to-ecr.yml index 8d1ba92036..7981bbf6f4 100644 --- a/.github/workflows/aws-publish-artifact-to-ecr.yml +++ b/.github/workflows/aws-publish-artifact-to-ecr.yml @@ -7,15 +7,15 @@ permissions: on: workflow_dispatch: inputs: - region: - description: 'region on which you want to deploy' + environment: + description: 'Environment to deploy' type: choice options: - - eu-west-1 - - us-east-1 + - DEV + - PROD required: true architecture: - description: 'architecture' + description: 'Architecture' type: choice options: - x86_64 @@ -26,9 +26,10 @@ jobs: trigger-push-to-ecr: uses: ./.github/workflows/push-to-ecr.yml with: - region: ${{ inputs.region }} architecture: ${{ inputs.architecture }} + environment: ${{ inputs.environment }} secrets: role: ${{ secrets.AWS_ROLE_TO_ASSUME }} account_id: ${{ secrets.AWS_ACCOUNT_ID }} - \ No newline at end of file + devRegion: ${{ secrets.AWS_DEV_REGION }} + prodRegion: ${{ secrets.AWS_PROD_REGION }} diff --git a/.github/workflows/aws-publish-artifact-to-s3.yml b/.github/workflows/aws-publish-artifact-to-s3.yml index 541b35b389..1ca948c43c 100644 --- a/.github/workflows/aws-publish-artifact-to-s3.yml +++ b/.github/workflows/aws-publish-artifact-to-s3.yml @@ -7,15 +7,15 @@ permissions: on: workflow_dispatch: inputs: - region: - description: 'region on which you want to deploy' + environment: + description: 'Environment to deploy' type: choice options: - - eu-west-1 - - us-east-1 + - DEV + - PROD required: true architecture: - description: 'architecture' + description: 'Architecture' type: choice options: - x86_64 @@ -26,8 +26,9 @@ jobs: trigger-push-to-s3: uses: ./.github/workflows/push-to-s3.yml with: - region: ${{ inputs.region }} architecture: ${{ inputs.architecture }} + environment: ${{ inputs.environment }} secrets: role: ${{ secrets.AWS_ROLE_TO_ASSUME }} - \ No newline at end of file + devRegion: ${{ secrets.AWS_DEV_REGION }} + prodRegion: ${{ secrets.AWS_PROD_REGION }} \ No newline at end of file diff --git a/.github/workflows/push-to-ecr.yml b/.github/workflows/push-to-ecr.yml index 07ea4df787..a1c4ca944c 100644 --- a/.github/workflows/push-to-ecr.yml +++ b/.github/workflows/push-to-ecr.yml @@ -7,14 +7,14 @@ permissions: on: workflow_call: inputs: - region: - description: 'region on which you want to deploy' - type: string - required: true architecture: description: 'architecture' type: string required: true + environment: + description: 'environment' + type: string + required: true secrets: role: description: 'AWS role to assume' @@ -22,6 +22,12 @@ on: account_id: description: 'AWS account id' required: true + devRegion: + description: 'AWS region for DEV' + required: false + prodRegion: + description: 'AWS region for PROD' + required: false jobs: setup: @@ -60,7 +66,7 @@ jobs: with: role-to-assume: ${{ secrets.role }} role-session-name: GitHub_Action_LambdaPerf_Session - aws-region: ${{ inputs.region }} + aws-region: ${{ inputs.environment == 'DEV' && secrets.devRegion || inputs.environment == 'PROD' && secrets.prodRegion }} - name: Delete huge unnecessary folders run: | rm -rf /opt/hostedtoolcache @@ -75,7 +81,7 @@ jobs: - name: build and deploy env: ARCHITECTURE: ${{ inputs.architecture }} - AWS_REGION: ${{ inputs.region }} + AWS_REGION: ${{ inputs.environment == 'DEV' && secrets.devRegion || inputs.environment == 'PROD' && secrets.prodRegion }} RUNTIME_ID: ${{ matrix.runtime_id }} AWS_ACCOUNT_ID: ${{ secrets.account_id }} run: | @@ -92,10 +98,10 @@ jobs: with: role-to-assume: ${{ secrets.role }} role-session-name: GitHub_Action_LambdaPerf_Session - aws-region: ${{ inputs.region }} + aws-region: ${{ inputs.environment == 'DEV' && secrets.devRegion || inputs.environment == 'PROD' && secrets.prodRegion }} - name: clean untagged images env: - AWS_REGION: ${{ inputs.region }} + AWS_REGION: ${{ inputs.environment == 'DEV' && secrets.devRegion || inputs.environment == 'PROD' && secrets.prodRegion }} run: | UNTAGGED_IMAGES=$(aws ecr list-images --region "${AWS_REGION}" --repository-name lambda-perf --filter "tagStatus=UNTAGGED" --query 'imageIds[*]' --output json) if [[ "$UNTAGGED_IMAGES" == "[]" ]]; then diff --git a/.github/workflows/push-to-s3.yml b/.github/workflows/push-to-s3.yml index 0f1a97bbcf..4ec59f5447 100644 --- a/.github/workflows/push-to-s3.yml +++ b/.github/workflows/push-to-s3.yml @@ -7,18 +7,24 @@ permissions: on: workflow_call: inputs: - region: - description: 'region on which you want to deploy' - type: string - required: true architecture: description: 'architecture' type: string required: true + environment: + description: 'environment' + type: string + required: true secrets: role: description: 'AWS role to assume' required: true + devRegion: + description: 'AWS region for DEV' + required: false + prodRegion: + description: 'AWS region for PROD' + required: false jobs: setup: @@ -56,7 +62,7 @@ jobs: with: role-to-assume: ${{ secrets.role }} role-session-name: GitHub_Action_LambdaPerf_Session - aws-region: ${{ inputs.region }} + aws-region: ${{ inputs.environment == 'DEV' && secrets.devRegion || inputs.environment == 'PROD' && secrets.prodRegion }} - uses: actions/checkout@v4 - name: Set up Docker uses: docker/setup-docker-action@v4 @@ -66,7 +72,7 @@ jobs: - name: build and deploy env: ARCHITECTURE: ${{ inputs.architecture }} - AWS_REGION: ${{ inputs.region }} + AWS_REGION: ${{ inputs.environment == 'DEV' && secrets.devRegion || inputs.environment == 'PROD' && secrets.prodRegion }} RUNTIME_ID: ${{ matrix.runtime_id }} run: | cd s3-uploader diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b9dabff8ba..276f642ffc 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -41,7 +41,8 @@ jobs: architecture: [x86_64, arm64] uses: ./.github/workflows/push-to-s3.yml with: - region: 'us-east-1' + environment: DEV architecture: ${{ matrix.architecture }} secrets: role: ${{ secrets.AWS_ROLE_TO_ASSUME }} + devRegion: ${{ secrets.AWS_DEV_REGION }}