-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDeploy.swift
109 lines (89 loc) · 3.59 KB
/
Deploy.swift
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import AWSLambdaDeploymentDescriptor
// example of a shared resource
let sharedQueue = Queue(
logicalName: "SharedQueue",
physicalName: "swift-lambda-shared-queue"
)
// example of common environment variables
let sharedEnvironmentVariables = ["LOG_LEVEL": "debug"]
let validEfsArn =
"arn:aws:elasticfilesystem:eu-central-1:012345678901:access-point/fsap-abcdef01234567890"
// the deployment descriptor
DeploymentDescriptor {
// an optional description
"Description of this deployment descriptor"
// Create a lambda function exposed through a REST API
Function(name: "HttpApiLambda") {
// an optional description
"Description of this function"
EventSources {
// example of a catch all api
HttpApi()
// example of an API for a specific HTTP verb and path
// HttpApi(method: .GET, path: "/test")
}
EnvironmentVariables {
[
"NAME1": "VALUE1",
"NAME2": "VALUE2",
]
// shared environment variables declared upfront
sharedEnvironmentVariables
}
}
// Example Function modifiers:
// .autoPublishAlias()
// .ephemeralStorage(2048)
// .eventInvoke(onSuccess: "arn:aws:sqs:eu-central-1:012345678901:lambda-test",
// onFailure: "arn:aws:lambda:eu-central-1:012345678901:lambda-test",
// maximumEventAgeInSeconds: 600,
// maximumRetryAttempts: 3)
// .fileSystem(validEfsArn, mountPoint: "/mnt/path1")
// .fileSystem(validEfsArn, mountPoint: "/mnt/path2")
// Create a Lambda function exposed through an URL
// you can invoke it with a signed request, for example
// curl --aws-sigv4 "aws:amz:eu-central-1:lambda" \
// --user $AWS_ACCESS_KEY_ID:$AWS_SECRET_ACCESS_KEY \
// -H 'content-type: application/json' \
// -d '{ "example": "test" }' \
// "$FUNCTION_URL?param1=value1¶m2=value2"
Function(name: "UrlLambda") {
"A Lambda function that is directly exposed as an URL, with IAM authentication"
}
.urlConfig(authType: .iam)
// Create a Lambda function triggered by messages on SQS
Function(name: "SQSLambda", architecture: .arm64) {
EventSources {
// this will reference an existing queue by its Arn
// Sqs("arn:aws:sqs:eu-central-1:012345678901:swift-lambda-shared-queue")
// // this will create a new queue resource
Sqs("swift-lambda-queue-name")
// // this will create a new queue resource, with control over physical queue name
// Sqs()
// .queue(logicalName: "LambdaQueueResource", physicalName: "swift-lambda-queue-resource")
// // this references a shared queue resource created at the top of this deployment descriptor
// // the queue resource will be created automatically, you do not need to add `sharedQueue` as a resource
// Sqs(sharedQueue)
}
EnvironmentVariables {
sharedEnvironmentVariables
}
}
//
// Additional resources
//
// Create a SQS queue
Queue(
logicalName: "TopLevelQueueResource",
physicalName: "swift-lambda-top-level-queue"
)
// Create a DynamoDB table
Table(
logicalName: "SwiftLambdaTable",
physicalName: "swift-lambda-table",
primaryKeyName: "id",
primaryKeyType: "String"
)
// example modifiers
// .provisionedThroughput(readCapacityUnits: 10, writeCapacityUnits: 99)
}