Skip to content

Commit

Permalink
feat(sdk): use arm64 for awscdk and tf-aws functions (#3963)
Browse files Browse the repository at this point in the history
This change should give better price/performance for most workloads, and not have any effect on runtime behavior since all cloud functions are using the AWS-provided NodeJS runtimes.

## Checklist

- [x] Title matches [Winglang's style guide](https://www.winglang.io/contributing/start-here/pull_requests#how-are-pull-request-titles-formatted)
- [x] Description explains motivation and solution
- [x] Tests added (always)
- [ ] Docs updated (only required for features)
- [ ] Added `pr/e2e-full` label if this feature requires end-to-end testing

*By submitting this pull request, I confirm that my contribution is made under the terms of the [Wing Cloud Contribution License](https://github.com/winglang/wing/blob/main/CONTRIBUTION_LICENSE.md)*.
  • Loading branch information
Chriscbr authored Aug 25, 2023
1 parent 8efecc2 commit dd9055c
Show file tree
Hide file tree
Showing 174 changed files with 1,059 additions and 6 deletions.
2 changes: 2 additions & 0 deletions libs/wingsdk/src/target-awscdk/function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { resolve } from "path";
import { Duration } from "aws-cdk-lib";
import { PolicyStatement as CdkPolicyStatement } from "aws-cdk-lib/aws-iam";
import {
Architecture,
Function as CdkFunction,
Code,
IEventSource,
Expand Down Expand Up @@ -44,6 +45,7 @@ export class Function extends cloud.Function implements IAwsFunction {
? Duration.seconds(props.timeout.seconds)
: Duration.minutes(0.5),
memorySize: props.memory ? props.memory : undefined,
architecture: Architecture.ARM_64,
});

this.arn = this.function.functionArn;
Expand Down
1 change: 1 addition & 0 deletions libs/wingsdk/src/target-tf-aws/function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ export class Function extends cloud.Function implements IAwsFunction {
? props.timeout.seconds
: Duration.fromMinutes(0.5).seconds,
memorySize: props.memory ? props.memory : undefined,
architectures: ["arm64"],
});

this.arn = this.function.arn;
Expand Down
12 changes: 12 additions & 0 deletions libs/wingsdk/test/target-awscdk/__snapshots__/bucket.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,9 @@ def submit_response(event: dict, context, response_status: str, error_message: s
"mybucketOnCreatec185c7e3ServiceRoleE5FE1BDD",
],
"Properties": {
"Architectures": [
"arm64",
],
"Code": {
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-\${AWS::AccountId}-\${AWS::Region}",
Expand Down Expand Up @@ -718,6 +721,9 @@ def submit_response(event: dict, context, response_status: str, error_message: s
"mybucketOnDeletec185c7e3ServiceRole113BE170",
],
"Properties": {
"Architectures": [
"arm64",
],
"Code": {
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-\${AWS::AccountId}-\${AWS::Region}",
Expand Down Expand Up @@ -1091,6 +1097,9 @@ def submit_response(event: dict, context, response_status: str, error_message: s
"mybucketOnEventc185c7e3ServiceRole3C4A0154",
],
"Properties": {
"Architectures": [
"arm64",
],
"Code": {
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-\${AWS::AccountId}-\${AWS::Region}",
Expand Down Expand Up @@ -1442,6 +1451,9 @@ def submit_response(event: dict, context, response_status: str, error_message: s
"mybucketOnUpdatec185c7e3ServiceRoleA530B9CD",
],
"Properties": {
"Architectures": [
"arm64",
],
"Code": {
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-\${AWS::AccountId}-\${AWS::Region}",
Expand Down
15 changes: 15 additions & 0 deletions libs/wingsdk/test/target-awscdk/__snapshots__/counter.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ exports[`dec() policy statement 2`] = `
"FunctionServiceRole675BB04A",
],
"Properties": {
"Architectures": [
"arm64",
],
"Code": {
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-\${AWS::AccountId}-\${AWS::Region}",
Expand Down Expand Up @@ -363,6 +366,9 @@ exports[`function with a counter binding 2`] = `
"FunctionServiceRole675BB04A",
],
"Properties": {
"Architectures": [
"arm64",
],
"Code": {
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-\${AWS::AccountId}-\${AWS::Region}",
Expand Down Expand Up @@ -535,6 +541,9 @@ exports[`inc() policy statement 2`] = `
"FunctionServiceRole675BB04A",
],
"Properties": {
"Architectures": [
"arm64",
],
"Code": {
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-\${AWS::AccountId}-\${AWS::Region}",
Expand Down Expand Up @@ -707,6 +716,9 @@ exports[`peek() policy statement 2`] = `
"FunctionServiceRole675BB04A",
],
"Properties": {
"Architectures": [
"arm64",
],
"Code": {
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-\${AWS::AccountId}-\${AWS::Region}",
Expand Down Expand Up @@ -879,6 +891,9 @@ exports[`set() policy statement 2`] = `
"FunctionServiceRole675BB04A",
],
"Properties": {
"Architectures": [
"arm64",
],
"Code": {
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-\${AWS::AccountId}-\${AWS::Region}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ exports[`basic function 1`] = `
"FunctionServiceRole675BB04A",
],
"Properties": {
"Architectures": [
"arm64",
],
"Code": {
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-\${AWS::AccountId}-\${AWS::Region}",
Expand Down Expand Up @@ -120,6 +123,9 @@ exports[`basic function with environment variables 1`] = `
"FunctionServiceRole675BB04A",
],
"Properties": {
"Architectures": [
"arm64",
],
"Code": {
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-\${AWS::AccountId}-\${AWS::Region}",
Expand Down Expand Up @@ -226,6 +232,9 @@ exports[`basic function with memory size specified 1`] = `
"FunctionServiceRole675BB04A",
],
"Properties": {
"Architectures": [
"arm64",
],
"Code": {
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-\${AWS::AccountId}-\${AWS::Region}",
Expand Down Expand Up @@ -327,6 +336,9 @@ exports[`basic function with timeout explicitly set 1`] = `
"FunctionServiceRole675BB04A",
],
"Properties": {
"Architectures": [
"arm64",
],
"Code": {
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-\${AWS::AccountId}-\${AWS::Region}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ exports[`create an OnDeploy 1`] = `
"myondeployFunctionServiceRole7277F8BB",
],
"Properties": {
"Architectures": [
"arm64",
],
"Code": {
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-\${AWS::AccountId}-\${AWS::Region}",
Expand All @@ -116,7 +119,7 @@ exports[`create an OnDeploy 1`] = `
},
"Type": "AWS::Lambda::Function",
},
"myondeployFunctionCurrentVersion6BC23754dc8a690e8db1c57e1302de9438f9dfa2": {
"myondeployFunctionCurrentVersion6BC23754495ffbfe7093f6d76e062790f78856b0": {
"Properties": {
"FunctionName": {
"Ref": "myondeployFunction47551748",
Expand Down Expand Up @@ -159,7 +162,7 @@ exports[`create an OnDeploy 1`] = `
"DeletionPolicy": "Delete",
"Properties": {
"HandlerArn": {
"Ref": "myondeployFunctionCurrentVersion6BC23754dc8a690e8db1c57e1302de9438f9dfa2",
"Ref": "myondeployFunctionCurrentVersion6BC23754495ffbfe7093f6d76e062790f78856b0",
},
"ServiceToken": {
"Fn::GetAtt": [
Expand Down Expand Up @@ -322,6 +325,9 @@ exports[`execute OnDeploy after other resources 1`] = `
"myondeployFunctionServiceRole7277F8BB",
],
"Properties": {
"Architectures": [
"arm64",
],
"Code": {
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-\${AWS::AccountId}-\${AWS::Region}",
Expand All @@ -340,7 +346,7 @@ exports[`execute OnDeploy after other resources 1`] = `
},
"Type": "AWS::Lambda::Function",
},
"myondeployFunctionCurrentVersion6BC23754dc8a690e8db1c57e1302de9438f9dfa2": {
"myondeployFunctionCurrentVersion6BC23754495ffbfe7093f6d76e062790f78856b0": {
"Properties": {
"FunctionName": {
"Ref": "myondeployFunction47551748",
Expand Down Expand Up @@ -386,7 +392,7 @@ exports[`execute OnDeploy after other resources 1`] = `
],
"Properties": {
"HandlerArn": {
"Ref": "myondeployFunctionCurrentVersion6BC23754dc8a690e8db1c57e1302de9438f9dfa2",
"Ref": "myondeployFunctionCurrentVersion6BC23754495ffbfe7093f6d76e062790f78856b0",
},
"ServiceToken": {
"Fn::GetAtt": [
Expand Down Expand Up @@ -552,6 +558,9 @@ exports[`execute OnDeploy before other resources 1`] = `
"myondeployFunctionServiceRole7277F8BB",
],
"Properties": {
"Architectures": [
"arm64",
],
"Code": {
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-\${AWS::AccountId}-\${AWS::Region}",
Expand All @@ -570,7 +579,7 @@ exports[`execute OnDeploy before other resources 1`] = `
},
"Type": "AWS::Lambda::Function",
},
"myondeployFunctionCurrentVersion6BC23754dc8a690e8db1c57e1302de9438f9dfa2": {
"myondeployFunctionCurrentVersion6BC23754495ffbfe7093f6d76e062790f78856b0": {
"Properties": {
"FunctionName": {
"Ref": "myondeployFunction47551748",
Expand Down Expand Up @@ -613,7 +622,7 @@ exports[`execute OnDeploy before other resources 1`] = `
"DeletionPolicy": "Delete",
"Properties": {
"HandlerArn": {
"Ref": "myondeployFunctionCurrentVersion6BC23754dc8a690e8db1c57e1302de9438f9dfa2",
"Ref": "myondeployFunctionCurrentVersion6BC23754495ffbfe7093f6d76e062790f78856b0",
},
"ServiceToken": {
"Fn::GetAtt": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ exports[`queue with a consumer function 2`] = `
"QueueSetConsumerc185c7e3ServiceRole98E9022D",
],
"Properties": {
"Architectures": [
"arm64",
],
"Code": {
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-\${AWS::AccountId}-\${AWS::Region}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ exports[`schedule behavior with cron 1`] = `
"ScheduleSetConsumerc185c7e3ServiceRoleAA894847",
],
"Properties": {
"Architectures": [
"arm64",
],
"Code": {
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-\${AWS::AccountId}-\${AWS::Region}",
Expand Down Expand Up @@ -194,6 +197,9 @@ exports[`schedule behavior with rate 1`] = `
"ScheduleSetConsumerc185c7e3ServiceRoleAA894847",
],
"Properties": {
"Architectures": [
"arm64",
],
"Code": {
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-\${AWS::AccountId}-\${AWS::Region}",
Expand Down Expand Up @@ -359,6 +365,9 @@ exports[`schedule with two functions 1`] = `
"ScheduleSetConsumer6e1b4252ServiceRole88F787AF",
],
"Properties": {
"Architectures": [
"arm64",
],
"Code": {
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-\${AWS::AccountId}-\${AWS::Region}",
Expand Down Expand Up @@ -413,6 +422,9 @@ exports[`schedule with two functions 1`] = `
"ScheduleSetConsumerc185c7e3ServiceRoleAA894847",
],
"Properties": {
"Architectures": [
"arm64",
],
"Code": {
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-\${AWS::AccountId}-\${AWS::Region}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ exports[`topic with multiple subscribers 3`] = `
"TopicOnMessage6e1b4252ServiceRoleEC336C6C",
],
"Properties": {
"Architectures": [
"arm64",
],
"Code": {
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-\${AWS::AccountId}-\${AWS::Region}",
Expand Down Expand Up @@ -187,6 +190,9 @@ exports[`topic with multiple subscribers 3`] = `
"TopicOnMessagee967ab9dServiceRole111B1D6D",
],
"Properties": {
"Architectures": [
"arm64",
],
"Code": {
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-\${AWS::AccountId}-\${AWS::Region}",
Expand Down Expand Up @@ -336,6 +342,9 @@ exports[`topic with subscriber function 2`] = `
"TopicOnMessagec185c7e3ServiceRole9266A390",
],
"Properties": {
"Architectures": [
"arm64",
],
"Code": {
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-\${AWS::AccountId}-\${AWS::Region}",
Expand Down
18 changes: 18 additions & 0 deletions libs/wingsdk/test/target-tf-aws/__snapshots__/bucket.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,9 @@ exports[`bucket with onCreate method 1`] = `
},
"aws_lambda_function": {
"my_bucket_my_bucket-oncreate-OnMessage-7b961f4d_8104FB90": {
"architectures": [
"arm64",
],
"environment": {
"variables": {
"WING_FUNCTION_NAME": "my_bucket-oncreate-OnMessage-7b961f4d-c81311dd",
Expand Down Expand Up @@ -885,6 +888,9 @@ exports[`bucket with onDelete method 1`] = `
},
"aws_lambda_function": {
"my_bucket_my_bucket-ondelete-OnMessage-1de1a361_37C9E1F7": {
"architectures": [
"arm64",
],
"environment": {
"variables": {
"WING_FUNCTION_NAME": "my_bucket-ondelete-OnMessage-1de1a361-c89e08bf",
Expand Down Expand Up @@ -1326,6 +1332,9 @@ exports[`bucket with onEvent method 1`] = `
},
"aws_lambda_function": {
"my_bucket_my_bucket-oncreate-OnMessage-7b961f4d_8104FB90": {
"architectures": [
"arm64",
],
"environment": {
"variables": {
"WING_FUNCTION_NAME": "my_bucket-oncreate-OnMessage-7b961f4d-c81311dd",
Expand All @@ -1345,6 +1354,9 @@ exports[`bucket with onEvent method 1`] = `
},
},
"my_bucket_my_bucket-ondelete-OnMessage-1de1a361_37C9E1F7": {
"architectures": [
"arm64",
],
"environment": {
"variables": {
"WING_FUNCTION_NAME": "my_bucket-ondelete-OnMessage-1de1a361-c89e08bf",
Expand All @@ -1364,6 +1376,9 @@ exports[`bucket with onEvent method 1`] = `
},
},
"my_bucket_my_bucket-onupdate-OnMessage-46c07356_F3040BF9": {
"architectures": [
"arm64",
],
"environment": {
"variables": {
"WING_FUNCTION_NAME": "my_bucket-onupdate-OnMessage-46c07356-c844b8ba",
Expand Down Expand Up @@ -2105,6 +2120,9 @@ exports[`bucket with onUpdate method 1`] = `
},
"aws_lambda_function": {
"my_bucket_my_bucket-onupdate-OnMessage-46c07356_F3040BF9": {
"architectures": [
"arm64",
],
"environment": {
"variables": {
"WING_FUNCTION_NAME": "my_bucket-onupdate-OnMessage-46c07356-c844b8ba",
Expand Down
Loading

0 comments on commit dd9055c

Please sign in to comment.