Skip to content

Commit 8b8f73a

Browse files
committed
Fix Shared ADF Lambda Layer builds and add move to ARM-64 Lambdas
**Why?** The Lambda Layer that ADF builds included the `bootstrap/adf-build/shared` folder as its source. Unfortunately, this resulted in 388 MB of unzipped dependencies. While the maximum limit for AWS Lambda Layers is set at 250 MB. **What?** After going through each of the lambda functions that use this Lambda Layer, I realized that they only require the files located in `bootstrap/adf-build/shared/python`. Since this implied no longer requiring AWS CDK in the Lambda Layer, I also used this opportunity to move to the ARM-64 Lambdas in ADF. The new Lambda Layer is 26 MB. To build ARM-64 on CodeBuild, I've added the Amazon managed container that enables cross-architecture builds on Docker. That will launch and configure Qemu correctly, so ARM-64 Docker images can execute correctly. I've also fixed the build metadata and updated the `sam build` process to use a container instead. As without it, it could not resolve the dependencies required for PyYaml and others specifically for ARM-64. Lastly, I've updated the shared lambda layer permissions, so we have control in the stack who can access and build on top of it.
1 parent f1fec85 commit 8b8f73a

39 files changed

Lines changed: 258 additions & 144 deletions

linters/custom-adf-dict.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ adf
44
adfconfig
55
awscli
66
backoff
7+
binfmt
78
bitnami
89
boto
910
boto3

src/lambda_codebase/account_bootstrap.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,22 @@
99
"""
1010

1111
import os
12-
import boto3
1312

13+
import boto3
1414
from botocore.exceptions import ClientError
15-
from logger import configure_logger
15+
16+
# ADF imports
1617
from errors import (
1718
AccountCreationNotFinishedError,
1819
GenericAccountConfigureError,
1920
ParameterNotFoundError,
2021
)
21-
from parameter_store import ParameterStore
2222
from cloudformation import CloudFormation
23+
from logger import configure_logger
24+
from parameter_store import ParameterStore
25+
from partition import get_partition
2326
from s3 import S3
2427
from sts import STS
25-
from partition import get_partition
2628

2729
# Globals taken from the lambda environment variables
2830
S3_BUCKET = os.environ["S3_BUCKET_NAME"]

src/lambda_codebase/account_processing/configure_account_alias.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66
"""
77

88
import os
9-
from sts import STS
9+
1010
from aws_xray_sdk.core import patch_all
11+
12+
# ADF imports
1113
from logger import configure_logger
14+
from sts import STS
1215

1316
patch_all()
1417

src/lambda_codebase/account_processing/configure_account_ou.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
"""
55
Moves an account to the specified OU.
66
"""
7-
from organizations import Organizations
87
import boto3
98
from aws_xray_sdk.core import patch_all
9+
10+
# ADF imports
1011
from logger import configure_logger
12+
from organizations import Organizations
1113

1214

1315
patch_all()

src/lambda_codebase/account_processing/configure_account_regions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
"""
77
from ast import literal_eval
88

9-
109
import boto3
1110
from aws_xray_sdk.core import patch_all
11+
12+
# ADF imports
1213
from logger import configure_logger
1314

1415
patch_all()

src/lambda_codebase/account_processing/configure_account_tags.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
"""
1010
import boto3
1111
from aws_xray_sdk.core import patch_all
12+
13+
# ADF imports
1214
from logger import configure_logger
1315

1416
patch_all()

src/lambda_codebase/account_processing/create_account.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import os
99
from aws_xray_sdk.core import patch_all
1010
import boto3
11+
12+
# ADF imports
1113
from logger import configure_logger
1214

1315
patch_all()

src/lambda_codebase/account_processing/delete_default_vpc.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
Deletes the default VPC in a particular region
66
"""
77
import os
8-
from sts import STS
98
from aws_xray_sdk.core import patch_all
9+
10+
# ADF imports
1011
from logger import configure_logger
12+
from sts import STS
1113

1214
patch_all()
1315

src/lambda_codebase/account_processing/get_account_regions.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
"""
77

88
import os
9-
from sts import STS
109
from aws_xray_sdk.core import patch_all
10+
11+
# ADF imports
1112
from logger import configure_logger
13+
from sts import STS
1214

1315
patch_all()
1416

src/lambda_codebase/account_processing/process_account_files.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,17 @@
1313
import logging
1414
from typing import Any, TypedDict
1515
import re
16-
import yaml
1716

17+
import yaml
1818
from yaml.error import YAMLError
1919

2020
import boto3
2121
from botocore.exceptions import ClientError
2222
from aws_xray_sdk.core import patch_all
23-
from organizations import Organizations
23+
24+
# ADF imports
2425
from logger import configure_logger
26+
from organizations import Organizations
2527

2628

2729
patch_all()

0 commit comments

Comments
 (0)