amazon-web-services - AWS SAM 本地启动 API 无法解析 Fn::ImportValue
问题描述
我有 SAM 模板(部分张贴在这里):
AWSTemplateFormatVersion: "2010-09-09"
Transform: "AWS::Serverless-2016-10-31"
Parameters:
StorageStackName:
Type: String
Description: Name of the stack which provisions DynamoDB table and S3 bucket.
Globals:
Function:
Runtime: nodejs12.x
MemorySize: 128
Timeout: 8
CodeUri: .
AutoPublishAlias: latest
Environment:
Variables:
SOURCE_TABLE_NAME:
Fn::ImportValue:
Fn::Sub: "${StorageStackName}-SourceTableName"
命令给我一个通知
sam local start-api --debug --parameter-overrides='StorageStackName=storage-dev'
Unable to resolve property SOURCE_TABLE_NAME: OrderedDict([('Fn::ImportValue', OrderedDict([('Fn::Sub', '${StorageStackName}-SourceTableName')]))]). Leaving as is.
我试图删除 Sub(不走运):
SOURCE_TABLE_NAME:
Fn::ImportValue: "storage-dev-SourceTableName"
该模板在服务器上工作,因此支持 Fn::ImportValue。所以我的问题是本地调用完全支持 Fn::ImportValue 吗?
storage-dev
我确保我使用与我拥有堆栈的本地 SAM 相同的凭据(配置文件) 。有什么办法可以再次检查以确保更多?
解决方案
从这篇文章开始,它似乎不受支持。我能找到的最后一个PR 只包括 !Sub 和 !If。看起来它们必须在 sam cli 成熟时作为参数或环境变量传入。
推荐阅读
- ruby-on-rails - Rails 5:设计可邀请的添加自定义字段
- makefile - 如何修改 configure 或 configure.ac 脚本以仅在指定位置查找二进制文件
- angularjs - 如何从角度降序开始
- c++ - 模板类成员与非成员模板函数的歧义
- git - 仅在选项卡中获取 git diff 输出
- jquery - 使用 jQuery 有条件地删除和替换 HTML 表单
- mysql - MYSQL:使用正则表达式 REGEX 验证输入
- json - 使用角度 ngx-translate 翻译 json 数组
- scrapy - 作为脚本运行时如何为 Scrapy 蜘蛛创建单独的日志文件
- android - 在 Lollipop 和 Marshmallow 上不调用 WebView 中的 JavaScriptInterface