-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
55 lines (47 loc) · 1.53 KB
/
Program.cs
File metadata and controls
55 lines (47 loc) · 1.53 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
using Amazon.CDK;
using Amazon.CDK.AWS.Lambda;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Serverless
{
public class MyAppFunction : FunctionBase
{
public MyAppFunction(Construct scope, string id) : base(scope, id)
{
}
}
public class Node12Aspect : IAspect
{
public void Visit(IConstruct construct)
{
if (construct.GetType().Name.CompareTo("CfnFunction") == 0)
{
((CfnResource) construct).AddPropertyOverride("Runtime", "nodejs12.x");
}
}
}
class Program
{
static void Main(string[] args)
{
var app = new App(null);
var stack = new Stack(app, "mystack");
var fn = new Function(stack, "myfunction", new FunctionProps {
Code = Code.FromInline("my code here"),
Handler = "index.handler",
Runtime = Runtime.NODEJS_8_10
});
CfnFunction cfnfn = (CfnFunction) fn.Node.DefaultChild;
cfnfn.AddPropertyOverride("Runtime", "nodejs10.x");
var version = new CfnVersion(stack, $"{fn.Node.Id}-Version", new CfnVersionProps {
FunctionName = fn.FunctionName
});
version.Node.AddDependency(cfnfn);
var myappfn = new MyAppFunction(stack, "myappfunction");
// Console.WriteLine(myappfn.FunctionName);
stack.Node.ApplyAspect(new Node12Aspect());
app.Synth();
}
}
}