-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLambdaFunctionConstructCustomization.cs
More file actions
44 lines (41 loc) · 2.03 KB
/
Copy pathLambdaFunctionConstructCustomization.cs
File metadata and controls
44 lines (41 loc) · 2.03 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
using Amazon.CDK.AWS.IAM;
using LayeredCraft.Cdk.Constructs.Models;
namespace LayeredCraft.Cdk.Constructs.Tests.TestKit.Customizations;
public class LambdaFunctionConstructCustomization(bool includeOtelLayer = false, bool includePermissions = true, bool generateUrl = false)
: ICustomization
{
public void Customize(IFixture fixture)
{
fixture.Customize<LambdaPermission>(transform => transform
.With(perm => perm.Principal, "alexa-appkit.amazon.com")
.With(perm => perm.Action, "lambda:InvokeFunction")
.With(perm => perm.EventSourceToken, "amzn1.ask.skill.test-skill-id"));
fixture.Customize<LambdaFunctionConstructProps>(transform => transform
.With(props => props.FunctionName, "test-function")
.With(props => props.FunctionSuffix, "disney-trivia")
.With(props => props.AssetPath, "./TestAssets/test-lambda.zip")
.With(props => props.RoleName, "test-function-us-east-1-lambdaRole")
.With(props => props.PolicyName, "test-function-lambda")
.With(props => props.PolicyStatements,
[
new(new PolicyStatementProps
{
Actions = ["dynamodb:Query", "dynamodb:GetItem", "dynamodb:PutItem"],
Resources = ["arn:aws:dynamodb:us-east-1:123456789012:table/test-table"],
Effect = Effect.ALLOW
})
])
.With(props => props.EnvironmentVariables, new Dictionary<string, string>
{
{ "TEST_VAR", "test-value" }
})
.With(props => props.IncludeOtelLayer, includeOtelLayer)
.With(props => props.OtelLayerVersion, "0-117-0")
.With(props => props.Architecture, "amd64")
.With(props => props.Permissions, includePermissions
? [fixture.Create<LambdaPermission>()]
: [])
.With(props => props.EnableSnapStart, false)
.With(props => props.GenerateUrl, generateUrl));
}
}