-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sdk): aws lambda layers (#6790)
Closes #6761 ## 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
Showing
13 changed files
with
255 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
examples/tests/doc_examples/valid/function.md_example_5/main.w
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
examples/tests/doc_examples/valid/function.md_example_6/main.w
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
bring aws; | ||
bring cloud; | ||
bring expect; | ||
bring util; | ||
|
||
if util.env("WING_TARGET") == "tf-aws" { | ||
let fn = new cloud.Function(inflight () => { | ||
return "Hello world!"; | ||
}); | ||
|
||
if let lambda = aws.Function.from(fn) { | ||
// Using a public layer from https://docs.powertools.aws.dev/lambda/typescript/latest/ | ||
lambda.addLambdaLayer("arn:aws:lambda:us-east-1:094274105915:layer:AWSLambdaPowertoolsTypeScriptV2:7"); | ||
} | ||
|
||
test "the function runs" { | ||
let result = fn.invoke(); | ||
expect.equal(result, "Hello world!"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
129 changes: 129 additions & 0 deletions
129
...__snapshots__/test_corpus/sdk_tests/function/aws-layer.test.w_compile_tf-aws.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
# [aws-layer.test.w](../../../../../../examples/tests/sdk_tests/function/aws-layer.test.w) | compile | tf-aws | ||
|
||
## main.tf.json | ||
```json | ||
{ | ||
"//": { | ||
"metadata": { | ||
"backend": "local", | ||
"stackName": "root" | ||
}, | ||
"outputs": {} | ||
}, | ||
"provider": { | ||
"aws": [ | ||
{} | ||
] | ||
}, | ||
"resource": { | ||
"aws_cloudwatch_log_group": { | ||
"Function_CloudwatchLogGroup_ABDCF4C4": { | ||
"//": { | ||
"metadata": { | ||
"path": "root/Default/Default/Function/CloudwatchLogGroup", | ||
"uniqueId": "Function_CloudwatchLogGroup_ABDCF4C4" | ||
} | ||
}, | ||
"name": "/aws/lambda/Function-c852aba6", | ||
"retention_in_days": 30 | ||
} | ||
}, | ||
"aws_iam_role": { | ||
"Function_IamRole_678BE84C": { | ||
"//": { | ||
"metadata": { | ||
"path": "root/Default/Default/Function/IamRole", | ||
"uniqueId": "Function_IamRole_678BE84C" | ||
} | ||
}, | ||
"assume_role_policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":\"sts:AssumeRole\",\"Principal\":{\"Service\":\"lambda.amazonaws.com\"},\"Effect\":\"Allow\"}]}" | ||
} | ||
}, | ||
"aws_iam_role_policy": { | ||
"Function_IamRolePolicy_E3B26607": { | ||
"//": { | ||
"metadata": { | ||
"path": "root/Default/Default/Function/IamRolePolicy", | ||
"uniqueId": "Function_IamRolePolicy_E3B26607" | ||
} | ||
}, | ||
"policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Action\":\"none:null\",\"Resource\":\"*\"}]}", | ||
"role": "${aws_iam_role.Function_IamRole_678BE84C.name}" | ||
} | ||
}, | ||
"aws_iam_role_policy_attachment": { | ||
"Function_IamRolePolicyAttachment_CACE1358": { | ||
"//": { | ||
"metadata": { | ||
"path": "root/Default/Default/Function/IamRolePolicyAttachment", | ||
"uniqueId": "Function_IamRolePolicyAttachment_CACE1358" | ||
} | ||
}, | ||
"policy_arn": "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole", | ||
"role": "${aws_iam_role.Function_IamRole_678BE84C.name}" | ||
} | ||
}, | ||
"aws_lambda_function": { | ||
"Function": { | ||
"//": { | ||
"metadata": { | ||
"path": "root/Default/Default/Function/Default", | ||
"uniqueId": "Function" | ||
} | ||
}, | ||
"architectures": [ | ||
"arm64" | ||
], | ||
"environment": { | ||
"variables": { | ||
"NODE_OPTIONS": "--enable-source-maps", | ||
"WING_FUNCTION_NAME": "Function-c852aba6", | ||
"WING_TARGET": "tf-aws" | ||
} | ||
}, | ||
"function_name": "Function-c852aba6", | ||
"handler": "index.handler", | ||
"layers": [ | ||
"arn:aws:lambda:us-east-1:094274105915:layer:AWSLambdaPowertoolsTypeScriptV2:7" | ||
], | ||
"memory_size": 1024, | ||
"publish": true, | ||
"role": "${aws_iam_role.Function_IamRole_678BE84C.arn}", | ||
"runtime": "nodejs20.x", | ||
"s3_bucket": "${aws_s3_bucket.Code.bucket}", | ||
"s3_key": "${aws_s3_object.Function_S3Object_C62A0C2D.key}", | ||
"timeout": 60, | ||
"vpc_config": { | ||
"security_group_ids": [], | ||
"subnet_ids": [] | ||
} | ||
} | ||
}, | ||
"aws_s3_bucket": { | ||
"Code": { | ||
"//": { | ||
"metadata": { | ||
"path": "root/Default/Code", | ||
"uniqueId": "Code" | ||
} | ||
}, | ||
"bucket_prefix": "code-c84a50b1-" | ||
} | ||
}, | ||
"aws_s3_object": { | ||
"Function_S3Object_C62A0C2D": { | ||
"//": { | ||
"metadata": { | ||
"path": "root/Default/Default/Function/S3Object", | ||
"uniqueId": "Function_S3Object_C62A0C2D" | ||
} | ||
}, | ||
"bucket": "${aws_s3_bucket.Code.bucket}", | ||
"key": "<ASSET_KEY>", | ||
"source": "<ASSET_SOURCE>" | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
12 changes: 12 additions & 0 deletions
12
...angar/__snapshots__/test_corpus/sdk_tests/function/aws-layer.test.w_test_sim.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# [aws-layer.test.w](../../../../../../examples/tests/sdk_tests/function/aws-layer.test.w) | test | sim | ||
|
||
## stdout.log | ||
```log | ||
pass ─ aws-layer.test.wsim (no tests) | ||
Tests 1 passed (1) | ||
Snapshots 1 skipped | ||
Test Files 1 passed (1) | ||
Duration <DURATION> | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters