0
votes

I am using the template included with Aws tool kit for visual studio 2017 to create a serverless asp.net core 2 web api service which proxies a S3 bucket, hosted inside an aws lambda function. I am able to deploy this using the dotnet cli

dotnet lambda deploy-serverless

all the parameters to the sub command are stored in the aws-lambda-tools-defaults.json file. Everything works a expected, except for the parameters that are set for the CloudFormation template

{
"Information" : [
    "This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.",
    "To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.",
    "dotnet lambda help",
    "All the command line options for the Lambda command can be specified in this file."
],
"profile"     : "Development",
"region"      : "ap-southeast-2",
"configuration" : "Release",
"framework"     : "netcoreapp2.0",
"s3-prefix"     : "s3-prefix/",
"s3-bucket"     : "s3-bucket-name",
"stack-name"    : "stack-name",
"template"      : "serverless.template",
"template-parameters" : "\"ShouldCreateBucket\"=\"true\";\"BucketName\"=\"app-bucket-name\"",
    "stack-wait"          : true
}

These parameters are not passed into the template before the stack is created. Can anyone shed light on this ? Am I missing something or is it a bug with the aws tools for visual studio?

Thanks for your time!

1

1 Answers

0
votes

Alrighty now to answer my own question...it was human error..how embarassing. I made a typo in "Conditions" so BucketNameNotProvided was always false.

"Conditions" : {
"CreateS3Bucket" : {"Fn::Equals" : [{"Ref" : "ShouldCreateBucket"}, "true"]},
"BucketNameNotProvided" : {"Fn::Equals" : [{"Ref" : "BucketName"}, ""]}}

So further on in the template "BucketName" was removed from "Properties", results in Bucket with auto generated name.

"Bucket" : {
    "Type" : "AWS::S3::Bucket",
    "Condition" : "CreateS3Bucket",
    "Properties" : {
        "BucketName" : { "Fn::If" : ["BucketNameNotProvided", {"Ref" : "AWS::NoValue" }, { "Ref" : "BucketName" } ] }
    }
}