protected override Amazon.CDK.AWS.Lambda.Function Build(Construct scope)
        {
            this
            .SourceFromAsset(_infraContext.AssetFileFolder + "\\ImageTagger.Web.zip")
            .SetHandler("ImageTagger.Web::ImageTagger.Web.LambdaEntryPoint::FunctionHandlerAsync")
            .SetName(_infraContext.RestApiFunctionName)
            .AddEnvVariables("IMGTAGGER_BUCKETNAME", _imageBucket.GetInstance(scope).BucketName)
            .Grant(new S3Grant()
                   .ReadWrite()
                   .On($"{_imageBucket.GetInstance(scope).BucketArn}*")
                   );


            var result = base.Build(scope);

            return(result);
        }
Example #2
0
        protected override Function Build(Construct scope)
        {
            var functionName  = _infraContext.ImageTaggerFunctionName;
            var assetFilename = _infraContext.AssetFileFolder + "\\ImageTagger.Lambda.zip";

            this.SetName(functionName)
            .SetHandler("ImageTagger.Lambda::ImageTagger.Lambda.Function::Handler")
            .SourceFromAsset(assetFilename)
            .Grant(new RekognitionGrant().FullAccess())
            .Grant(new S3Grant()
                   .ReadWrite()
                   .On($"{_bucketBuilder.GetInstance(scope).BucketArn}*")
                   )
            .AddS3EventSource(_bucketBuilder, EventType.OBJECT_CREATED);

            return(base.Build(scope));
        }