Skip to content

Commit f112e27

Browse files
authored
feat: dynamic region (#1892)
* fix: regions are now configurable * fix: region * fix: region * fix: region * fix: region * fix: region * fix: region * fix: region * fix: region * fix: region * fix: region * fix: region * fix: region * fix: region * fix: region * fix: region * fix: region * fix: token * fix: region
1 parent ce8405c commit f112e27

File tree

7 files changed

+58
-48
lines changed

7 files changed

+58
-48
lines changed

.github/workflows/autobuild.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ jobs:
1717
architecture: [x86_64, arm64]
1818
uses: ./.github/workflows/push-to-s3.yml
1919
with:
20-
region: 'us-east-1'
20+
environment: PROD
2121
architecture: ${{ matrix.architecture }}
2222
secrets:
2323
role: ${{ secrets.AWS_ROLE_TO_ASSUME }}
24+
prodRegion: ${{ secrets.AWS_PROD_REGION }}
2425

2526
trigger-push-to-ecr:
2627
needs: trigger-push-to-s3
@@ -30,8 +31,9 @@ jobs:
3031
architecture: [x86_64, arm64]
3132
uses: ./.github/workflows/push-to-ecr.yml
3233
with:
33-
region: 'us-east-1'
34+
environment: PROD
3435
architecture: ${{ matrix.architecture }}
3536
secrets:
3637
role: ${{ secrets.AWS_ROLE_TO_ASSUME }}
37-
account_id: ${{ secrets.AWS_ACCOUNT_ID }}
38+
account_id: ${{ secrets.AWS_ACCOUNT_ID }}
39+
prodRegion: ${{ secrets.AWS_PROD_REGION }}

.github/workflows/aws-deploy.yml

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,12 @@ permissions:
77
on:
88
workflow_dispatch:
99
inputs:
10-
region:
11-
description: 'region on which you want to deploy'
10+
environment:
11+
description: 'Environment to deploy'
1212
type: choice
1313
options:
14-
- eu-west-1
15-
- us-east-1
16-
required: true
17-
lambdaPerfEnv:
18-
description: 'environment on which you want to deploy'
19-
type: choice
20-
options:
21-
- staging
22-
- production
14+
- DEV
15+
- PROD
2316
required: true
2417

2518
jobs:
@@ -62,12 +55,12 @@ jobs:
6255
with:
6356
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
6457
role-session-name: GitHub_Action_LambdaPerf_Session
65-
aws-region: ${{ inputs.region }}
58+
aws-region: ${{ inputs.environment == 'DEV' && secrets.AWS_DEV_REGION || inputs.environment == 'PROD' && secrets.AWS_PROD_REGION }}
6659
- name: deploy
6760
env:
68-
AWS_REGION: ${{ inputs.region }}
69-
LAMBDA_PERF_ENV: ${{ inputs.lambdaPerfEnv }}
70-
SKIP_SNAPSTART: ${{ (inputs.region == 'eu-west-1') && secrets.SKIP_SNAPSTART_DEV || 'false' }}
71-
GITHUB_AUTH_TOKEN: ${{ secrets.GH_AUTH_TOKEN }}
61+
AWS_REGION: ${{ inputs.environment == 'DEV' && secrets.AWS_DEV_REGION || inputs.environment == 'PROD' && secrets.AWS_PROD_REGION }}
62+
LAMBDA_PERF_ENV: ${{ inputs.environment == 'PROD' && 'production' || 'dev' }}
63+
SKIP_SNAPSTART: ${{ (inputs.environment == 'DEV') && secrets.SKIP_SNAPSTART_DEV || 'false' }}
64+
GITHUB_AUTH_TOKEN: ${{ inputs.environment == 'PROD' && secrets.GH_AUTH_TOKEN || 'no-token-needed' }}
7265
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
7366
run: cd cdk && yarn install && cdk bootstrap && cdk deploy LambdaPerfStack --require-approval never

.github/workflows/aws-publish-artifact-to-ecr.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ permissions:
77
on:
88
workflow_dispatch:
99
inputs:
10-
region:
11-
description: 'region on which you want to deploy'
10+
environment:
11+
description: 'Environment to deploy'
1212
type: choice
1313
options:
14-
- eu-west-1
15-
- us-east-1
14+
- DEV
15+
- PROD
1616
required: true
1717
architecture:
18-
description: 'architecture'
18+
description: 'Architecture'
1919
type: choice
2020
options:
2121
- x86_64
@@ -26,9 +26,10 @@ jobs:
2626
trigger-push-to-ecr:
2727
uses: ./.github/workflows/push-to-ecr.yml
2828
with:
29-
region: ${{ inputs.region }}
3029
architecture: ${{ inputs.architecture }}
30+
environment: ${{ inputs.environment }}
3131
secrets:
3232
role: ${{ secrets.AWS_ROLE_TO_ASSUME }}
3333
account_id: ${{ secrets.AWS_ACCOUNT_ID }}
34-
34+
devRegion: ${{ secrets.AWS_DEV_REGION }}
35+
prodRegion: ${{ secrets.AWS_PROD_REGION }}

.github/workflows/aws-publish-artifact-to-s3.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ permissions:
77
on:
88
workflow_dispatch:
99
inputs:
10-
region:
11-
description: 'region on which you want to deploy'
10+
environment:
11+
description: 'Environment to deploy'
1212
type: choice
1313
options:
14-
- eu-west-1
15-
- us-east-1
14+
- DEV
15+
- PROD
1616
required: true
1717
architecture:
18-
description: 'architecture'
18+
description: 'Architecture'
1919
type: choice
2020
options:
2121
- x86_64
@@ -26,8 +26,9 @@ jobs:
2626
trigger-push-to-s3:
2727
uses: ./.github/workflows/push-to-s3.yml
2828
with:
29-
region: ${{ inputs.region }}
3029
architecture: ${{ inputs.architecture }}
30+
environment: ${{ inputs.environment }}
3131
secrets:
3232
role: ${{ secrets.AWS_ROLE_TO_ASSUME }}
33-
33+
devRegion: ${{ secrets.AWS_DEV_REGION }}
34+
prodRegion: ${{ secrets.AWS_PROD_REGION }}

.github/workflows/push-to-ecr.yml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,27 @@ permissions:
77
on:
88
workflow_call:
99
inputs:
10-
region:
11-
description: 'region on which you want to deploy'
12-
type: string
13-
required: true
1410
architecture:
1511
description: 'architecture'
1612
type: string
1713
required: true
14+
environment:
15+
description: 'environment'
16+
type: string
17+
required: true
1818
secrets:
1919
role:
2020
description: 'AWS role to assume'
2121
required: true
2222
account_id:
2323
description: 'AWS account id'
2424
required: true
25+
devRegion:
26+
description: 'AWS region for DEV'
27+
required: false
28+
prodRegion:
29+
description: 'AWS region for PROD'
30+
required: false
2531

2632
jobs:
2733
setup:
@@ -60,7 +66,7 @@ jobs:
6066
with:
6167
role-to-assume: ${{ secrets.role }}
6268
role-session-name: GitHub_Action_LambdaPerf_Session
63-
aws-region: ${{ inputs.region }}
69+
aws-region: ${{ inputs.environment == 'DEV' && secrets.devRegion || inputs.environment == 'PROD' && secrets.prodRegion }}
6470
- name: Delete huge unnecessary folders
6571
run: |
6672
rm -rf /opt/hostedtoolcache
@@ -75,7 +81,7 @@ jobs:
7581
- name: build and deploy
7682
env:
7783
ARCHITECTURE: ${{ inputs.architecture }}
78-
AWS_REGION: ${{ inputs.region }}
84+
AWS_REGION: ${{ inputs.environment == 'DEV' && secrets.devRegion || inputs.environment == 'PROD' && secrets.prodRegion }}
7985
RUNTIME_ID: ${{ matrix.runtime_id }}
8086
AWS_ACCOUNT_ID: ${{ secrets.account_id }}
8187
run: |
@@ -92,10 +98,10 @@ jobs:
9298
with:
9399
role-to-assume: ${{ secrets.role }}
94100
role-session-name: GitHub_Action_LambdaPerf_Session
95-
aws-region: ${{ inputs.region }}
101+
aws-region: ${{ inputs.environment == 'DEV' && secrets.devRegion || inputs.environment == 'PROD' && secrets.prodRegion }}
96102
- name: clean untagged images
97103
env:
98-
AWS_REGION: ${{ inputs.region }}
104+
AWS_REGION: ${{ inputs.environment == 'DEV' && secrets.devRegion || inputs.environment == 'PROD' && secrets.prodRegion }}
99105
run: |
100106
UNTAGGED_IMAGES=$(aws ecr list-images --region "${AWS_REGION}" --repository-name lambda-perf --filter "tagStatus=UNTAGGED" --query 'imageIds[*]' --output json)
101107
if [[ "$UNTAGGED_IMAGES" == "[]" ]]; then

.github/workflows/push-to-s3.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,24 @@ permissions:
77
on:
88
workflow_call:
99
inputs:
10-
region:
11-
description: 'region on which you want to deploy'
12-
type: string
13-
required: true
1410
architecture:
1511
description: 'architecture'
1612
type: string
1713
required: true
14+
environment:
15+
description: 'environment'
16+
type: string
17+
required: true
1818
secrets:
1919
role:
2020
description: 'AWS role to assume'
2121
required: true
22+
devRegion:
23+
description: 'AWS region for DEV'
24+
required: false
25+
prodRegion:
26+
description: 'AWS region for PROD'
27+
required: false
2228

2329
jobs:
2430
setup:
@@ -56,7 +62,7 @@ jobs:
5662
with:
5763
role-to-assume: ${{ secrets.role }}
5864
role-session-name: GitHub_Action_LambdaPerf_Session
59-
aws-region: ${{ inputs.region }}
65+
aws-region: ${{ inputs.environment == 'DEV' && secrets.devRegion || inputs.environment == 'PROD' && secrets.prodRegion }}
6066
- uses: actions/checkout@v4
6167
- name: Set up Docker
6268
uses: docker/setup-docker-action@v4
@@ -66,7 +72,7 @@ jobs:
6672
- name: build and deploy
6773
env:
6874
ARCHITECTURE: ${{ inputs.architecture }}
69-
AWS_REGION: ${{ inputs.region }}
75+
AWS_REGION: ${{ inputs.environment == 'DEV' && secrets.devRegion || inputs.environment == 'PROD' && secrets.prodRegion }}
7076
RUNTIME_ID: ${{ matrix.runtime_id }}
7177
run: |
7278
cd s3-uploader

.github/workflows/test.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ jobs:
4141
architecture: [x86_64, arm64]
4242
uses: ./.github/workflows/push-to-s3.yml
4343
with:
44-
region: 'us-east-1'
44+
environment: DEV
4545
architecture: ${{ matrix.architecture }}
4646
secrets:
4747
role: ${{ secrets.AWS_ROLE_TO_ASSUME }}
48+
devRegion: ${{ secrets.AWS_DEV_REGION }}

0 commit comments

Comments
 (0)