【问题标题】:AWS Tools for Visual Studio 2017适用于 Visual Studio 2017 的 AWS 工具
【发布时间】:2018-04-17 12:22:02
【问题描述】:

我正在使用 Visual Studio 2017 的 Aws 工具包中包含的模板来创建一个无服务器的 asp.net core 2 Web api 服务,该服务代理一个 S3 存储桶,托管在 aws lambda 函数中。我可以使用 dotnet cli 部署它

dotnet lambda deploy-serverless

子命令的所有参数都存储在 aws-lambda-tools-defaults.json 文件。除了为 CloudFormation 模板设置的参数外,一切都按预期进行

{
"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
}

在创建堆栈之前,这些参数不会传递到模板中。任何人都可以阐明这一点吗?我是否遗漏了什么,还是 Visual Studio 的 aws 工具的错误?

感谢您的宝贵时间!

【问题讨论】:

    标签: amazon-web-services aws-lambda serverless


    【解决方案1】:

    现在可以回答我自己的问题了……这是人为错误……太尴尬了。我在“条件”中打错字,所以 BucketNameNotProvided 总是错误的。

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

    因此,在模板中“BucketName”进一步从“Properties”中删除,结果 Bucket 具有自动生成的名称。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-09-12
      • 1970-01-01
      • 2018-04-08
      • 2017-04-27
      • 2018-03-16
      • 1970-01-01
      • 2017-10-03
      相关资源
      最近更新 更多