Alexander Presber
Alexander Presber

Reputation: 6625

AWS CLI create cloudfront distribution: --distribution-config

Trying a cloudfront distribution using the AWS CLI, one needs an argument --distribution-config

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

I assume this is a json string with the configuration for the distribution, but I cannot find any documentation about it. Where can I find a minimal working example?

Upvotes: 6

Views: 5805

Answers (2)

Francois
Francois

Reputation: 1510

As stated in the documentation you could try to run this command:

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

The file distconfig.json is a JSON document in the current folder that defines a CloudFront distribution:

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
}

If you follow the link I provided, you will have more information about the output this command will give you.

Upvotes: -1

imperalix
imperalix

Reputation: 3741

The following JSON worked for me. I used get-distribution-config to generate it.

{
    "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
    }
}

Upvotes: 3

Related Questions