コード例 #1
0
ファイル: HitCounter.cs プロジェクト: leo-texuanw/learning
        public HitCounter(Construct scope, string id, HitCounterProps props) : base(scope, id)
        {
            var table = new Table(this, "Hits", new TableProps
            {
                PartitionKey = new Attribute
                {
                    Name = "path",
                    Type = AttributeType.STRING
                }
            });

            Handler = new Function(this, "HitCounterHandler", new FunctionProps
            {
                Runtime     = Runtime.NODEJS_10_X,
                Handler     = "hitcounter.handler",
                Code        = Code.FromAsset("src/lambda"),
                Environment = new Dictionary <string, string>
                {
                    ["DOWNSTREAM_FUNCTION_NAME"] = props.Downstream.FunctionName,
                    ["HITS_TABLE_NAME"]          = table.TableName
                }
            });

            // grant the lambda role read/write permission to the table
            table.GrantReadWriteData(Handler);

            // Grant the lambda role invoke permission to the downstream function
            props.Downstream.GrantInvoke(Handler);
        }
コード例 #2
0
ファイル: HitCounter.cs プロジェクト: ongzhixian/Impulse
 public HitCounter(Construct scope, string id, HitCounterProps props) : base(scope, id)
 {
     // TODO
 }