Skip to content

Commit 57e269e

Browse files
authored
Use amazonlinux:2023 + Use arm64 machines for lambdas (#377)
1 parent 92b6bb1 commit 57e269e

File tree

3 files changed

+65
-54
lines changed

3 files changed

+65
-54
lines changed

.github/workflows/deploy-all-lambdas.yml

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,42 +7,34 @@ on:
77

88
jobs:
99
deploy-lambdas:
10-
runs-on: ubuntu-latest
11-
container: swift:6.2-amazonlinux2
10+
runs-on: ubuntu-24.04-arm
11+
container: amazonlinux:2023
1212

1313
env:
14+
AWS_BUCKET_NAME: penny-lambdas-store
1415
AWS_DEFAULT_REGION: eu-west-1
1516
AWS_ACCESS_KEY_ID: ${{ secrets.DEPLOYER_ACCESS_KEY_ID }}
1617
AWS_SECRET_ACCESS_KEY: ${{ secrets.DEPLOYER_ACCESS_SECRET_KEY }}
1718

1819
steps:
19-
- name: Install additional dependencies and AWSCLI v2
20+
- name: Install AWSCLI v2, Swift, git, jq, zip, tar, zstd, zlib-devel
2021
run: |
21-
yum -y install \
22-
{libuuid,libicu,libedit,sqlite,python,ncurses,openssl}-devel \
23-
libtool jq zip
24-
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
25-
unzip awscliv2.zip
26-
./aws/install
22+
dnf install git jq zip tar awscli zstd zlib-devel swiftlang -y
23+
swift --version
2724
2825
- name: Check out repository
29-
# uses: actions/checkout@v3 ❌ Needs node 20 which amazonlinux2 doesn't have
30-
run: |
31-
git clone https://github.com/${{ github.repository }}
32-
cd ${{ github.event.repository.name }}
33-
git checkout ${{ github.sha }}
26+
uses: actions/checkout@v6
3427

3528
- name: Restore .build
36-
if: false # ❌ Needs node 20 which amazonlinux2 doesn't have
29+
if: ${{ runner.debug != '1' }}
3730
id: "restore-cache"
3831
uses: actions/cache/restore@v5
3932
with:
40-
path: ${{ github.event.repository.name }}/.build
33+
path: .build
4134
key: "lambdas-build-${{ runner.os }}-${{ github.event.after }}"
4235
restore-keys: "lambdas-build-${{ runner.os }}-"
4336

4437
- name: Find package names
45-
working-directory: ${{ github.event.repository.name }}
4638
id: find_package_names
4739
run: |
4840
echo "names=$(
@@ -56,30 +48,35 @@ jobs:
5648
tr '\n' ' '
5749
)" >> $GITHUB_OUTPUT
5850
59-
- name: Build, package and deploy
60-
working-directory: ${{ github.event.repository.name }}
51+
- name: Build lambdas
6152
run: |
62-
mkdir zips
53+
mkdir ./zips
6354
for name in ${{ steps.find_package_names.outputs.names }}; do
6455
swift package \
6556
--allow-network-connections docker \
6657
archive \
6758
--verbose \
6859
--output-path ./zips \
6960
--products "${name}"
70-
aws s3api put-object \
71-
--bucket penny-lambdas-store \
72-
--key "${name}.zip" \
73-
--body ./zips/${name}/${name}.zip
74-
aws lambda update-function-code \
75-
--function-name "${name}" \
76-
--s3-bucket "penny-lambdas-store" \
77-
--s3-key "${name}.zip"
7861
done
7962
8063
- name: Cache .build
81-
if: false # ❌ Needs node 20 which amazonlinux2 doesn't have
64+
if: steps.restore-cache.outputs.cache-hit != 'true'
8265
uses: actions/cache/save@v5
8366
with:
84-
path: ${{ github.event.repository.name }}/.build
67+
path: .build
8568
key: "lambdas-build-${{ runner.os }}-${{ github.event.after }}"
69+
70+
- name: Package and deploy lambdas
71+
run: |
72+
for name in ${{ steps.find_package_names.outputs.names }}; do
73+
aws s3api put-object \
74+
--bucket "${AWS_BUCKET_NAME}" \
75+
--key "${name}".zip \
76+
--body ./zips/"${name}"/"${name}".zip
77+
78+
aws lambda update-function-code \
79+
--function-name "${name}" \
80+
--s3-bucket "${AWS_BUCKET_NAME}" \
81+
--s3-key "${name}.zip"
82+
done

Package.resolved

Lines changed: 17 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deploy/penny-discord-bot-stack.yml

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ Resources:
128128
usersFunction:
129129
Type: AWS::Lambda::Function
130130
Properties:
131+
Architectures:
132+
- arm64
131133
Code:
132134
S3Bucket: penny-lambdas-store
133135
S3Key: !Sub ${UsersFilename}.zip
@@ -139,7 +141,7 @@ Resources:
139141
MemorySize: 256
140142
Handler: handler
141143
Role: !GetAtt lambdaIAMRole.Arn
142-
Runtime: provided.al2
144+
Runtime: provided.al2023
143145
Timeout: 20
144146

145147
lambdaUsersRoutePermission:
@@ -180,14 +182,16 @@ Resources:
180182
sponsorsFunction:
181183
Type: AWS::Lambda::Function
182184
Properties:
185+
Architectures:
186+
- arm64
183187
Code:
184188
S3Bucket: penny-lambdas-store
185189
S3Key: !Sub ${SponsorsFilename}.zip
186190
FunctionName: !Sub ${SponsorsFilename}
187191
MemorySize: 256
188192
Handler: handler
189193
Role: !GetAtt lambdaIAMRole.Arn
190-
Runtime: provided.al2
194+
Runtime: provided.al2023
191195
Timeout: 20
192196

193197
lambdaSponsorsPermission:
@@ -332,14 +336,16 @@ Resources:
332336
autoPingsFunction:
333337
Type: AWS::Lambda::Function
334338
Properties:
339+
Architectures:
340+
- arm64
335341
Code:
336342
S3Bucket: penny-lambdas-store
337343
S3Key: !Sub ${AutoPingsFilename}.zip
338344
FunctionName: !Sub ${AutoPingsFilename}
339345
MemorySize: 256
340346
Handler: handler
341347
Role: !GetAtt lambdaIAMRole.Arn
342-
Runtime: provided.al2
348+
Runtime: provided.al2023
343349
Timeout: 20
344350

345351
lambdaAutoPingsRoutePermission:
@@ -387,14 +393,16 @@ Resources:
387393
faqsFunction:
388394
Type: AWS::Lambda::Function
389395
Properties:
396+
Architectures:
397+
- arm64
390398
Code:
391399
S3Bucket: penny-lambdas-store
392400
S3Key: !Sub ${FaqsFilename}.zip
393401
FunctionName: !Sub ${FaqsFilename}
394402
MemorySize: 256
395403
Handler: handler
396404
Role: !GetAtt lambdaIAMRole.Arn
397-
Runtime: provided.al2
405+
Runtime: provided.al2023
398406
Timeout: 20
399407

400408
lambdaFaqsRoutePermission:
@@ -442,14 +450,16 @@ Resources:
442450
autoFaqsFunction:
443451
Type: AWS::Lambda::Function
444452
Properties:
453+
Architectures:
454+
- arm64
445455
Code:
446456
S3Bucket: penny-lambdas-store
447457
S3Key: !Sub ${AutoFaqsFilename}.zip
448458
FunctionName: !Sub ${AutoFaqsFilename}
449459
MemorySize: 256
450460
Handler: handler
451461
Role: !GetAtt lambdaIAMRole.Arn
452-
Runtime: provided.al2
462+
Runtime: provided.al2023
453463
Timeout: 20
454464

455465
lambdaAutoFaqsRoutePermission:
@@ -497,6 +507,8 @@ Resources:
497507
ghHooksFunction:
498508
Type: AWS::Lambda::Function
499509
Properties:
510+
Architectures:
511+
- arm64
500512
Code:
501513
S3Bucket: penny-lambdas-store
502514
S3Key: !Sub ${GHHooksFilename}.zip
@@ -511,7 +523,7 @@ Resources:
511523
MemorySize: 512
512524
Handler: handler
513525
Role: !GetAtt lambdaIAMRole.Arn
514-
Runtime: provided.al2
526+
Runtime: provided.al2023
515527
Timeout: 30
516528

517529
lambdaGHHooksRoutePermission:
@@ -552,6 +564,8 @@ Resources:
552564
ghOAuthFunction:
553565
Type: AWS::Lambda::Function
554566
Properties:
567+
Architectures:
568+
- arm64
555569
Code:
556570
S3Bucket: penny-lambdas-store
557571
S3Key: !Sub ${GHOAuthFilename}.zip
@@ -567,7 +581,7 @@ Resources:
567581
MemorySize: 256
568582
Handler: handler
569583
Role: !GetAtt lambdaIAMRole.Arn
570-
Runtime: provided.al2
584+
Runtime: provided.al2023
571585
Timeout: 20
572586

573587
lambdaGHOAuthRoutePermission:

0 commit comments

Comments
 (0)