Spaces:
No application file
No application file
| **To create a CloudFront distribution** | |
| The following example creates a distribution for an S3 bucket named | |
| ``awsexamplebucket``, and also specifies ``index.html`` as the default root | |
| object, using command line arguments:: | |
| aws cloudfront create-distribution \ | |
| --origin-domain-name awsexamplebucket.s3.amazonaws.com \ | |
| --default-root-object index.html | |
| Instead of using command line arguments, you can provide the distribution | |
| configuration in a JSON file, as shown in the following example:: | |
| aws cloudfront create-distribution \ | |
| --distribution-config file://dist-config.json | |
| The file ``dist-config.json`` is a JSON document in the current folder that | |
| contains the following:: | |
| { | |
| "CallerReference": "cli-example", | |
| "Aliases": { | |
| "Quantity": 0 | |
| }, | |
| "DefaultRootObject": "index.html", | |
| "Origins": { | |
| "Quantity": 1, | |
| "Items": [ | |
| { | |
| "Id": "awsexamplebucket.s3.amazonaws.com-cli-example", | |
| "DomainName": "awsexamplebucket.s3.amazonaws.com", | |
| "OriginPath": "", | |
| "CustomHeaders": { | |
| "Quantity": 0 | |
| }, | |
| "S3OriginConfig": { | |
| "OriginAccessIdentity": "" | |
| } | |
| } | |
| ] | |
| }, | |
| "OriginGroups": { | |
| "Quantity": 0 | |
| }, | |
| "DefaultCacheBehavior": { | |
| "TargetOriginId": "awsexamplebucket.s3.amazonaws.com-cli-example", | |
| "ForwardedValues": { | |
| "QueryString": false, | |
| "Cookies": { | |
| "Forward": "none" | |
| }, | |
| "Headers": { | |
| "Quantity": 0 | |
| }, | |
| "QueryStringCacheKeys": { | |
| "Quantity": 0 | |
| } | |
| }, | |
| "TrustedSigners": { | |
| "Enabled": false, | |
| "Quantity": 0 | |
| }, | |
| "ViewerProtocolPolicy": "allow-all", | |
| "MinTTL": 0, | |
| "AllowedMethods": { | |
| "Quantity": 2, | |
| "Items": [ | |
| "HEAD", | |
| "GET" | |
| ], | |
| "CachedMethods": { | |
| "Quantity": 2, | |
| "Items": [ | |
| "HEAD", | |
| "GET" | |
| ] | |
| } | |
| }, | |
| "SmoothStreaming": false, | |
| "DefaultTTL": 86400, | |
| "MaxTTL": 31536000, | |
| "Compress": false, | |
| "LambdaFunctionAssociations": { | |
| "Quantity": 0 | |
| }, | |
| "FieldLevelEncryptionId": "" | |
| }, | |
| "CacheBehaviors": { | |
| "Quantity": 0 | |
| }, | |
| "CustomErrorResponses": { | |
| "Quantity": 0 | |
| }, | |
| "Comment": "", | |
| "Logging": { | |
| "Enabled": false, | |
| "IncludeCookies": false, | |
| "Bucket": "", | |
| "Prefix": "" | |
| }, | |
| "PriceClass": "PriceClass_All", | |
| "Enabled": true, | |
| "ViewerCertificate": { | |
| "CloudFrontDefaultCertificate": true, | |
| "MinimumProtocolVersion": "TLSv1", | |
| "CertificateSource": "cloudfront" | |
| }, | |
| "Restrictions": { | |
| "GeoRestriction": { | |
| "RestrictionType": "none", | |
| "Quantity": 0 | |
| } | |
| }, | |
| "WebACLId": "", | |
| "HttpVersion": "http2", | |
| "IsIPV6Enabled": true | |
| } | |
| Whether you provide the distribution information with a command line argument | |
| or a JSON file, the output is the same:: | |
| { | |
| "Location": "https://cloudfront.amazonaws.com/2019-03-26/distribution/EMLARXS9EXAMPLE", | |
| "ETag": "E9LHASXEXAMPLE", | |
| "Distribution": { | |
| "Id": "EMLARXS9EXAMPLE", | |
| "ARN": "arn:aws:cloudfront::123456789012:distribution/EMLARXS9EXAMPLE", | |
| "Status": "InProgress", | |
| "LastModifiedTime": "2019-11-22T00:55:15.705Z", | |
| "InProgressInvalidationBatches": 0, | |
| "DomainName": "d111111abcdef8.cloudfront.net", | |
| "ActiveTrustedSigners": { | |
| "Enabled": false, | |
| "Quantity": 0 | |
| }, | |
| "DistributionConfig": { | |
| "CallerReference": "cli-example", | |
| "Aliases": { | |
| "Quantity": 0 | |
| }, | |
| "DefaultRootObject": "index.html", | |
| "Origins": { | |
| "Quantity": 1, | |
| "Items": [ | |
| { | |
| "Id": "awsexamplebucket.s3.amazonaws.com-cli-example", | |
| "DomainName": "awsexamplebucket.s3.amazonaws.com", | |
| "OriginPath": "", | |
| "CustomHeaders": { | |
| "Quantity": 0 | |
| }, | |
| "S3OriginConfig": { | |
| "OriginAccessIdentity": "" | |
| } | |
| } | |
| ] | |
| }, | |
| "OriginGroups": { | |
| "Quantity": 0 | |
| }, | |
| "DefaultCacheBehavior": { | |
| "TargetOriginId": "awsexamplebucket.s3.amazonaws.com-cli-example", | |
| "ForwardedValues": { | |
| "QueryString": false, | |
| "Cookies": { | |
| "Forward": "none" | |
| }, | |
| "Headers": { | |
| "Quantity": 0 | |
| }, | |
| "QueryStringCacheKeys": { | |
| "Quantity": 0 | |
| } | |
| }, | |
| "TrustedSigners": { | |
| "Enabled": false, | |
| "Quantity": 0 | |
| }, | |
| "ViewerProtocolPolicy": "allow-all", | |
| "MinTTL": 0, | |
| "AllowedMethods": { | |
| "Quantity": 2, | |
| "Items": [ | |
| "HEAD", | |
| "GET" | |
| ], | |
| "CachedMethods": { | |
| "Quantity": 2, | |
| "Items": [ | |
| "HEAD", | |
| "GET" | |
| ] | |
| } | |
| }, | |
| "SmoothStreaming": false, | |
| "DefaultTTL": 86400, | |
| "MaxTTL": 31536000, | |
| "Compress": false, | |
| "LambdaFunctionAssociations": { | |
| "Quantity": 0 | |
| }, | |
| "FieldLevelEncryptionId": "" | |
| }, | |
| "CacheBehaviors": { | |
| "Quantity": 0 | |
| }, | |
| "CustomErrorResponses": { | |
| "Quantity": 0 | |
| }, | |
| "Comment": "", | |
| "Logging": { | |
| "Enabled": false, | |
| "IncludeCookies": false, | |
| "Bucket": "", | |
| "Prefix": "" | |
| }, | |
| "PriceClass": "PriceClass_All", | |
| "Enabled": true, | |
| "ViewerCertificate": { | |
| "CloudFrontDefaultCertificate": true, | |
| "MinimumProtocolVersion": "TLSv1", | |
| "CertificateSource": "cloudfront" | |
| }, | |
| "Restrictions": { | |
| "GeoRestriction": { | |
| "RestrictionType": "none", | |
| "Quantity": 0 | |
| } | |
| }, | |
| "WebACLId": "", | |
| "HttpVersion": "http2", | |
| "IsIPV6Enabled": true | |
| } | |
| } | |
| } | |