Jie*_*eng 4 amazon-web-services aws-cloudformation ssm
我收到错误:
$ aws cloudformation deploy --template-file ./packaged-stack.yml --stack-name mystackname --capabilities CAPABILITY_NAMED_IAM`
An error occurred (ValidationError) when calling the CreateChangeSet operation: Unable to fetch parameters [XXX] from parameter store for this account.
Run Code Online (Sandbox Code Playgroud)
这里有什么问题?
奇怪的是XXX来自参数存储的值,所以 CloudFormation 实际上能够获取该值......但它似乎试图从其名称是它得到的值的参数中读取......我想我的用法是不正确?
AWSTemplateFormatVersion : '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: '...'
Parameters:
BaseStack:
Type: AWS::SSM::Parameter::Value<String>
Default: /some/thing/baseStack
Run Code Online (Sandbox Code Playgroud)
存储在所述值/some/thing/baseStack是XXX在这个例子中
小智 7
当您将参数从一个模板传递到另一个模板时,通常会发生这种情况。
Template 1 has parameter reading from SSM store and passing it to another template
Run Code Online (Sandbox Code Playgroud)
Parameters:
SNSTopicArnParam:
Description: Arn of the SNS topic
Type: AWS::SSM::Parameter::Value<String>
Default: /arn/topics/topic1
Resources:
CallOtherStack:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: someurl/template2.yaml
Parameters:
SNSTopicArn: !Ref SNSTopicArnParam
Run Code Online (Sandbox Code Playgroud)
模板 2 具有以下参数和资源(将出现 Unable to fetch parameters 错误。)
Parameters:
SNSTopicArnFromCaller:
Description: Arn of the SNS topic
Type: AWS::SSM::Parameter::Value<String>
Default: /arn/topics/topic1
Resources:
NewSubscription:
Type: AWS::SNS::Subscription
Properties:
Parameters:
TopicArn: !Ref SNSTopicArnFromCaller
Endpoint: someValue
Protocol: SQS
Run Code Online (Sandbox Code Playgroud)
这是因为模板 one 将具有 /arn/topics/topic1(主题的 arn)的值,并在调用它时将 arn 值传递给 template2。并且 template2 将值的类型作为另一个 SSM 参数。
为了解决这个问题,template2 参数类型应该只是实际参数值的类型。在这种情况下,它应该是String
所以,模板 2 应该更新如下才能正常工作
Parameters:
SNSTopicArnFromCaller:
Description: Arn of the SNS topic
Type: String
Resources:
NewSubscription:
Type: AWS::SNS::Subscription
Properties:
Parameters:
TopicArn: !Ref SNSTopicArnFromCaller
Endpoint: someValue
Protocol: SQS
Run Code Online (Sandbox Code Playgroud)
我们有一个类似的问题,发现我们在更新参数定义时遇到了这个问题。
我们的情况是:
使用参数 StageName 创建的堆栈,类型为 String default Dev。
然后,我们转而使用参数存储,并将参数定义更新为 AWS::SSM::Parameter::Value 类型,并使用参数存储路径进行默认。
在调用更新堆栈时,Cloudformation 正在读取现有值“Dev”并将其作为默认值传递给参数,因此它会在路径 Dev 中查找参数存储值。显然这不存在并导致错误:
调用 CreateChangeSet 操作时发生错误 (ValidationError):无法从此帐户的参数存储中获取参数 [Dev]。
对我们来说最简单的解决方法是删除堆栈并重新创建,但可以看到这对其他人来说是一个问题。如果有人有更好的“升级”方法,最好找出来。
我们正在为 Lambda 使用 sam deploy 进行部署,因此不确定这是否适用于其他堆栈的更新堆栈。
更新**
我尝试通过创建/更新堆栈重新创建它,但失败了,所以看起来这个问题仅限于 pacakge/deploy 升级机制
| 归档时间: |
|
| 查看次数: |
7923 次 |
| 最近记录: |