是什么导致Aws :: CloudFront :: Errors :: MalformedInput:意外的列表元素终止

问题描述 投票:3回答:1

我正在尝试使用ruby AWS SDK的v2创建新的AWS Cloudfront Distribution,但无法弄清楚导致此错误的原因。

Aws :: CloudFront :: Errors :: MalformedInput:意外的列表元素终止

    client = Aws::CloudFront::Client.new

    resp = client.create_distribution({
        distribution_config: { 
            caller_reference: Time.now.to_i.to_s,
            :aliases => {
                :quantity => 1,
                :items => [Name.generate_name]
            },
            :origins => {
                :quantity => 1,
                :items => [
                    {
                        :id => "#{self.id}-distribution",
                        :domain_name => "example-static.s3-website-us-east-1.amazonaws.com",
                        :origin_path => "/#{self.id}",
                        :custom_headers => {
                            :quantity => 0,
                            :items => []
                        },
                        :custom_origin_config => {
                            :http_port => 80,
                            :https_port => 443,
                            :origin_protocol_policy => "http-only",
                            :origin_ssl_protocols => {
                                :quantity => 3,
                                :items => ["TLSv1","TLSv1.1","TLSv1.2"]
                            }
                        }
                    }
                ]
            },
            :default_cache_behavior => {
                :target_origin_id => "Custom-example-static.s3-website-us-east-1.amazonaws.com/#{self.id}",
                :forwarded_values => {
                    :query_string => true,
                    :cookies => {
                        :forward => "none"
                    },
                    :headers => {
                        :quantity => 1,
                        :items => ["Origin"]
                    }
                },
                :trusted_signers => {
                    :enabled => false,
                    :quantity => 0
                },
                :viewer_protocol_policy => "allow-all",
                :min_ttl => 0,
                :allowed_methods => {
                    :quantity => 3,
                     :items => ["HEAD","GET","OPTIONS"],
                    :cached_methods => {
                        :quantity => 3,
                        :items => ["HEAD","GET","OPTIONS"]
                    }
                },
                :smooth_streaming => false,
                :default_ttl => 86400,
                :max_ttl => 31536000,
                :compress => true
            },
            :cache_behaviors => {
                :quantity => 0
            },
            :custom_error_responses => {
                :quantity => 0
            },
            :comment => "",
            logging: {
                enabled: true, # required
                include_cookies: false, # required
                bucket: "example-logs", # required
                prefix: "#{self.id}", # required
            },              
            :price_class => "PriceClass_100",
            :enabled => true,
            :restrictions => {
                :geo_restriction => {
                    :restriction_type => "none",
                    :quantity => 0
                }
            }
        }
            })
ruby-on-rails ruby amazon-cloudfront aws-sdk
1个回答
6
投票

我比较了从现有实例中获得的结果

client = Aws::CloudFront::Client.new(:http_wire_trace => true)
resp = client.get_distribution_config({
    :id => '<ID>'
})

更改有效负载

:custom_headers => {
    :quantity => 0,
    :items => []
},

:custom_headers => {
    :quantity => 0
},

似乎为我修复了同样的错误信息。

© www.soinside.com 2019 - 2024. All rights reserved.