-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlambda-version-ref.pkl
More file actions
90 lines (77 loc) · 2.1 KB
/
Copy pathlambda-version-ref.pkl
File metadata and controls
90 lines (77 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*
* © 2025 Platform Engineering Labs Inc.
*
* SPDX-License-Identifier: FSL-1.1-ALv2
*/
amends "@formae/forma.pkl"
import "@formae/formae.pkl"
import "@aws/aws.pkl"
import "@aws/iam/role.pkl"
import "@aws/lambda/func.pkl"
import "@aws/lambda/permission.pkl"
import "@aws/lambda/version.pkl"
local testRunID = read("env:FORMAE_TEST_RUN_ID")
local stackName = "plugin-sdk-test-lambda-version-ref-\(testRunID)"
local lambdaRole = new role.Role {
label = "lambda-execution-role"
roleName = "formae-sdk-test-lambda-vref-role-\(testRunID)"
assumeRolePolicyDocument {
["Version"] = "2012-10-17"
["Statement"] {
new {
["Effect"] = "Allow"
["Principal"] {
["Service"] = "lambda.amazonaws.com"
}
["Action"] = "sts:AssumeRole"
}
}
}
}
local testFunction = new func.Function {
label = "test-function-for-version-ref"
functionName = "formae-sdk-test-lambda-vref-\(testRunID)"
role = lambdaRole.res.arn
runtime = "python3.12"
handler = "index.handler"
code = new func.Code {
zipFile = """
import json
def handler(event, context):
return {
'statusCode': 200,
'body': json.dumps({'message': 'hello from formae'})
}
"""
}
memorySize = 128
timeout = 10
}
local testVersion = new version.Version {
label = "plugin-sdk-test-lambda-version-ref"
functionName = testFunction.res.arn
description = "Plugin SDK test version for resolvable reference"
}
forma {
new formae.Stack {
label = stackName
description = "Plugin SDK test for Lambda Version references"
}
new formae.Target {
label = "aws-target"
config = new aws.Config {
region = "us-east-1"
}
}
lambdaRole
testFunction
testVersion
// The permission targets the published version's qualified ARN, so the
// apply only succeeds if the Version's FunctionArn resolves.
new permission.Permission {
label = "plugin-sdk-test-lambda-version-ref-permission"
functionName = testVersion.res.functionArn
action = "lambda:InvokeFunction"
principal = "apigateway.amazonaws.com"
}
}