5

尝试使用 AWS CLI 进行云端分发,需要一个参数 --distribution-config

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

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

4

2 回答 2

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
    }
}
于 2014-10-05T07:49:39.233 回答
-2

文档中所述,您可以尝试运行此命令:

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
}

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

于 2017-08-03T13:19:50.997 回答