本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
CloudFront 使用 的範例 AWS CLI
下列程式碼範例示範如何使用 AWS Command Line Interface 搭配 來執行動作和實作常見案例 CloudFront。
Actions 是大型程式的程式碼摘錄,必須在內容中執行。雖然動作會示範如何呼叫個別服務函數,但您可以在其相關案例中查看內容中的動作。
每個範例都包含完整原始程式碼的連結,您可以在其中找到如何在內容中設定和執行程式碼的指示。
主題
動作
下列程式碼範例示範如何使用 create-cloud-front-origin-access-identity
。
- AWS CLI
-
建立 CloudFront 原始存取身分
下列範例透過將OAI組態提供為命令列引數來建立 CloudFront 原始伺服器存取身分 (OAI):
aws cloudfront create-cloud-front-origin-access-identity \ --cloud-front-origin-access-identity-config \ CallerReference="cli-example",Comment="Example OAI"
您可以透過在JSON檔案中提供OAI組態來完成相同的動作,如下列範例所示:
aws cloudfront create-cloud-front-origin-access-identity \ --cloud-front-origin-access-identity-config
file://OAI-config.json
檔案
OAI-config.json
是目前目錄中JSON的文件,其中包含以下內容:{ "CallerReference": "cli-example", "Comment": "Example OAI" }
無論您是使用命令列引數或JSON檔案提供OAI組態,輸出都是相同的:
{ "Location": "https://cloudfront.amazonaws.com/2019-03-26/origin-access-identity/cloudfront/E74FTE3AEXAMPLE", "ETag": "E2QWRUHEXAMPLE", "CloudFrontOriginAccessIdentity": { "Id": "E74FTE3AEXAMPLE", "S3CanonicalUserId": "cd13868f797c227fbea2830611a26fe0a21ba1b826ab4bed9b7771c9aEXAMPLE", "CloudFrontOriginAccessIdentityConfig": { "CallerReference": "cli-example", "Comment": "Example OAI" } } }
-
如需API詳細資訊,請參閱 命令參考 CreateCloudFrontOriginAccessIdentity
中的 。 AWS CLI
-
下列程式碼範例示範如何使用 create-distribution-with-tags
。
- AWS CLI
-
使用標籤建立 CloudFront 分佈
下列範例透過在名為 的JSON檔案中提供分佈組態和標籤,建立具有兩個標籤的分佈
dist-config-with-tags.json
:aws cloudfront create-distribution-with-tags \ --distribution-config-with-tags
file://dist-config-with-tags.json
檔案
dist-config-with-tags.json
是JSON目前資料夾中的文件,其中包含以下內容。請注意檔案頂端的Tags
物件,其中包含兩個標籤:Name = ExampleDistribution
Project = ExampleProject
{ "Tags": { "Items": [ { "Key": "Name", "Value": "ExampleDistribution" }, { "Key": "Project", "Value": "ExampleProject" } ] }, "DistributionConfig": { "CallerReference": "cli-example", "Aliases": { "Quantity": 0 }, "DefaultRootObject": "index.html", "Origins": { "Quantity": 1, "Items": [ { "Id": "awsexamplebucket---s3.amazonaws.com.rproxy.goskope.com-cli-example", "DomainName": "awsexamplebucket.s3.amazonaws.com", "OriginPath": "", "CustomHeaders": { "Quantity": 0 }, "S3OriginConfig": { "OriginAccessIdentity": "" } } ] }, "OriginGroups": { "Quantity": 0 }, "DefaultCacheBehavior": { "TargetOriginId": "awsexamplebucket---s3.amazonaws.com.rproxy.goskope.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 } }
輸出:
{ "Location": "https://cloudfront.amazonaws.com/2019-03-26/distribution/EDFDVBD6EXAMPLE", "ETag": "E2QWRUHEXAMPLE", "Distribution": { "Id": "EDFDVBD6EXAMPLE", "ARN": "arn:aws:cloudfront::123456789012:distribution/EDFDVBD6EXAMPLE", "Status": "InProgress", "LastModifiedTime": "2019-12-04T23:35:41.433Z", "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.rproxy.goskope.com-cli-example", "DomainName": "awsexamplebucket.s3.amazonaws.com", "OriginPath": "", "CustomHeaders": { "Quantity": 0 }, "S3OriginConfig": { "OriginAccessIdentity": "" } } ] }, "OriginGroups": { "Quantity": 0 }, "DefaultCacheBehavior": { "TargetOriginId": "awsexamplebucket---s3.amazonaws.com.rproxy.goskope.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 } } }
-
如需API詳細資訊,請參閱 命令參考 CreateDistributionWithTags
中的 。 AWS CLI
-
下列程式碼範例示範如何使用 create-distribution
。
- AWS CLI
-
建立 CloudFront 分佈
下列範例會為名為 的 S3 儲存貯體建立分佈,
awsexamplebucket
並使用命令列引數指定index.html
為預設根物件:aws cloudfront create-distribution \ --origin-domain-name
awsexamplebucket.s3.amazonaws.com
\ --default-root-objectindex.html
您可以提供JSON檔案中的分佈組態,而不是使用命令列引數,如下列範例所示:
aws cloudfront create-distribution \ --distribution-config
file://dist-config.json
檔案
dist-config.json
是JSON目前資料夾中的文件,其中包含以下內容:{ "CallerReference": "cli-example", "Aliases": { "Quantity": 0 }, "DefaultRootObject": "index.html", "Origins": { "Quantity": 1, "Items": [ { "Id": "awsexamplebucket---s3.amazonaws.com.rproxy.goskope.com-cli-example", "DomainName": "awsexamplebucket.s3.amazonaws.com", "OriginPath": "", "CustomHeaders": { "Quantity": 0 }, "S3OriginConfig": { "OriginAccessIdentity": "" } } ] }, "OriginGroups": { "Quantity": 0 }, "DefaultCacheBehavior": { "TargetOriginId": "awsexamplebucket---s3.amazonaws.com.rproxy.goskope.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 }
無論您是使用命令列引數或 JSON 檔案提供分佈資訊,輸出都是相同的:
{ "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.rproxy.goskope.com-cli-example", "DomainName": "awsexamplebucket.s3.amazonaws.com", "OriginPath": "", "CustomHeaders": { "Quantity": 0 }, "S3OriginConfig": { "OriginAccessIdentity": "" } } ] }, "OriginGroups": { "Quantity": 0 }, "DefaultCacheBehavior": { "TargetOriginId": "awsexamplebucket---s3.amazonaws.com.rproxy.goskope.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 } } }
-
如需API詳細資訊,請參閱 命令參考 CreateDistribution
中的 。 AWS CLI
-
下列程式碼範例示範如何使用 create-field-level-encryption-config
。
- AWS CLI
-
建立 CloudFront 欄位層級加密組態
下列範例透過在名為 的JSON檔案中提供組態參數來建立欄位層級加密組態
fle-config.json
。您必須先具有欄位層級加密設定檔,才能建立欄位層級加密組態。若要建立設定檔,請參閱 create-field-level-encryption-profile 命令。如需 CloudFront 欄位層級加密的詳細資訊,請參閱 Amazon CloudFront 開發人員指南 中的使用欄位層級加密協助保護敏感資料。
aws cloudfront create-field-level-encryption-config \ --field-level-encryption-config
file://fle-config.json
檔案
fle-config.json
是JSON目前資料夾中的文件,其中包含以下內容:{ "CallerReference": "cli-example", "Comment": "Example FLE configuration", "QueryArgProfileConfig": { "ForwardWhenQueryArgProfileIsUnknown": true, "QueryArgProfiles": { "Quantity": 0 } }, "ContentTypeProfileConfig": { "ForwardWhenContentTypeIsUnknown": true, "ContentTypeProfiles": { "Quantity": 1, "Items": [ { "Format": "URLEncoded", "ProfileId": "P280MFCLSYOCVU", "ContentType": "application/x-www-form-urlencoded" } ] } } }
輸出:
{ "Location": "https://cloudfront.amazonaws.com/2019-03-26/field-level-encryption/C3KM2WVD605UAY", "ETag": "E2P4Z4VU7TY5SG", "FieldLevelEncryption": { "Id": "C3KM2WVD605UAY", "LastModifiedTime": "2019-12-10T21:30:18.974Z", "FieldLevelEncryptionConfig": { "CallerReference": "cli-example", "Comment": "Example FLE configuration", "QueryArgProfileConfig": { "ForwardWhenQueryArgProfileIsUnknown": true, "QueryArgProfiles": { "Quantity": 0, "Items": [] } }, "ContentTypeProfileConfig": { "ForwardWhenContentTypeIsUnknown": true, "ContentTypeProfiles": { "Quantity": 1, "Items": [ { "Format": "URLEncoded", "ProfileId": "P280MFCLSYOCVU", "ContentType": "application/x-www-form-urlencoded" } ] } } } } }
-
如需API詳細資訊,請參閱 命令參考 CreateFieldLevelEncryptionConfig
中的 。 AWS CLI
-
下列程式碼範例示範如何使用 create-field-level-encryption-profile
。
- AWS CLI
-
建立 CloudFront 欄位層級加密設定檔
下列範例會透過在名為 的JSON檔案中提供參數來建立欄位層級加密設定檔
fle-profile-config.json
。您必須先擁有 CloudFront 公有金鑰,才能建立欄位層級加密設定檔。若要建立 CloudFront 公有金鑰,請參閱 create-public-key命令。如需 CloudFront 欄位層級加密的詳細資訊,請參閱 Amazon CloudFront 開發人員指南 中的使用欄位層級加密協助保護敏感資料。
aws cloudfront create-field-level-encryption-profile \ --field-level-encryption-profile-config
file://fle-profile-config.json
檔案
fle-profile-config.json
是目前資料夾中JSON的文件,其中包含以下內容:{ "Name": "ExampleFLEProfile", "CallerReference": "cli-example", "Comment": "FLE profile for AWS CLI example", "EncryptionEntities": { "Quantity": 1, "Items": [ { "PublicKeyId": "K2K8NC4HVFE3M0", "ProviderId": "ExampleFLEProvider", "FieldPatterns": { "Quantity": 1, "Items": [ "ExampleSensitiveField" ] } } ] } }
輸出:
{ "Location": "https://cloudfront.amazonaws.com/2019-03-26/field-level-encryption-profile/PPK0UOSIF5WSV", "ETag": "E2QWRUHEXAMPLE", "FieldLevelEncryptionProfile": { "Id": "PPK0UOSIF5WSV", "LastModifiedTime": "2019-12-10T01:03:16.537Z", "FieldLevelEncryptionProfileConfig": { "Name": "ExampleFLEProfile", "CallerReference": "cli-example", "Comment": "FLE profile for AWS CLI example", "EncryptionEntities": { "Quantity": 1, "Items": [ { "PublicKeyId": "K2K8NC4HVFE3M0", "ProviderId": "ExampleFLEProvider", "FieldPatterns": { "Quantity": 1, "Items": [ "ExampleSensitiveField" ] } } ] } } } }
-
如需API詳細資訊,請參閱 命令參考 CreateFieldLevelEncryptionProfile
中的 。 AWS CLI
-
下列程式碼範例示範如何使用 create-invalidation
。
- AWS CLI
-
為 CloudFront 分佈建立無效
下列
create-invalidation
範例會為指定 CloudFront 分佈中的指定檔案建立無效:aws cloudfront create-invalidation \ --distribution-id
EDFDVBD6EXAMPLE
\ --paths"/example-path/example-file.jpg"
"/example-path/example-file2.png"
輸出:
{ "Location": "https://cloudfront.amazonaws.com/2019-03-26/distribution/EDFDVBD6EXAMPLE/invalidation/I1JLWSDAP8FU89", "Invalidation": { "Id": "I1JLWSDAP8FU89", "Status": "InProgress", "CreateTime": "2019-12-05T18:24:51.407Z", "InvalidationBatch": { "Paths": { "Quantity": 2, "Items": [ "/example-path/example-file2.png", "/example-path/example-file.jpg" ] }, "CallerReference": "cli-1575570291-670203" } } }
在上一個範例中, AWS CLI會自動產生隨機
CallerReference
。若要指定您自己的CallerReference
,或避免將無效參數傳遞為命令列引數,您可以使用 JSON 檔案。下列範例透過在名為 的JSON檔案中提供失效參數,為兩個檔案建立失效inv-batch.json
:aws cloudfront create-invalidation \ --distribution-id
EDFDVBD6EXAMPLE
\ --invalidation-batchfile://inv-batch.json
inv-batch.json
的內容:{ "Paths": { "Quantity": 2, "Items": [ "/example-path/example-file.jpg", "/example-path/example-file2.png" ] }, "CallerReference": "cli-example" }
輸出:
{ "Location": "https://cloudfront.amazonaws.com/2019-03-26/distribution/EDFDVBD6EXAMPLE/invalidation/I2J0I21PCUYOIK", "Invalidation": { "Id": "I2J0I21PCUYOIK", "Status": "InProgress", "CreateTime": "2019-12-05T18:40:49.413Z", "InvalidationBatch": { "Paths": { "Quantity": 2, "Items": [ "/example-path/example-file.jpg", "/example-path/example-file2.png" ] }, "CallerReference": "cli-example" } } }
-
如需API詳細資訊,請參閱 命令參考 CreateInvalidation
中的 。 AWS CLI
-
下列程式碼範例示範如何使用 create-public-key
。
- AWS CLI
-
若要建立 CloudFront 公有金鑰
下列範例透過在名為 的JSON檔案中提供參數來建立 CloudFront 公有金鑰
pub-key-config.json
。您必須先有 PEM編碼的公有金鑰,才能使用此命令。如需詳細資訊,請參閱 Amazon CloudFront 開發人員指南 中的建立RSA金鑰對。aws cloudfront create-public-key \ --public-key-config
file://pub-key-config.json
檔案
pub-key-config.json
是JSON目前資料夾中的文件,其中包含以下內容。請注意,公有金鑰會以 PEM 格式編碼。{ "CallerReference": "cli-example", "Name": "ExampleKey", "EncodedKey": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxPMbCA2Ks0lnd7IR+3pw\nwd3H/7jPGwj8bLUmore7bX+oeGpZ6QmLAe/1UOWcmZX2u70dYcSIzB1ofZtcn4cJ\nenHBAzO3ohBY/L1tQGJfS2A+omnN6H16VZE1JCK8XSJyfze7MDLcUyHZETdxuvRb\nA9X343/vMAuQPnhinFJ8Wdy8YBXSPpy7r95ylUQd9LfYTBzVZYG2tSesplcOkjM3\n2Uu+oMWxQAw1NINnSLPinMVsutJy6ZqlV3McWNWe4T+STGtWhrPNqJEn45sIcCx4\nq+kGZ2NQ0FyIyT2eiLKOX5Rgb/a36E/aMk4VoDsaenBQgG7WLTnstb9sr7MIhS6A\nrwIDAQAB\n-----END PUBLIC KEY-----\n", "Comment": "example public key" }
輸出:
{ "Location": "https://cloudfront.amazonaws.com/2019-03-26/public-key/KDFB19YGCR002", "ETag": "E2QWRUHEXAMPLE", "PublicKey": { "Id": "KDFB19YGCR002", "CreatedTime": "2019-12-05T18:51:43.781Z", "PublicKeyConfig": { "CallerReference": "cli-example", "Name": "ExampleKey", "EncodedKey": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxPMbCA2Ks0lnd7IR+3pw\nwd3H/7jPGwj8bLUmore7bX+oeGpZ6QmLAe/1UOWcmZX2u70dYcSIzB1ofZtcn4cJ\nenHBAzO3ohBY/L1tQGJfS2A+omnN6H16VZE1JCK8XSJyfze7MDLcUyHZETdxuvRb\nA9X343/vMAuQPnhinFJ8Wdy8YBXSPpy7r95ylUQd9LfYTBzVZYG2tSesplcOkjM3\n2Uu+oMWxQAw1NINnSLPinMVsutJy6ZqlV3McWNWe4T+STGtWhrPNqJEn45sIcCx4\nq+kGZ2NQ0FyIyT2eiLKOX5Rgb/a36E/aMk4VoDsaenBQgG7WLTnstb9sr7MIhS6A\nrwIDAQAB\n-----END PUBLIC KEY-----\n", "Comment": "example public key" } } }
-
如需API詳細資訊,請參閱 命令參考 CreatePublicKey
中的 。 AWS CLI
-
下列程式碼範例示範如何使用 delete-cloud-front-origin-access-identity
。
- AWS CLI
-
刪除 CloudFront 原始存取身分
下列範例會刪除 ID 為 的原始存取身分 (OAI)
E74FTE3AEXAMPLE
。若要刪除 OAI,您必須具有 OAI的 ID 和ETag
。OAI ID 會在 create-cloud-front-origin-access-identity 和 list-cloud-front-origin-access-identities 命令的輸出中傳回。若要取得ETag
,請使用 get-cloud-front-origin-access-identity 或 get-cloud-front-origin-access-identity-config mand。使用--if-match
選項提供 OAI的ETag
。aws cloudfront delete-cloud-front-origin-access-identity \ --id
E74FTE3AEXAMPLE
\ --if-matchE2QWRUHEXAMPLE
成功時,此命令沒有輸出。
-
如需API詳細資訊,請參閱 命令參考 DeleteCloudFrontOriginAccessIdentity
中的 。 AWS CLI
-
下列程式碼範例示範如何使用 delete-distribution
。
- AWS CLI
-
若要刪除 CloudFront 分佈
下列範例會刪除 ID 為 的 CloudFront 分佈
EDFDVBD6EXAMPLE
。您必須先停用分發,才能刪除分發。若要停用分佈,請使用 update-distribution 命令。如需詳細資訊,請參閱 update-distribution 範例。停用分佈時,您可以將其刪除。若要刪除分佈,您必須使用
--if-match
選項來提供分佈的ETag
。若要取得ETag
,請使用 get-distribution 或 get-distribution-config 命令。aws cloudfront delete-distribution \ --id
EDFDVBD6EXAMPLE
\ --if-matchE2QWRUHEXAMPLE
成功時,此命令沒有輸出。
-
如需API詳細資訊,請參閱 命令參考 DeleteDistribution
中的 。 AWS CLI
-
下列程式碼範例示範如何使用 delete-field-level-encryption-config
。
- AWS CLI
-
若要刪除 CloudFront 欄位層級加密組態
下列範例會刪除 ID 為 CloudFront 的欄位層級加密組態
C3KM2WVD605UAY
。若要刪除欄位層級加密組態,您必須具有其 ID 和ETag
。ID 會在 create-field-level-encryption-config 和 list-field-level-encryption-configs 命令的輸出中傳回。若要取得ETag
,請使用 get-field-level-encryption 或 get-field-level-encryption-config 命令。使用--if-match
選項提供組態的ETag
。aws cloudfront delete-field-level-encryption-config \ --id
C3KM2WVD605UAY
\ --if-matchE26M4BIAV81ZF6
成功時,此命令沒有輸出。
-
如需API詳細資訊,請參閱 命令參考 DeleteFieldLevelEncryptionConfig
中的 。 AWS CLI
-
下列程式碼範例示範如何使用 delete-field-level-encryption-profile
。
- AWS CLI
-
若要刪除 CloudFront 欄位層級加密設定檔
下列範例會刪除 ID 為 CloudFront 的欄位層級加密設定檔
PPK0UOSIF5WSV
。若要刪除欄位層級加密設定檔,您必須具有其 ID 和ETag
。ID 會在 create-field-level-encryption-profile 和 list-field-level-encryption-profiles 命令的輸出中傳回。若要取得ETag
,請使用 get-field-level-encryption-profile 或 get-field-level-encryption-profile-config 命令。使用--if-match
選項提供設定檔的ETag
。aws cloudfront delete-field-level-encryption-profile \ --id
PPK0UOSIF5WSV
\ --if-matchEJETYFJ9CL66D
成功時,此命令沒有輸出。
-
如需API詳細資訊,請參閱 命令參考 DeleteFieldLevelEncryptionProfile
中的 。 AWS CLI
-
下列程式碼範例示範如何使用 delete-public-key
。
- AWS CLI
-
若要刪除 CloudFront 公有金鑰
下列範例會刪除 ID 為 的 CloudFront 公有金鑰
KDFB19YGCR002
。若要刪除公有金鑰,您必須擁有其 ID 和ETag
。ID 會在 create-public-key 和 list-public-keys 命令的輸出中傳回。若要取得ETag
,請使用 get-public-key 或 get-public-key-config 命令。使用--if-match
選項提供公有金鑰的ETag
。aws cloudfront delete-public-key \ --id
KDFB19YGCR002
\ --if-matchE2QWRUHEXAMPLE
成功時,此命令沒有輸出。
-
如需API詳細資訊,請參閱 命令參考 DeletePublicKey
中的 。 AWS CLI
-
下列程式碼範例示範如何使用 get-cloud-front-origin-access-identity-config
。
- AWS CLI
-
若要取得 CloudFront 原始存取身分組態
下列範例會使用 ID 取得 CloudFront 來源存取身分 (OAI) 的中繼資料
E74FTE3AEXAMPLE
,包括其ETag
。OAI ID 會在 create-cloud-front-origin-access-identity 和 list-cloud-front-origin-access-identities 命令的輸出中傳回。aws cloudfront get-cloud-front-origin-access-identity-config --id
E74FTE3AEXAMPLE
輸出:
{ "ETag": "E2QWRUHEXAMPLE", "CloudFrontOriginAccessIdentityConfig": { "CallerReference": "cli-example", "Comment": "Example OAI" } }
-
如需API詳細資訊,請參閱 命令參考 GetCloudFrontOriginAccessIdentityConfig
中的 。 AWS CLI
-
下列程式碼範例示範如何使用 get-cloud-front-origin-access-identity
。
- AWS CLI
-
若要取得 CloudFront 原始存取身分
下列範例會取得具有 ID 的 CloudFront 原始存取身分 (OAI)
E74FTE3AEXAMPLE
,包括其ETag
和相關聯的 S3 正式 ID。OAI ID 會在 create-cloud-front-origin-access-identity 和 list-cloud-front-origin-access-identities 命令的輸出中傳回。aws cloudfront get-cloud-front-origin-access-identity --id
E74FTE3AEXAMPLE
輸出:
{ "ETag": "E2QWRUHEXAMPLE", "CloudFrontOriginAccessIdentity": { "Id": "E74FTE3AEXAMPLE", "S3CanonicalUserId": "cd13868f797c227fbea2830611a26fe0a21ba1b826ab4bed9b7771c9aEXAMPLE", "CloudFrontOriginAccessIdentityConfig": { "CallerReference": "cli-example", "Comment": "Example OAI" } } }
-
如需API詳細資訊,請參閱 命令參考 GetCloudFrontOriginAccessIdentity
中的 。 AWS CLI
-
下列程式碼範例示範如何使用 get-distribution-config
。
- AWS CLI
-
若要取得 CloudFront 分佈組態
下列範例會取得 ID 為 的 CloudFront 分佈中繼資料
EDFDVBD6EXAMPLE
,包括其ETag
。分佈 ID 會在 create-distribution 和 list-distributions 命令中傳回。aws cloudfront get-distribution-config --id
EDFDVBD6EXAMPLE
輸出:
{ "ETag": "E2QWRUHEXAMPLE", "DistributionConfig": { "CallerReference": "cli-example", "Aliases": { "Quantity": 0 }, "DefaultRootObject": "index.html", "Origins": { "Quantity": 1, "Items": [ { "Id": "awsexamplebucket---s3.amazonaws.com.rproxy.goskope.com-cli-example", "DomainName": "awsexamplebucket.s3.amazonaws.com", "OriginPath": "", "CustomHeaders": { "Quantity": 0 }, "S3OriginConfig": { "OriginAccessIdentity": "" } } ] }, "OriginGroups": { "Quantity": 0 }, "DefaultCacheBehavior": { "TargetOriginId": "awsexamplebucket---s3.amazonaws.com.rproxy.goskope.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 } }
-
如需API詳細資訊,請參閱 命令參考 GetDistributionConfig
中的 。 AWS CLI
-
下列程式碼範例示範如何使用 get-distribution
。
- AWS CLI
-
若要取得 CloudFront 分佈
下列範例會使用 ID 取得 CloudFront 分佈
EDFDVBD6EXAMPLE
,包括其ETag
。分佈 ID 會在 create-distribution 和 list-distributions 命令中傳回。aws cloudfront get-distribution --id
EDFDVBD6EXAMPLE
輸出:
{ "ETag": "E2QWRUHEXAMPLE", "Distribution": { "Id": "EDFDVBD6EXAMPLE", "ARN": "arn:aws:cloudfront::123456789012:distribution/EDFDVBD6EXAMPLE", "Status": "Deployed", "LastModifiedTime": "2019-12-04T23:35:41.433Z", "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.rproxy.goskope.com-cli-example", "DomainName": "awsexamplebucket.s3.amazonaws.com", "OriginPath": "", "CustomHeaders": { "Quantity": 0 }, "S3OriginConfig": { "OriginAccessIdentity": "" } } ] }, "OriginGroups": { "Quantity": 0 }, "DefaultCacheBehavior": { "TargetOriginId": "awsexamplebucket---s3.amazonaws.com.rproxy.goskope.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 } } }
-
如需API詳細資訊,請參閱 命令參考 GetDistribution
中的 。 AWS CLI
-
下列程式碼範例示範如何使用 get-field-level-encryption-config
。
- AWS CLI
-
若要取得 CloudFront 欄位層級加密組態的中繼資料
下列範例會使用 ID 取得有關 CloudFront 欄位層級加密組態的中繼資料
C3KM2WVD605UAY
,包括其ETag
:aws cloudfront get-field-level-encryption-config --id
C3KM2WVD605UAY
輸出:
{ "ETag": "E2P4Z4VU7TY5SG", "FieldLevelEncryptionConfig": { "CallerReference": "cli-example", "Comment": "Example FLE configuration", "QueryArgProfileConfig": { "ForwardWhenQueryArgProfileIsUnknown": true, "QueryArgProfiles": { "Quantity": 0, "Items": [] } }, "ContentTypeProfileConfig": { "ForwardWhenContentTypeIsUnknown": true, "ContentTypeProfiles": { "Quantity": 1, "Items": [ { "Format": "URLEncoded", "ProfileId": "P280MFCLSYOCVU", "ContentType": "application/x-www-form-urlencoded" } ] } } } }
-
如需API詳細資訊,請參閱 命令參考 GetFieldLevelEncryptionConfig
中的 。 AWS CLI
-
下列程式碼範例示範如何使用 get-field-level-encryption-profile-config
。
- AWS CLI
-
若要取得 CloudFront 欄位層級加密設定檔組態
下列範例取得 ID
PPK0UOSIF5WSV
為 之 CloudFront 欄位層級加密設定檔的中繼資料,包括其ETag
:aws cloudfront get-field-level-encryption-profile-config --id
PPK0UOSIF5WSV
輸出:
{ "ETag": "E1QQG65FS2L2GC", "FieldLevelEncryptionProfileConfig": { "Name": "ExampleFLEProfile", "CallerReference": "cli-example", "Comment": "FLE profile for AWS CLI example", "EncryptionEntities": { "Quantity": 1, "Items": [ { "PublicKeyId": "K2K8NC4HVFE3M0", "ProviderId": "ExampleFLEProvider", "FieldPatterns": { "Quantity": 1, "Items": [ "ExampleSensitiveField" ] } } ] } } }
-
如需API詳細資訊,請參閱 命令參考 GetFieldLevelEncryptionProfileConfig
中的 。 AWS CLI
-
下列程式碼範例示範如何使用 get-field-level-encryption-profile
。
- AWS CLI
-
若要取得 CloudFront 欄位層級加密設定檔
下列範例取得 ID 為
PPK0UOSIF5WSV
CloudFront 的欄位層級加密設定檔,包括其ETag
:aws cloudfront get-field-level-encryption-profile --id
PPK0UOSIF5WSV
輸出:
{ "ETag": "E1QQG65FS2L2GC", "FieldLevelEncryptionProfile": { "Id": "PPK0UOSIF5WSV", "LastModifiedTime": "2019-12-10T01:03:16.537Z", "FieldLevelEncryptionProfileConfig": { "Name": "ExampleFLEProfile", "CallerReference": "cli-example", "Comment": "FLE profile for AWS CLI example", "EncryptionEntities": { "Quantity": 1, "Items": [ { "PublicKeyId": "K2K8NC4HVFE3M0", "ProviderId": "ExampleFLEProvider", "FieldPatterns": { "Quantity": 1, "Items": [ "ExampleSensitiveField" ] } } ] } } } }
-
如需API詳細資訊,請參閱 命令參考 GetFieldLevelEncryptionProfile
中的 。 AWS CLI
-
下列程式碼範例示範如何使用 get-field-level-encryption
。
- AWS CLI
-
若要取得 CloudFront 欄位層級加密組態
下列範例使用 ID 取得 CloudFront 欄位層級加密組態
C3KM2WVD605UAY
,包括其ETag
:aws cloudfront get-field-level-encryption --id
C3KM2WVD605UAY
輸出:
{ "ETag": "E2P4Z4VU7TY5SG", "FieldLevelEncryption": { "Id": "C3KM2WVD605UAY", "LastModifiedTime": "2019-12-10T21:30:18.974Z", "FieldLevelEncryptionConfig": { "CallerReference": "cli-example", "Comment": "Example FLE configuration", "QueryArgProfileConfig": { "ForwardWhenQueryArgProfileIsUnknown": true, "QueryArgProfiles": { "Quantity": 0, "Items": [] } }, "ContentTypeProfileConfig": { "ForwardWhenContentTypeIsUnknown": true, "ContentTypeProfiles": { "Quantity": 1, "Items": [ { "Format": "URLEncoded", "ProfileId": "P280MFCLSYOCVU", "ContentType": "application/x-www-form-urlencoded" } ] } } } } }
-
如需API詳細資訊,請參閱 命令參考 GetFieldLevelEncryption
中的 。 AWS CLI
-
下列程式碼範例示範如何使用 get-invalidation
。
- AWS CLI
-
若要取得 CloudFront 無效
下列範例使用 ID 的
I2J0I21PCUYOIK
CloudFront 分佈 ID 取得無效EDFDVBD6EXAMPLE
:aws cloudfront get-invalidation --id
I2J0I21PCUYOIK
--distribution-idEDFDVBD6EXAMPLE
輸出:
{ "Invalidation": { "Status": "Completed", "InvalidationBatch": { "Paths": { "Items": [ "/example-path/example-file.jpg", "/example-path/example-file-2.jpg" ], "Quantity": 2 }, "CallerReference": "cli-example" }, "Id": "I2J0I21PCUYOIK", "CreateTime": "2019-12-05T18:40:49.413Z" } }
-
如需API詳細資訊,請參閱 命令參考 GetInvalidation
中的 。 AWS CLI
-
下列程式碼範例示範如何使用 get-public-key-config
。
- AWS CLI
-
若要取得 CloudFront 公有金鑰組態
下列範例會使用 ID 取得 CloudFront 公有金鑰的中繼資料
KDFB19YGCR002
,包括其ETag
。公有金鑰 ID 會在 create-public-key 和 list-public-keys 命令中傳回。aws cloudfront get-public-key-config --id
KDFB19YGCR002
輸出:
{ "ETag": "E2QWRUHEXAMPLE", "PublicKeyConfig": { "CallerReference": "cli-example", "Name": "ExampleKey", "EncodedKey": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxPMbCA2Ks0lnd7IR+3pw\nwd3H/7jPGwj8bLUmore7bX+oeGpZ6QmLAe/1UOWcmZX2u70dYcSIzB1ofZtcn4cJ\nenHBAzO3ohBY/L1tQGJfS2A+omnN6H16VZE1JCK8XSJyfze7MDLcUyHZETdxuvRb\nA9X343/vMAuQPnhinFJ8Wdy8YBXSPpy7r95ylUQd9LfYTBzVZYG2tSesplcOkjM3\n2Uu+oMWxQAw1NINnSLPinMVsutJy6ZqlV3McWNWe4T+STGtWhrPNqJEn45sIcCx4\nq+kGZ2NQ0FyIyT2eiLKOX5Rgb/a36E/aMk4VoDsaenBQgG7WLTnstb9sr7MIhS6A\nrwIDAQAB\n-----END PUBLIC KEY-----\n", "Comment": "example public key" } }
-
如需API詳細資訊,請參閱 命令參考 GetPublicKeyConfig
中的 。 AWS CLI
-
下列程式碼範例示範如何使用 get-public-key
。
- AWS CLI
-
若要取得 CloudFront 公有金鑰
下列範例會取得 ID 為 的 CloudFront 公有金鑰
KDFB19YGCR002
,包括其ETag
。公有金鑰 ID 會在 create-public-key 和 list-public-keys 命令中傳回。aws cloudfront get-public-key --id
KDFB19YGCR002
輸出:
{ "ETag": "E2QWRUHEXAMPLE", "PublicKey": { "Id": "KDFB19YGCR002", "CreatedTime": "2019-12-05T18:51:43.781Z", "PublicKeyConfig": { "CallerReference": "cli-example", "Name": "ExampleKey", "EncodedKey": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxPMbCA2Ks0lnd7IR+3pw\nwd3H/7jPGwj8bLUmore7bX+oeGpZ6QmLAe/1UOWcmZX2u70dYcSIzB1ofZtcn4cJ\nenHBAzO3ohBY/L1tQGJfS2A+omnN6H16VZE1JCK8XSJyfze7MDLcUyHZETdxuvRb\nA9X343/vMAuQPnhinFJ8Wdy8YBXSPpy7r95ylUQd9LfYTBzVZYG2tSesplcOkjM3\n2Uu+oMWxQAw1NINnSLPinMVsutJy6ZqlV3McWNWe4T+STGtWhrPNqJEn45sIcCx4\nq+kGZ2NQ0FyIyT2eiLKOX5Rgb/a36E/aMk4VoDsaenBQgG7WLTnstb9sr7MIhS6A\nrwIDAQAB\n-----END PUBLIC KEY-----\n", "Comment": "example public key" } } }
-
如需API詳細資訊,請參閱 命令參考 GetPublicKey
中的 。 AWS CLI
-
下列程式碼範例示範如何使用 list-cloud-front-origin-access-identities
。
- AWS CLI
-
列出 CloudFront 原始存取身分
下列範例會取得您 AWS 帳戶中 CloudFront 原始存取身分 (OAIs) 的清單:
aws cloudfront list-cloud-front-origin-access-identities
輸出:
{ "CloudFrontOriginAccessIdentityList": { "Items": [ { "Id": "E74FTE3AEXAMPLE", "S3CanonicalUserId": "cd13868f797c227fbea2830611a26fe0a21ba1b826ab4bed9b7771c9aEXAMPLE", "Comment": "Example OAI" }, { "Id": "EH1HDMBEXAMPLE", "S3CanonicalUserId": "1489f6f2e6faacaae7ff64c4c3e6956c24f78788abfc1718c3527c263bf7a17EXAMPLE", "Comment": "Test OAI" }, { "Id": "E2X2C9TEXAMPLE", "S3CanonicalUserId": "cbfeebb915a64749f9be546a45b3fcfd3a31c779673c13c4dd460911ae402c2EXAMPLE", "Comment": "Example OAI #2" } ] } }
-
如需API詳細資訊,請參閱 命令參考 ListCloudFrontOriginAccessIdentities
中的 。 AWS CLI
-
下列程式碼範例示範如何使用 list-distributions
。
- AWS CLI
-
列出 CloudFront 分佈
下列範例會取得您 AWS 帳戶中 CloudFront 分佈的清單:
aws cloudfront list-distributions
輸出:
{ "DistributionList": { "Items": [ { "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.rproxy.goskope.com-cli-example", "DomainName": "awsexamplebucket.s3.amazonaws.com", "OriginPath": "", "CustomHeaders": { "Quantity": 0 }, "S3OriginConfig": { "OriginAccessIdentity": "" } } ] }, "OriginGroups": { "Quantity": 0 }, "DefaultCacheBehavior": { "TargetOriginId": "awsexamplebucket---s3.amazonaws.com.rproxy.goskope.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 } }, { "Id": "EDFDVBD6EXAMPLE", "ARN": "arn:aws:cloudfront::123456789012:distribution/EDFDVBD6EXAMPLE", "Status": "InProgress", "LastModifiedTime": "2019-12-04T23:35:41.433Z", "InProgressInvalidationBatches": 0, "DomainName": "d930174dauwrn8.cloudfront.net", "ActiveTrustedSigners": { "Enabled": false, "Quantity": 0 }, "DistributionConfig": { "CallerReference": "cli-example", "Aliases": { "Quantity": 0 }, "DefaultRootObject": "index.html", "Origins": { "Quantity": 1, "Items": [ { "Id": "awsexamplebucket1---s3.amazonaws.com.rproxy.goskope.com-cli-example", "DomainName": "awsexamplebucket1.s3.amazonaws.com", "OriginPath": "", "CustomHeaders": { "Quantity": 0 }, "S3OriginConfig": { "OriginAccessIdentity": "" } } ] }, "OriginGroups": { "Quantity": 0 }, "DefaultCacheBehavior": { "TargetOriginId": "awsexamplebucket1---s3.amazonaws.com.rproxy.goskope.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 } }, { "Id": "E1X5IZQEXAMPLE", "ARN": "arn:aws:cloudfront::123456789012:distribution/E1X5IZQEXAMPLE", "Status": "Deployed", "LastModifiedTime": "2019-11-06T21:31:48.864Z", "DomainName": "d2e04y12345678.cloudfront.net", "Aliases": { "Quantity": 0 }, "Origins": { "Quantity": 1, "Items": [ { "Id": "awsexamplebucket2", "DomainName": "awsexamplebucket2.s3.us-west-2.amazonaws.com", "OriginPath": "", "CustomHeaders": { "Quantity": 0 }, "S3OriginConfig": { "OriginAccessIdentity": "" } } ] }, "OriginGroups": { "Quantity": 0 }, "DefaultCacheBehavior": { "TargetOriginId": "awsexamplebucket2", "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": "", "PriceClass": "PriceClass_All", "Enabled": true, "ViewerCertificate": { "CloudFrontDefaultCertificate": true, "MinimumProtocolVersion": "TLSv1", "CertificateSource": "cloudfront" }, "Restrictions": { "GeoRestriction": { "RestrictionType": "none", "Quantity": 0 } }, "WebACLId": "", "HttpVersion": "HTTP1_1", "IsIPV6Enabled": true } ] } }
-
如需API詳細資訊,請參閱 命令參考 ListDistributions
中的 。 AWS CLI
-
下列程式碼範例示範如何使用 list-field-level-encryption-configs
。
- AWS CLI
-
列出 CloudFront 欄位層級加密組態
下列範例會取得您 AWS 帳戶中 CloudFront 的欄位層級加密組態清單:
aws cloudfront list-field-level-encryption-configs
輸出:
{ "FieldLevelEncryptionList": { "MaxItems": 100, "Quantity": 1, "Items": [ { "Id": "C3KM2WVD605UAY", "LastModifiedTime": "2019-12-10T21:30:18.974Z", "Comment": "Example FLE configuration", "QueryArgProfileConfig": { "ForwardWhenQueryArgProfileIsUnknown": true, "QueryArgProfiles": { "Quantity": 0, "Items": [] } }, "ContentTypeProfileConfig": { "ForwardWhenContentTypeIsUnknown": true, "ContentTypeProfiles": { "Quantity": 1, "Items": [ { "Format": "URLEncoded", "ProfileId": "P280MFCLSYOCVU", "ContentType": "application/x-www-form-urlencoded" } ] } } } ] } }
-
如需API詳細資訊,請參閱 命令參考 ListFieldLevelEncryptionConfigs
中的 。 AWS CLI
-
下列程式碼範例示範如何使用 list-field-level-encryption-profiles
。
- AWS CLI
-
列出 CloudFront 欄位層級加密設定檔
下列範例會取得您 AWS 帳戶中 CloudFront 欄位層級加密設定檔的清單:
aws cloudfront list-field-level-encryption-profiles
輸出:
{ "FieldLevelEncryptionProfileList": { "MaxItems": 100, "Quantity": 2, "Items": [ { "Id": "P280MFCLSYOCVU", "LastModifiedTime": "2019-12-05T01:05:39.896Z", "Name": "ExampleFLEProfile", "EncryptionEntities": { "Quantity": 1, "Items": [ { "PublicKeyId": "K2K8NC4HVFE3M0", "ProviderId": "ExampleFLEProvider", "FieldPatterns": { "Quantity": 1, "Items": [ "ExampleSensitiveField" ] } } ] }, "Comment": "FLE profile for AWS CLI example" }, { "Id": "PPK0UOSIF5WSV", "LastModifiedTime": "2019-12-10T01:03:16.537Z", "Name": "ExampleFLEProfile2", "EncryptionEntities": { "Quantity": 1, "Items": [ { "PublicKeyId": "K2ABC10EXAMPLE", "ProviderId": "ExampleFLEProvider2", "FieldPatterns": { "Quantity": 1, "Items": [ "ExampleSensitiveField2" ] } } ] }, "Comment": "FLE profile #2 for AWS CLI example" } ] } }
-
如需API詳細資訊,請參閱 命令參考 ListFieldLevelEncryptionProfiles
中的 。 AWS CLI
-
下列程式碼範例示範如何使用 list-invalidations
。
- AWS CLI
-
列出 CloudFront 無效
下列範例會取得 ID 為 的 CloudFront分發失效清單
EDFDVBD6EXAMPLE
:aws cloudfront list-invalidations --distribution-id
EDFDVBD6EXAMPLE
輸出:
{ "InvalidationList": { "Marker": "", "Items": [ { "Status": "Completed", "Id": "YNY2LI2BVJ4NJU", "CreateTime": "2019-08-31T21:15:52.042Z" } ], "IsTruncated": false, "MaxItems": 100, "Quantity": 1 } }
-
如需API詳細資訊,請參閱 命令參考 ListInvalidations
中的 。 AWS CLI
-
下列程式碼範例示範如何使用 list-public-keys
。
- AWS CLI
-
列出 CloudFront 公有金鑰
下列範例會取得您 AWS 帳戶中 CloudFront 公有金鑰的清單:
aws cloudfront list-public-keys
輸出:
{ "PublicKeyList": { "MaxItems": 100, "Quantity": 2, "Items": [ { "Id": "K2K8NC4HVFE3M0", "Name": "ExampleKey", "CreatedTime": "2019-12-05T01:04:28.818Z", "EncodedKey": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxPMbCA2Ks0lnd7IR+3pw\nwd3H/7jPGwj8bLUmore7bX+oeGpZ6QmLAe/1UOWcmZX2u70dYcSIzB1ofZtcn4cJ\nenHBAzO3ohBY/L1tQGJfS2A+omnN6H16VZE1JCK8XSJyfze7MDLcUyHZETdxuvRb\nA9X343/vMAuQPnhinFJ8Wdy8YBXSPpy7r95ylUQd9LfYTBzVZYG2tSesplcOkjM3\n2Uu+oMWxQAw1NINnSLPinMVsutJy6ZqlV3McWNWe4T+STGtWhrPNqJEn45sIcCx4\nq+kGZ2NQ0FyIyT2eiLKOX5Rgb/a36E/aMk4VoDsaenBQgG7WLTnstb9sr7MIhS6A\nrwIDAQAB\n-----END PUBLIC KEY-----\n", "Comment": "example public key" }, { "Id": "K1S0LWQ2L5HTBU", "Name": "ExampleKey2", "CreatedTime": "2019-12-09T23:28:11.110Z", "EncodedKey": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApOCAg88A8+f4dujn9Izt\n26LxtgAkn2opGgo/NKpMiaisyw5qlg3f1gol7FV6pYNl78iJg3EO8JBbwtlH+cR9\nLGSf60NDeVhm76Oc39Np/vWgOdsGQcRbi9WmKZeSODqjQGzVZWqPmito3FzWVk6b\nfVY5N36U/RdbVAJm95Km+qaMYlbIdF40t72bi3IkKYV5hlB2XoDjlQ9F6ajQKyTB\nMHa3SN8q+3ZjQ4sJJ7D1V6r4wR8jDcFVD5NckWJmmgIVnkOQM37NYeoDnkaOuTpu\nha/+3b8tOb2z3LBVHPkp85zJRAOXacSwf5rZtPYKBNFsixTa2n55k2r218mOkMC4\nUwIDAQAB\n-----END PUBLIC KEY-----", "Comment": "example public key #2" } ] } }
-
如需API詳細資訊,請參閱 命令參考 ListPublicKeys
中的 。 AWS CLI
-
下列程式碼範例示範如何使用 list-tags-for-resource
。
- AWS CLI
-
列出 CloudFront 分佈的標籤
下列範例會取得 CloudFront 分佈的標籤清單:
aws cloudfront list-tags-for-resource \ --resource
arn:aws:cloudfront::123456789012:distribution/EDFDVBD6EXAMPLE
輸出:
{ "Tags": { "Items": [ { "Key": "DateCreated", "Value": "2019-12-04" }, { "Key": "Name", "Value": "Example name" }, { "Key": "Project", "Value": "Example project" } ] } }
-
如需API詳細資訊,請參閱 命令參考 ListTagsForResource
中的 。 AWS CLI
-
下列程式碼範例示範如何使用 sign
。
- AWS CLI
-
若要簽署 CloudFront URL
下列範例會簽署 CloudFront URL。若要簽署 URL,您需要金鑰對 ID (在 AWS 管理主控台中稱為存取金鑰 ID) 和受信任簽署者 CloudFront 金鑰對的私有金鑰。如需已簽署 的詳細資訊URLs,請參閱 Amazon CloudFront 開發人員指南 中的使用已簽署URLs和已簽署 Cookie 提供私有內容。
aws cloudfront sign \ --url
https://d111111abcdef8.cloudfront.net/private-content/private-file.html
\ --key-pair-idAPKAEIBAERJR2EXAMPLE
\ --private-keyfile://cf-signer-priv-key.pem
\ --date-less-than2020-01-01
輸出:
https://d111111abcdef8.cloudfront.net/private-content/private-file.html?Expires=1577836800&Signature=nEXK7Kby47XKeZQKVc6pwkif6oZc-JWSpDkH0UH7EBGGqvgurkecCbgL5VfUAXyLQuJxFwRQWscz-owcq9KpmewCXrXQbPaJZNi9XSNwf4YKurPDQYaRQawKoeenH0GFteRf9ELK-Bs3nljTLjtbgzIUt7QJNKXcWr8AuUYikzGdJ4-qzx6WnxXfH~fxg4-GGl6l2kgCpXUB6Jx6K~Y3kpVOdzUPOIqFLHAnJojbhxqrVejomZZ2XrquDvNUCCIbePGnR3d24UPaLXG4FKOqNEaWDIBXu7jUUPwOyQCvpt-GNvjRJxqWf93uMobeMOiVYahb-e0KItiQewGcm0eLZQ__&Key-Pair-Id=APKAEIBAERJR2EXAMPLE
-
如需API詳細資訊,請參閱登入
AWS CLI 命令參考 。
-
下列程式碼範例示範如何使用 tag-resource
。
- AWS CLI
-
標記 CloudFront 分佈
下列
tag-resource
範例會將兩個標籤新增至指定的 CloudFront 分佈。aws cloudfront tag-resource \ --resource
arn:aws:cloudfront::123456789012:distribution/EDFDVBD6EXAMPLE
\ --tags 'Items=[{Key=Name,Value="Example name"},{Key=Project,Value="Example project"}]
'您可以提供JSON檔案中的標籤,而不是使用命令列引數,如下列範例所示:
aws cloudfront tag-resource \ --resource
arn:aws:cloudfront::123456789012:distribution/EDFDVBD6EXAMPLE
\ --tagsfile://tags.json
tags.json
的內容:{ "Items": [ { "Key": "Name", "Value": "Example name" }, { "Key": "Project", "Value": "Example project" } ] }
此命令不會產生輸出。
-
如需API詳細資訊,請參閱 命令參考 TagResource
中的 。 AWS CLI
-
下列程式碼範例示範如何使用 untag-resource
。
- AWS CLI
-
從 CloudFront 分佈中移除標籤
下列範例使用命令列引數從 CloudFront 分佈中移除兩個標籤:
aws cloudfront untag-resource \ --resource
arn:aws:cloudfront::123456789012:distribution/EDFDVBD6EXAMPLE
\ --tag-keysItems=Name,Project
您可以提供JSON檔案中的標籤金鑰,而不是使用命令列引數,如下列範例所示:
aws cloudfront untag-resource \ --resource
arn:aws:cloudfront::123456789012:distribution/EDFDVBD6EXAMPLE
\ --tag-keysfile://tag-keys.json
檔案
tag-keys.json
是JSON目前資料夾中的文件,其中包含以下內容:{ "Items": [ "Name", "Project" ] }
成功時,此命令沒有輸出。
-
如需API詳細資訊,請參閱 命令參考 UntagResource
中的 。 AWS CLI
-
下列程式碼範例示範如何使用 update-cloud-front-origin-access-identity
。
- AWS CLI
-
更新 CloudFront 原始存取身分
下列範例會使用 ID 更新原始伺服器存取身分 (OAI)
E74FTE3AEXAMPLE
。您可以更新的唯一欄位是 OAI的Comment
。若要更新 OAI,您必須具有 OAI的 ID 和
ETag
。OAI ID 會在 create-cloud-front-origin-access-identity 和 list-cloud-front-origin-access-identities 命令的輸出中傳回。若要取得ETag
,請使用 get-cloud-front-origin-access-identity 或 get-cloud-front-origin-access-identity-config mand。使用--if-match
選項提供 OAI的ETag
。aws cloudfront update-cloud-front-origin-access-identity \ --id
E74FTE3AEXAMPLE
\ --if-matchE2QWRUHEXAMPLE
\ --cloud-front-origin-access-identity-config \ CallerReference=cli-example,Comment="Example OAI Updated"您可以透過在JSON檔案中提供OAI組態來完成相同的動作,如下列範例所示:
aws cloudfront update-cloud-front-origin-access-identity \ --id
E74FTE3AEXAMPLE
\ --if-matchE2QWRUHEXAMPLE
\ --cloud-front-origin-access-identity-configfile://OAI-config.json
檔案
OAI-config.json
是目前目錄中JSON的文件,其中包含以下內容:{ "CallerReference": "cli-example", "Comment": "Example OAI Updated" }
無論您是使用命令列引數或JSON檔案提供OAI組態,輸出都相同:
{ "ETag": "E9LHASXEXAMPLE", "CloudFrontOriginAccessIdentity": { "Id": "E74FTE3AEXAMPLE", "S3CanonicalUserId": "cd13868f797c227fbea2830611a26fe0a21ba1b826ab4bed9b7771c9aEXAMPLE", "CloudFrontOriginAccessIdentityConfig": { "CallerReference": "cli-example", "Comment": "Example OAI Updated" } } }
-
如需API詳細資訊,請參閱 命令參考 UpdateCloudFrontOriginAccessIdentity
中的 。 AWS CLI
-
下列程式碼範例示範如何使用 update-distribution
。
- AWS CLI
-
更新 CloudFront 分佈的預設根物件
下列範例會使用 ID 將預設根物件更新為
index.html
的CloudFront 分佈EDFDVBD6EXAMPLE
:aws cloudfront update-distribution --id
EDFDVBD6EXAMPLE
\ --default-root-objectindex.html
輸出:
{ "ETag": "E2QWRUHEXAMPLE", "Distribution": { "Id": "EDFDVBD6EXAMPLE", "ARN": "arn:aws:cloudfront::123456789012:distribution/EDFDVBD6EXAMPLE", "Status": "InProgress", "LastModifiedTime": "2019-12-06T18:55:39.870Z", "InProgressInvalidationBatches": 0, "DomainName": "d111111abcdef8.cloudfront.net", "ActiveTrustedSigners": { "Enabled": false, "Quantity": 0 }, "DistributionConfig": { "CallerReference": "6b10378d-49be-4c4b-a642-419ccaf8f3b5", "Aliases": { "Quantity": 0 }, "DefaultRootObject": "index.html", "Origins": { "Quantity": 1, "Items": [ { "Id": "example-website", "DomainName": "www.example.com", "OriginPath": "", "CustomHeaders": { "Quantity": 0 }, "CustomOriginConfig": { "HTTPPort": 80, "HTTPSPort": 443, "OriginProtocolPolicy": "match-viewer", "OriginSslProtocols": { "Quantity": 2, "Items": [ "SSLv3", "TLSv1" ] }, "OriginReadTimeout": 30, "OriginKeepaliveTimeout": 5 } } ] }, "OriginGroups": { "Quantity": 0 }, "DefaultCacheBehavior": { "TargetOriginId": "example-website", "ForwardedValues": { "QueryString": false, "Cookies": { "Forward": "none" }, "Headers": { "Quantity": 1, "Items": [ "*" ] }, "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": "http1.1", "IsIPV6Enabled": true } } }
更新 CloudFront 分佈
下列範例會在名為 的JSON檔案中提供 CloudFront 分佈組態,
EMLARXS9EXAMPLE
以停用 ID 的分佈dist-config-disable.json
。若要更新分佈,您必須使用--if-match
選項來提供分佈的ETag
。若要取得ETag
,請使用 get-distribution 或 get-distribution-config 命令。使用以下範例停用分佈之後,您可以使用 delete-distribution 命令將其刪除。
aws cloudfront update-distribution \ --id
EMLARXS9EXAMPLE
\ --if-matchE2QWRUHEXAMPLE
\ --distribution-configfile://dist-config-disable.json
檔案
dist-config-disable.json
是JSON目前資料夾中的文件,其中包含以下內容。請注意,Enabled
欄位設定為false
:{ "CallerReference": "cli-1574382155-496510", "Aliases": { "Quantity": 0 }, "DefaultRootObject": "index.html", "Origins": { "Quantity": 1, "Items": [ { "Id": "awsexamplebucket---s3.amazonaws.com.rproxy.goskope.com-1574382155-273939", "DomainName": "awsexamplebucket.s3.amazonaws.com", "OriginPath": "", "CustomHeaders": { "Quantity": 0 }, "S3OriginConfig": { "OriginAccessIdentity": "" } } ] }, "OriginGroups": { "Quantity": 0 }, "DefaultCacheBehavior": { "TargetOriginId": "awsexamplebucket---s3.amazonaws.com.rproxy.goskope.com-1574382155-273939", "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": false, "ViewerCertificate": { "CloudFrontDefaultCertificate": true, "MinimumProtocolVersion": "TLSv1", "CertificateSource": "cloudfront" }, "Restrictions": { "GeoRestriction": { "RestrictionType": "none", "Quantity": 0 } }, "WebACLId": "", "HttpVersion": "http2", "IsIPV6Enabled": true }
輸出:
{ "ETag": "E9LHASXEXAMPLE", "Distribution": { "Id": "EMLARXS9EXAMPLE", "ARN": "arn:aws:cloudfront::123456789012:distribution/EMLARXS9EXAMPLE", "Status": "InProgress", "LastModifiedTime": "2019-12-06T18:32:35.553Z", "InProgressInvalidationBatches": 0, "DomainName": "d111111abcdef8.cloudfront.net", "ActiveTrustedSigners": { "Enabled": false, "Quantity": 0 }, "DistributionConfig": { "CallerReference": "cli-1574382155-496510", "Aliases": { "Quantity": 0 }, "DefaultRootObject": "index.html", "Origins": { "Quantity": 1, "Items": [ { "Id": "awsexamplebucket---s3.amazonaws.com.rproxy.goskope.com-1574382155-273939", "DomainName": "awsexamplebucket.s3.amazonaws.com", "OriginPath": "", "CustomHeaders": { "Quantity": 0 }, "S3OriginConfig": { "OriginAccessIdentity": "" } } ] }, "OriginGroups": { "Quantity": 0 }, "DefaultCacheBehavior": { "TargetOriginId": "awsexamplebucket---s3.amazonaws.com.rproxy.goskope.com-1574382155-273939", "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": false, "ViewerCertificate": { "CloudFrontDefaultCertificate": true, "MinimumProtocolVersion": "TLSv1", "CertificateSource": "cloudfront" }, "Restrictions": { "GeoRestriction": { "RestrictionType": "none", "Quantity": 0 } }, "WebACLId": "", "HttpVersion": "http2", "IsIPV6Enabled": true } } }
-
如需API詳細資訊,請參閱 命令參考 UpdateDistribution
中的 。 AWS CLI
-
下列程式碼範例示範如何使用 update-field-level-encryption-config
。
- AWS CLI
-
更新 CloudFront 欄位層級加密組態
下列範例提供JSON檔案中的參數,
C3KM2WVD605UAY
以 ID 更新欄位層級加密組態Comment
的欄位。若要更新欄位層級加密組態,您必須具有組態的 ID 和
ETag
。ID 會在 create-field-level-encryption-config 和 list-field-level-encryption-configs 命令的輸出中傳回。若要取得ETag
,請使用 get-field-level-encryption 或 get-field-level-encryption-config 命令。使用--if-match
選項提供組態的ETag
。aws cloudfront update-field-level-encryption-config \ --id
C3KM2WVD605UAY
\ --if-matchE2P4Z4VU7TY5SG
\ --field-level-encryption-configfile://fle-config.json
檔案
fle-config.json
是目前目錄中JSON的文件,其中包含以下內容:{ "CallerReference": "cli-example", "Comment": "Updated example FLE configuration", "QueryArgProfileConfig": { "ForwardWhenQueryArgProfileIsUnknown": true, "QueryArgProfiles": { "Quantity": 0 } }, "ContentTypeProfileConfig": { "ForwardWhenContentTypeIsUnknown": true, "ContentTypeProfiles": { "Quantity": 1, "Items": [ { "Format": "URLEncoded", "ProfileId": "P280MFCLSYOCVU", "ContentType": "application/x-www-form-urlencoded" } ] } } }
輸出:
{ "ETag": "E26M4BIAV81ZF6", "FieldLevelEncryption": { "Id": "C3KM2WVD605UAY", "LastModifiedTime": "2019-12-10T22:26:26.170Z", "FieldLevelEncryptionConfig": { "CallerReference": "cli-example", "Comment": "Updated example FLE configuration", "QueryArgProfileConfig": { "ForwardWhenQueryArgProfileIsUnknown": true, "QueryArgProfiles": { "Quantity": 0, "Items": [] } }, "ContentTypeProfileConfig": { "ForwardWhenContentTypeIsUnknown": true, "ContentTypeProfiles": { "Quantity": 1, "Items": [ { "Format": "URLEncoded", "ProfileId": "P280MFCLSYOCVU", "ContentType": "application/x-www-form-urlencoded" } ] } } } } }
-
如需API詳細資訊,請參閱 命令參考 UpdateFieldLevelEncryptionConfig
中的 。 AWS CLI
-
下列程式碼範例示範如何使用 update-field-level-encryption-profile
。
- AWS CLI
-
更新 CloudFront 欄位層級加密設定檔
下列範例會使用 ID 更新欄位層級加密設定檔
PPK0UOSIF5WSV
。此範例會更新設定檔的Name
和Comment
,並透過在JSON檔案中提供參數來新增第二個FieldPatterns
項目。若要更新欄位層級加密設定檔,您必須具有設定檔的 ID 和
ETag
。ID 會在 create-field-level-encryption-profile 和 list-field-level-encryption-profiles 命令的輸出中傳回。若要取得ETag
,請使用 get-field-level-encryption-profile 或 get-field-level-encryption-profile-config 命令。使用--if-match
選項提供設定檔的ETag
。aws cloudfront update-field-level-encryption-profile \ --id
PPK0UOSIF5WSV
\ --if-matchE1QQG65FS2L2GC
\ --field-level-encryption-profile-configfile://fle-profile-config.json
檔案
fle-profile-config.json
是目前目錄中JSON的文件,其中包含以下內容:{ "Name": "ExampleFLEProfileUpdated", "CallerReference": "cli-example", "Comment": "Updated FLE profile for AWS CLI example", "EncryptionEntities": { "Quantity": 1, "Items": [ { "PublicKeyId": "K2K8NC4HVFE3M0", "ProviderId": "ExampleFLEProvider", "FieldPatterns": { "Quantity": 2, "Items": [ "ExampleSensitiveField", "SecondExampleSensitiveField" ] } } ] } }
輸出:
{ "ETag": "EJETYFJ9CL66D", "FieldLevelEncryptionProfile": { "Id": "PPK0UOSIF5WSV", "LastModifiedTime": "2019-12-10T19:05:58.296Z", "FieldLevelEncryptionProfileConfig": { "Name": "ExampleFLEProfileUpdated", "CallerReference": "cli-example", "Comment": "Updated FLE profile for AWS CLI example", "EncryptionEntities": { "Quantity": 1, "Items": [ { "PublicKeyId": "K2K8NC4HVFE3M0", "ProviderId": "ExampleFLEProvider", "FieldPatterns": { "Quantity": 2, "Items": [ "ExampleSensitiveField", "SecondExampleSensitiveField" ] } } ] } } } }
-
如需API詳細資訊,請參閱 命令參考 UpdateFieldLevelEncryptionProfile
中的 。 AWS CLI
-