@@ -15,6 +15,7 @@ import (
1515 "github.com/aws/aws-sdk-go-v2/config"
1616 "github.com/aws/aws-sdk-go-v2/service/lambda"
1717 "github.com/aws/aws-sdk-go-v2/service/lambda/types"
18+ "golang.org/x/exp/slices"
1819 "golang.org/x/sync/errgroup"
1920)
2021
@@ -44,27 +45,40 @@ var canonicalLayers = []LayerInfo{
4445// regions are the regions that we want to keep in sync
4546var regions = []string {
4647 "af-south-1" ,
47- "eu-central-1" ,
48- "us-east-1" ,
49- "us-east-2" ,
50- "us-west-1" ,
51- "us-west-2" ,
5248 "ap-east-1" ,
53- "ap-south-1" ,
5449 "ap-northeast-1" ,
5550 "ap-northeast-2" ,
51+ "ap-northeast-3" ,
52+ "ap-south-1" ,
53+ "ap-south-2" ,
5654 "ap-southeast-1" ,
5755 "ap-southeast-2" ,
56+ "ap-southeast-3" ,
57+ "ap-southeast-4" ,
5858 "ca-central-1" ,
59+ "eu-central-1" ,
60+ "eu-central-2" ,
61+ "eu-north-1" ,
62+ "eu-south-1" ,
63+ "eu-south-2" ,
5964 "eu-west-1" ,
6065 "eu-west-2" ,
6166 "eu-west-3" ,
62- "eu-south-1" ,
63- "eu-north-1" ,
64- "sa-east-1" ,
65- "ap-southeast-3" ,
66- "ap-northeast-3" ,
67+ "me-central-1" ,
6768 "me-south-1" ,
69+ "sa-east-1" ,
70+ "us-east-1" ,
71+ "us-east-2" ,
72+ "us-west-1" ,
73+ "us-west-2" ,
74+ }
75+
76+ var singleArchitectureRegions = []string {
77+ "ap-south-2" ,
78+ "ap-southeast-4" ,
79+ "eu-central-2" ,
80+ "eu-south-2" ,
81+ "me-central-1" ,
6882}
6983
7084// getLayerVersion returns the latest version of a layer in a region
@@ -100,6 +114,11 @@ func getGreatestVersion(ctx context.Context) (int64, error) {
100114 layer := & canonicalLayers [idx ]
101115
102116 for _ , region := range regions {
117+ // Ignore regions that are excluded
118+ if layer .Architecture == types .ArchitectureArm64 && slices .Contains (singleArchitectureRegions , region ) {
119+ continue
120+ }
121+
103122 layerName := layer .Name
104123 ctx := ctx
105124 region := region
@@ -149,16 +168,30 @@ func balanceRegionToVersion(ctx context.Context, region string, layer *LayerInfo
149168 return fmt .Errorf ("error downloading canonical zip: %w" , err )
150169 }
151170
152- layerVersionResponse , err := lambdaSvc .PublishLayerVersion (ctx , & lambda.PublishLayerVersionInput {
153- Content : & types.LayerVersionContentInput {
154- ZipFile : payload ,
155- },
156- LayerName : aws .String (layer .Name ),
157- CompatibleArchitectures : []types.Architecture {layer .Architecture },
158- CompatibleRuntimes : []types.Runtime {types .RuntimePython37 , types .RuntimePython38 , types .RuntimePython39 },
159- Description : aws .String (layer .Description ),
160- LicenseInfo : aws .String ("MIT-0" ),
161- })
171+ var layerVersionResponse * lambda.PublishLayerVersionOutput
172+
173+ if slices .Contains (singleArchitectureRegions , region ) {
174+ layerVersionResponse , err = lambdaSvc .PublishLayerVersion (ctx , & lambda.PublishLayerVersionInput {
175+ Content : & types.LayerVersionContentInput {
176+ ZipFile : payload ,
177+ },
178+ LayerName : aws .String (layer .Name ),
179+ CompatibleRuntimes : []types.Runtime {types .RuntimePython37 , types .RuntimePython38 , types .RuntimePython39 },
180+ Description : aws .String (layer .Description ),
181+ LicenseInfo : aws .String ("MIT-0" ),
182+ })
183+ } else {
184+ layerVersionResponse , err = lambdaSvc .PublishLayerVersion (ctx , & lambda.PublishLayerVersionInput {
185+ Content : & types.LayerVersionContentInput {
186+ ZipFile : payload ,
187+ },
188+ LayerName : aws .String (layer .Name ),
189+ CompatibleArchitectures : []types.Architecture {layer .Architecture },
190+ CompatibleRuntimes : []types.Runtime {types .RuntimePython37 , types .RuntimePython38 , types .RuntimePython39 },
191+ Description : aws .String (layer .Description ),
192+ LicenseInfo : aws .String ("MIT-0" ),
193+ })
194+ }
162195 if err != nil {
163196 return fmt .Errorf ("error publishing layer version: %w" , err )
164197 }
@@ -186,6 +219,11 @@ func balanceRegions(ctx context.Context, maxVersion int64) error {
186219 layer := & canonicalLayers [idx ]
187220
188221 for _ , region := range regions {
222+ // Ignore regions that are excluded
223+ if layer .Architecture == types .ArchitectureArm64 && slices .Contains (singleArchitectureRegions , region ) {
224+ continue
225+ }
226+
189227 ctx := ctx
190228 region := region
191229 layer := layer
0 commit comments