AWS CLI创建云端分发:--distribution-config

时间:2014-09-29 07:29:30

标签: amazon-web-services amazon-cloudfront aws-cli

使用AWS CLI尝试使用cloudfront发行版时,需要一个参数--distribution-config

aws cloudfront create-distribution
aws: error: argument --distribution-config is required

我认为这是一个带有配置配置的json字符串,但我找不到任何关于它的文档。 我在哪里可以找到最小的工作示例?

2 个答案:

答案 0 :(得分:3)

以下JSON为我工作。我使用get-distribution-config来生成它。

{
    "Comment": "example json",
    "CacheBehaviors": {
        "Quantity": 0
    },
    "Logging": {
        "Bucket": null,
        "Prefix": null,
        "Enabled": false,
        "IncludeCookies": false
    },
    "Origins": {
        "Items": [
            {
                "S3OriginConfig": {
                    "OriginAccessIdentity": null
                },
                "Id": "S3-origin",
                "DomainName": "example.s3.amazonaws.com"
            }
        ],
        "Quantity": 1
    },
    "DefaultRootObject": null,
    "PriceClass": "PriceClass_All",
    "Enabled": false,
    "DefaultCacheBehavior": {
        "TrustedSigners": {
            "Enabled": false,
            "Quantity": 0
        },
        "TargetOriginId": "S3-origin",
        "ViewerProtocolPolicy": "allow-all",
        "ForwardedValues": {
            "Headers": {
                "Quantity": 0
            },
            "Cookies": {
                "Forward": "none"
            },
            "QueryString": false
        },
        "SmoothStreaming": false,
        "AllowedMethods": {
            "Items": [
                "GET",
                "HEAD"
            ],
            "Quantity": 2
        },
        "MinTTL": 0
    },
    "CallerReference": "example",
    "ViewerCertificate": {
        "CloudFrontDefaultCertificate": true
    },
    "CustomErrorResponses": {
        "Quantity": 0
    },
    "Restrictions": {
        "GeoRestriction": {
            "RestrictionType": "none",
            "Quantity": 0
        }
    },
    "Aliases": {
        "Quantity": 0
    }
}

答案 1 :(得分:-1)

the documentation中所述,您可以尝试运行此命令:

aws cloudfront create-distribution --distribution-config file://distconfig.json
  

文件distconfig.json是当前文件夹中定义CloudFront分配的JSON文档:

distconfig.json

{
  "CallerReference": "my-distribution-2015-09-01",
  "Aliases": {
    "Quantity": 0
  },
  "DefaultRootObject": "index.html",
  "Origins": {
    "Quantity": 1,
    "Items": [
      {
        "Id": "my-origin",
        "DomainName": "my-bucket.s3.amazonaws.com",
        "S3OriginConfig": {
          "OriginAccessIdentity": ""
        }
      }
    ]
  },
  "DefaultCacheBehavior": {
    "TargetOriginId": "my-origin",
    "ForwardedValues": {
      "QueryString": true,
      "Cookies": {
        "Forward": "none"
      }
    },
    "TrustedSigners": {
      "Enabled": false,
      "Quantity": 0
    },
    "ViewerProtocolPolicy": "allow-all",
    "MinTTL": 3600
  },
  "CacheBehaviors": {
    "Quantity": 0
  },
  "Comment": "",
  "Logging": {
    "Enabled": false,
    "IncludeCookies": true,
    "Bucket": "",
    "Prefix": ""
  },
  "PriceClass": "PriceClass_All",
  "Enabled": true
}

如果您按照我提供的链接,您将获得有关此命令将为您提供的输出的更多信息。