【发布时间】:2018-09-05 13:35:50
【问题描述】:
将我的模板上传到 CloudFormation 时,我收到以下验证错误:
模板验证错误:模板错误:中的属性 Fn::ImportValue 不得依赖于任何资源、导入的值或 Fn::GetAZs
我在下面有一个重现问题的测试模板:
Resources:
EC2Instance:
Type: "AWS::EC2::Instance"
Properties:
ImageId: ami-3bfab942
InstanceType: t2.micro
KeyName: mykeypair
UserData:
"Fn::Base64":
!Sub |
#!/bin/bash
yum update -y aws-cfn-bootstrap
/opt/aws/bin/cfn-init -v --stack ${AWS::StackName} --resource EC2Instance --configsets testset --region ${AWS::Region}
yum -y update
Metadata:
AWS::CloudFormation::Init:
configSets:
testset:
- "testConfiguration"
testConfiguration:
commands:
CreateTestFile:
cwd: "~"
command:
"Fn::ImportValue":
!Sub |
touch ${myexport}
为了让事情尽可能简单,我基本上是在尝试使用导出创建一个 bash 命令。所以在上面的例子中,我想创建一个基于导出值命名的文件。在我正在尝试做的事情的背景下,我不明白错误消息。我已验证导出存在于我创建的另一个堆栈中。
【问题讨论】:
-
你能发布你试图导入价值的资源 sn-p 吗?
-
您好,我已编辑包含一个具有相同问题的模板。
标签: amazon-web-services yaml amazon-cloudformation