遇到 ruby Cloudformation 问题我有一个超级简单的 cloudformation 模板,它将使用 AWS CLI 验证和 create_stack,但是当我使用 Ruby SDK 运行任何一个相同的命令时失败。
$ cat net.yml
AWSTemplateFormatVersion: '2010-09-09'
Resources:
Vpc:
Type: AWS::EC2::VPC
Properties:
CidrBlock: 10.0.0.0/16
$ aws cloudformation validate-template --region us-east-1 --template-body file://./net.yml
{
"Parameters": []
}
$ irb
irb(main):001:0> require 'aws-sdk-cloudformation'
=> true
irb(main):002:1* cfn = Aws::CloudFormation::Client.new(
irb(main):003:1* region: 'us-east-1'
irb(main):004:0> )
irb(main):005:2* cfn.validate_template({
irb(main):006:2* template_body: 'file://./net.yml'
irb(main):007:0> })
Traceback (most recent call last):
13: from /usr/bin/irb:23:in `<main>'
12: from /usr/bin/irb:23:in `load'
11: from /usr/lib/ruby/gems/2.7.0/gems/irb-1.2.1/exe/irb:11:in `<top (required)>'
10: from (irb):5
9: from /var/lib/gems/2.7.0/gems/aws-sdk-cloudformation-1.47.0/lib/aws-sdk-cloudformation/client.rb:5361:in `validate_template'
8: from /var/lib/gems/2.7.0/gems/aws-sdk-core-3.112.0/lib/seahorse/client/request.rb:72:in `send_request'
7: from /var/lib/gems/2.7.0/gems/aws-sdk-core-3.112.0/lib/seahorse/client/plugins/response_target.rb:24:in `call'
6: from /var/lib/gems/2.7.0/gems/aws-sdk-core-3.112.0/lib/aws-sdk-core/plugins/response_paging.rb:12:in `call'
5: from /var/lib/gems/2.7.0/gems/aws-sdk-core-3.112.0/lib/seahorse/client/plugins/request_callback.rb:71:in `call'
4: from /var/lib/gems/2.7.0/gems/aws-sdk-core-3.112.0/lib/aws-sdk-core/plugins/param_converter.rb:26:in `call'
3: from /var/lib/gems/2.7.0/gems/aws-sdk-core-3.112.0/lib/aws-sdk-core/plugins/idempotency_token.rb:19:in `call'
2: from /var/lib/gems/2.7.0/gems/aws-sdk-core-3.112.0/lib/aws-sdk-core/plugins/jsonvalue_converter.rb:22:in `call'
1: from /var/lib/gems/2.7.0/gems/aws-sdk-core-3.112.0/lib/seahorse/client/plugins/raise_response_errors.rb:17:in `call'
Aws::CloudFormation::Errors::ValidationError (Template format error: unsupported structure.)
irb(main):008:0>
我是否file://
在template_body
现场使用并不重要。如果我将它上传到 S3,我可以让 Ruby 使用相同的模板,但我不想这样做。以前有人遇到过这个问题吗?