Example #1
0
        static void Main(string[] args)
        {
            var app    = new App();
            var stack  = new Stack(app, "mystack");
            var events = new Dictionary <string, object>();

            events.Add("Event", new CfnFunction.EventSourceProperty()
            {
                Type       = "type1",
                Properties = new CfnFunction.SQSEventProperty()
                {
                    Queue = "mysqsqueue"
                }
            });
            var fn = new CfnFunction(stack, "myfunction", new CfnFunctionProps
            {
                CodeUri = "mycodeuri",
                Handler = "index.handler",
                Runtime = "nodejs10.x",
                Events  = events
            });

            Debug.Assert(
                ((CfnFunction.SQSEventProperty)
                     ((CfnFunction.EventSourceProperty)
                         ((Dictionary <string, object>)fn.Events)["Event"]
                     ).Properties
                ).Queue == "mysqsqueue");
            app.Synth();
        }
Example #2
0
        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();
        }