CloudFront contoh menggunakan AWS CLI - AWS Command Line Interface

Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.

CloudFront contoh menggunakan AWS CLI

Contoh kode berikut menunjukkan cara melakukan tindakan dan mengimplementasikan skenario umum dengan menggunakan AWS Command Line Interface with CloudFront.

Tindakan adalah kutipan kode dari program yang lebih besar dan harus dijalankan dalam konteks. Sementara tindakan menunjukkan cara memanggil fungsi layanan individual, Anda dapat melihat tindakan dalam konteks dalam skenario terkait.

Setiap contoh menyertakan tautan ke kode sumber lengkap, di mana Anda dapat menemukan instruksi tentang cara mengatur dan menjalankan kode dalam konteks.

Tindakan

Contoh kode berikut menunjukkan cara menggunakancreate-cloud-front-origin-access-identity.

AWS CLI

Untuk membuat identitas akses CloudFront asal

Contoh berikut membuat identitas akses CloudFront asal (OAI) dengan menyediakan OAI konfigurasi sebagai argumen baris perintah:

aws cloudfront create-cloud-front-origin-access-identity \ --cloud-front-origin-access-identity-config \ CallerReference="cli-example",Comment="Example OAI"

Anda dapat mencapai hal yang sama dengan menyediakan OAI konfigurasi dalam JSON file, seperti yang ditunjukkan pada contoh berikut:

aws cloudfront create-cloud-front-origin-access-identity \ --cloud-front-origin-access-identity-config file://OAI-config.json

File OAI-config.json adalah JSON dokumen dalam direktori saat ini yang berisi berikut ini:

{ "CallerReference": "cli-example", "Comment": "Example OAI" }

Apakah Anda memberikan OAI konfigurasi dengan argumen baris perintah atau JSON file, outputnya sama:

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

Contoh kode berikut menunjukkan cara menggunakancreate-distribution-with-tags.

AWS CLI

Untuk membuat CloudFront distribusi dengan tag

Contoh berikut membuat distribusi dengan dua tag dengan menyediakan konfigurasi distribusi dan tag dalam JSON file bernamadist-config-with-tags.json:

aws cloudfront create-distribution-with-tags \ --distribution-config-with-tags file://dist-config-with-tags.json

File tersebut dist-config-with-tags.json adalah JSON dokumen di folder saat ini yang berisi yang berikut ini. Perhatikan Tags objek di bagian atas file, yang berisi dua tag:

Name = ExampleDistributionProject = 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-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 } }

Output:

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

Contoh kode berikut menunjukkan cara menggunakancreate-distribution.

AWS CLI

Untuk membuat CloudFront distribusi

Contoh berikut membuat distribusi untuk bucket S3 bernamaawsexamplebucket, dan juga menentukan index.html sebagai objek root default, menggunakan argumen baris perintah:

aws cloudfront create-distribution \ --origin-domain-name awsexamplebucket.s3.amazonaws.com \ --default-root-object index.html

Alih-alih menggunakan argumen baris perintah, Anda dapat memberikan konfigurasi distribusi dalam JSON file, seperti yang ditunjukkan pada contoh berikut:

aws cloudfront create-distribution \ --distribution-config file://dist-config.json

File tersebut dist-config.json adalah JSON dokumen di folder saat ini yang berisi berikut ini:

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

Apakah Anda memberikan informasi distribusi dengan argumen baris perintah atau JSON file, outputnya sama:

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

Contoh kode berikut menunjukkan cara menggunakancreate-field-level-encryption-config.

AWS CLI

Untuk membuat konfigurasi CloudFront enkripsi tingkat lapangan

Contoh berikut membuat konfigurasi enkripsi tingkat lapangan dengan menyediakan parameter konfigurasi dalam file bernamaJSON. fle-config.json Sebelum Anda dapat membuat konfigurasi enkripsi tingkat lapangan, Anda harus memiliki profil enkripsi tingkat lapangan. Untuk membuat profil, lihat perintah create-field-level-encryption -profile.

Untuk informasi selengkapnya tentang enkripsi CloudFront tingkat lapangan, lihat Menggunakan Enkripsi Tingkat Bidang untuk Membantu Melindungi Data Sensitif di Panduan Pengembang Amazon. CloudFront

aws cloudfront create-field-level-encryption-config \ --field-level-encryption-config file://fle-config.json

File tersebut fle-config.json adalah JSON dokumen di folder saat ini yang berisi berikut ini:

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

Output:

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

Contoh kode berikut menunjukkan cara menggunakancreate-field-level-encryption-profile.

AWS CLI

Untuk membuat profil CloudFront enkripsi tingkat lapangan

Contoh berikut membuat profil enkripsi tingkat lapangan dengan menyediakan parameter dalam file bernamaJSON. fle-profile-config.json Sebelum Anda dapat membuat profil enkripsi tingkat lapangan, Anda harus memiliki CloudFront kunci publik. Untuk membuat kunci CloudFront publik, lihat create-public-key perintah.

Untuk informasi selengkapnya tentang enkripsi CloudFront tingkat lapangan, lihat Menggunakan Enkripsi Tingkat Bidang untuk Membantu Melindungi Data Sensitif di Panduan Pengembang Amazon. CloudFront

aws cloudfront create-field-level-encryption-profile \ --field-level-encryption-profile-config file://fle-profile-config.json

File tersebut fle-profile-config.json adalah JSON dokumen di folder saat ini yang berisi berikut ini:

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

Output:

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

Contoh kode berikut menunjukkan cara menggunakancreate-invalidation.

AWS CLI

Untuk membuat pembatalan untuk distribusi CloudFront

create-invalidationContoh berikut membuat pembatalan untuk file tertentu dalam distribusi yang ditentukan CloudFront :

aws cloudfront create-invalidation \ --distribution-id EDFDVBD6EXAMPLE \ --paths "/example-path/example-file.jpg" "/example-path/example-file2.png"

Output:

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

Pada contoh sebelumnya, secara AWS CLI otomatis dihasilkan acakCallerReference. Untuk menentukan sendiriCallerReference, atau untuk menghindari meneruskan parameter pembatalan sebagai argumen baris perintah, Anda dapat menggunakan file. JSON Contoh berikut membuat pembatalan untuk dua file, dengan menyediakan parameter pembatalan dalam file bernama: JSON inv-batch.json

aws cloudfront create-invalidation \ --distribution-id EDFDVBD6EXAMPLE \ --invalidation-batch file://inv-batch.json

Isi dari inv-batch.json:

{ "Paths": { "Quantity": 2, "Items": [ "/example-path/example-file.jpg", "/example-path/example-file2.png" ] }, "CallerReference": "cli-example" }

Output:

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

Contoh kode berikut menunjukkan cara menggunakancreate-public-key.

AWS CLI

Untuk membuat kunci CloudFront publik

Contoh berikut membuat kunci CloudFront publik dengan menyediakan parameter dalam JSON file bernamapub-key-config.json. Sebelum Anda dapat menggunakan perintah ini, Anda harus memiliki kunci publik PEM -encoded. Untuk informasi selengkapnya, lihat Membuat Pasangan RSA Kunci di Panduan CloudFront Pengembang Amazon.

aws cloudfront create-public-key \ --public-key-config file://pub-key-config.json

File tersebut pub-key-config.json adalah JSON dokumen di folder saat ini yang berisi yang berikut ini. Perhatikan bahwa kunci publik dikodekan dalam PEM format.

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

Output:

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

Contoh kode berikut menunjukkan cara menggunakandelete-cloud-front-origin-access-identity.

AWS CLI

Untuk menghapus identitas akses CloudFront asal

Contoh berikut menghapus identitas akses asal (OAI) dengan IDE74FTE3AEXAMPLE. Untuk menghapusOAI, Anda harus memiliki ID danETag. OAI OAIID dikembalikan dalam output perintah create-cloud-front-origin -access-identity dan list-cloud-front-origin -access-identities. Untuk mendapatkanETag, gunakan perintah get-cloud-front-origin -access-identity atau get-cloud-front-origin -. access-identity-config Gunakan --if-match opsi untuk menyediakan OAI'sETag.

aws cloudfront delete-cloud-front-origin-access-identity \ --id E74FTE3AEXAMPLE \ --if-match E2QWRUHEXAMPLE

Ketika berhasil, perintah ini tidak memiliki output.

Contoh kode berikut menunjukkan cara menggunakandelete-distribution.

AWS CLI

Untuk menghapus CloudFront distribusi

Contoh berikut menghapus CloudFront distribusi dengan IDEDFDVBD6EXAMPLE. Sebelum Anda dapat menghapus distribusi, Anda harus menonaktifkannya. Untuk menonaktifkan distribusi, gunakan perintah pembaruan-distribusi. Untuk informasi selengkapnya, lihat contoh distribusi pembaruan.

Ketika distribusi dinonaktifkan, Anda dapat menghapusnya. Untuk menghapus distribusi, Anda harus menggunakan --if-match opsi untuk menyediakan distribusiETag. Untuk mendapatkanETag, gunakan get-distribusi atau get-distribution-config perintah.

aws cloudfront delete-distribution \ --id EDFDVBD6EXAMPLE \ --if-match E2QWRUHEXAMPLE

Ketika berhasil, perintah ini tidak memiliki output.

Contoh kode berikut menunjukkan cara menggunakandelete-field-level-encryption-config.

AWS CLI

Untuk menghapus konfigurasi CloudFront enkripsi tingkat lapangan

Contoh berikut menghapus konfigurasi enkripsi CloudFront tingkat lapangan dengan ID. C3KM2WVD605UAY Untuk menghapus konfigurasi enkripsi tingkat lapangan, Anda harus memiliki ID dan. ETag ID dikembalikan dalam output perintah create-field-level-encryption -config dan list-field-level-encryption -configs. Untuk mendapatkanETag, gunakan perintah get-field-level-encryption or get-field-level-encryption -config. Gunakan --if-match opsi untuk menyediakan konfigurasiETag.

aws cloudfront delete-field-level-encryption-config \ --id C3KM2WVD605UAY \ --if-match E26M4BIAV81ZF6

Ketika berhasil, perintah ini tidak memiliki output.

Contoh kode berikut menunjukkan cara menggunakandelete-field-level-encryption-profile.

AWS CLI

Untuk menghapus profil CloudFront enkripsi tingkat lapangan

Contoh berikut menghapus profil enkripsi CloudFront tingkat lapangan dengan ID. PPK0UOSIF5WSV Untuk menghapus profil enkripsi tingkat lapangan, Anda harus memiliki ID dan. ETag ID dikembalikan dalam output perintah create-field-level-encryption -profile dan list-field-level-encryption -profiles. Untuk mendapatkanETag, gunakan perintah get-field-level-encryption -profile atau get-field-level-encryption -profile-config. Gunakan --if-match opsi untuk menyediakan profilETag.

aws cloudfront delete-field-level-encryption-profile \ --id PPK0UOSIF5WSV \ --if-match EJETYFJ9CL66D

Ketika berhasil, perintah ini tidak memiliki output.

Contoh kode berikut menunjukkan cara menggunakandelete-public-key.

AWS CLI

Untuk menghapus kunci CloudFront publik

Contoh berikut menghapus kunci CloudFront publik dengan IDKDFB19YGCR002. Untuk menghapus kunci publik, Anda harus memiliki ID danETag. ID dikembalikan dalam output list-public-keys perintah create-public-key dan. Untuk mendapatkanETag, gunakan get-public-key-config perintah get-public-key or. Gunakan --if-match opsi untuk menyediakan kunci publikETag.

aws cloudfront delete-public-key \ --id KDFB19YGCR002 \ --if-match E2QWRUHEXAMPLE

Ketika berhasil, perintah ini tidak memiliki output.

Contoh kode berikut menunjukkan cara menggunakanget-cloud-front-origin-access-identity-config.

AWS CLI

Untuk mendapatkan konfigurasi identitas akses CloudFront asal

Contoh berikut mendapatkan metadata tentang identitas akses CloudFront asal (OAI) dengan IDE74FTE3AEXAMPLE, termasuk nya. ETag OAIID dikembalikan dalam output perintah create-cloud-front-origin -access-identity dan list-cloud-front-origin -access-identities.

aws cloudfront get-cloud-front-origin-access-identity-config --id E74FTE3AEXAMPLE

Output:

{ "ETag": "E2QWRUHEXAMPLE", "CloudFrontOriginAccessIdentityConfig": { "CallerReference": "cli-example", "Comment": "Example OAI" } }

Contoh kode berikut menunjukkan cara menggunakanget-cloud-front-origin-access-identity.

AWS CLI

Untuk mendapatkan identitas akses CloudFront asal

Contoh berikut mendapatkan identitas akses CloudFront asal (OAI) dengan IDE74FTE3AEXAMPLE, termasuk ID kanonik ETag dan S3 terkait. OAIID dikembalikan dalam output perintah create-cloud-front-origin -access-identity dan list-cloud-front-origin -access-identities.

aws cloudfront get-cloud-front-origin-access-identity --id E74FTE3AEXAMPLE

Output:

{ "ETag": "E2QWRUHEXAMPLE", "CloudFrontOriginAccessIdentity": { "Id": "E74FTE3AEXAMPLE", "S3CanonicalUserId": "cd13868f797c227fbea2830611a26fe0a21ba1b826ab4bed9b7771c9aEXAMPLE", "CloudFrontOriginAccessIdentityConfig": { "CallerReference": "cli-example", "Comment": "Example OAI" } } }

Contoh kode berikut menunjukkan cara menggunakanget-distribution-config.

AWS CLI

Untuk mendapatkan konfigurasi CloudFront distribusi

Contoh berikut mendapatkan metadata tentang CloudFront distribusi dengan IDEDFDVBD6EXAMPLE, termasuk nya. ETag ID distribusi dikembalikan dalam perintah create-distribution dan list-distributions.

aws cloudfront get-distribution-config --id EDFDVBD6EXAMPLE

Output:

{ "ETag": "E2QWRUHEXAMPLE", "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 } }

Contoh kode berikut menunjukkan cara menggunakanget-distribution.

AWS CLI

Untuk mendapatkan CloudFront distribusi

Contoh berikut mendapatkan CloudFront distribusi dengan IDEDFDVBD6EXAMPLE, termasuk nyaETag. ID distribusi dikembalikan dalam perintah create-distribution dan list-distributions.

aws cloudfront get-distribution --id EDFDVBD6EXAMPLE

Output:

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

Contoh kode berikut menunjukkan cara menggunakanget-field-level-encryption-config.

AWS CLI

Untuk mendapatkan metadata tentang konfigurasi enkripsi tingkat CloudFront lapangan

Contoh berikut mendapatkan metadata tentang konfigurasi enkripsi CloudFront tingkat lapangan dengan ID, termasuk: C3KM2WVD605UAY ETag

aws cloudfront get-field-level-encryption-config --id C3KM2WVD605UAY

Output:

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

Contoh kode berikut menunjukkan cara menggunakanget-field-level-encryption-profile-config.

AWS CLI

Untuk mendapatkan konfigurasi CloudFront profil enkripsi tingkat lapangan

Contoh berikut mendapatkan metadata tentang profil enkripsi CloudFront tingkat lapangan dengan ID, termasuk: PPK0UOSIF5WSV ETag

aws cloudfront get-field-level-encryption-profile-config --id PPK0UOSIF5WSV

Output:

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

Contoh kode berikut menunjukkan cara menggunakanget-field-level-encryption-profile.

AWS CLI

Untuk mendapatkan profil CloudFront enkripsi tingkat lapangan

Contoh berikut mendapatkan profil enkripsi CloudFront tingkat lapangan dengan IDPPK0UOSIF5WSV, termasuk: ETag

aws cloudfront get-field-level-encryption-profile --id PPK0UOSIF5WSV

Output:

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

Contoh kode berikut menunjukkan cara menggunakanget-field-level-encryption.

AWS CLI

Untuk mendapatkan konfigurasi CloudFront enkripsi tingkat lapangan

Contoh berikut mendapatkan konfigurasi enkripsi CloudFront tingkat lapangan dengan IDC3KM2WVD605UAY, termasuk: ETag

aws cloudfront get-field-level-encryption --id C3KM2WVD605UAY

Output:

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

Contoh kode berikut menunjukkan cara menggunakanget-invalidation.

AWS CLI

Untuk mendapatkan CloudFront pembatalan

Contoh berikut mendapatkan pembatalan dengan ID I2J0I21PCUYOIK untuk CloudFront distribusi dengan ID: EDFDVBD6EXAMPLE

aws cloudfront get-invalidation --id I2J0I21PCUYOIK --distribution-id EDFDVBD6EXAMPLE

Output:

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

Contoh kode berikut menunjukkan cara menggunakanget-public-key-config.

AWS CLI

Untuk mendapatkan konfigurasi kunci CloudFront publik

Contoh berikut mendapatkan metadata tentang kunci CloudFront publik dengan IDKDFB19YGCR002, termasuk nya. ETag ID kunci publik dikembalikan dalam list-public-keys perintah create-public-key and.

aws cloudfront get-public-key-config --id KDFB19YGCR002

Output:

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

Contoh kode berikut menunjukkan cara menggunakanget-public-key.

AWS CLI

Untuk mendapatkan kunci CloudFront publik

Contoh berikut mendapatkan kunci CloudFront publik dengan IDKDFB19YGCR002, termasuk nyaETag. ID kunci publik dikembalikan dalam list-public-keys perintah create-public-key and.

aws cloudfront get-public-key --id KDFB19YGCR002

Output:

{ "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" } } }
  • Untuk API detailnya, lihat GetPublicKeydi Referensi AWS CLI Perintah.

Contoh kode berikut menunjukkan cara menggunakanlist-cloud-front-origin-access-identities.

AWS CLI

Untuk mencantumkan identitas akses CloudFront asal

Contoh berikut mendapatkan daftar identitas akses CloudFront asal (OAIs) di AWS akun Anda:

aws cloudfront list-cloud-front-origin-access-identities

Output:

{ "CloudFrontOriginAccessIdentityList": { "Items": [ { "Id": "E74FTE3AEXAMPLE", "S3CanonicalUserId": "cd13868f797c227fbea2830611a26fe0a21ba1b826ab4bed9b7771c9aEXAMPLE", "Comment": "Example OAI" }, { "Id": "EH1HDMBEXAMPLE", "S3CanonicalUserId": "1489f6f2e6faacaae7ff64c4c3e6956c24f78788abfc1718c3527c263bf7a17EXAMPLE", "Comment": "Test OAI" }, { "Id": "E2X2C9TEXAMPLE", "S3CanonicalUserId": "cbfeebb915a64749f9be546a45b3fcfd3a31c779673c13c4dd460911ae402c2EXAMPLE", "Comment": "Example OAI #2" } ] } }

Contoh kode berikut menunjukkan cara menggunakanlist-distributions.

AWS CLI

Untuk daftar CloudFront distribusi

Contoh berikut mendapatkan daftar CloudFront distribusi di AWS akun Anda:

aws cloudfront list-distributions

Output:

{ "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-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 } }, { "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-cli-example", "DomainName": "awsexamplebucket1.s3.amazonaws.com", "OriginPath": "", "CustomHeaders": { "Quantity": 0 }, "S3OriginConfig": { "OriginAccessIdentity": "" } } ] }, "OriginGroups": { "Quantity": 0 }, "DefaultCacheBehavior": { "TargetOriginId": "awsexamplebucket1.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 } }, { "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 } ] } }

Contoh kode berikut menunjukkan cara menggunakanlist-field-level-encryption-configs.

AWS CLI

Untuk membuat daftar konfigurasi CloudFront enkripsi tingkat lapangan

Contoh berikut mendapatkan daftar konfigurasi enkripsi CloudFront tingkat bidang di akun Anda: AWS

aws cloudfront list-field-level-encryption-configs

Output:

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

Contoh kode berikut menunjukkan cara menggunakanlist-field-level-encryption-profiles.

AWS CLI

Untuk membuat daftar profil CloudFront enkripsi tingkat lapangan

Contoh berikut mendapatkan daftar profil enkripsi CloudFront tingkat bidang di akun Anda: AWS

aws cloudfront list-field-level-encryption-profiles

Output:

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

Contoh kode berikut menunjukkan cara menggunakanlist-invalidations.

AWS CLI

Untuk daftar CloudFront pembatalan

Contoh berikut mendapatkan daftar pembatalan untuk CloudFront distribusi dengan ID: EDFDVBD6EXAMPLE

aws cloudfront list-invalidations --distribution-id EDFDVBD6EXAMPLE

Output:

{ "InvalidationList": { "Marker": "", "Items": [ { "Status": "Completed", "Id": "YNY2LI2BVJ4NJU", "CreateTime": "2019-08-31T21:15:52.042Z" } ], "IsTruncated": false, "MaxItems": 100, "Quantity": 1 } }

Contoh kode berikut menunjukkan cara menggunakanlist-public-keys.

AWS CLI

Untuk daftar kunci CloudFront publik

Contoh berikut mendapatkan daftar kunci CloudFront publik di AWS akun Anda:

aws cloudfront list-public-keys

Output:

{ "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" } ] } }
  • Untuk API detailnya, lihat ListPublicKeysdi Referensi AWS CLI Perintah.

Contoh kode berikut menunjukkan cara menggunakanlist-tags-for-resource.

AWS CLI

Untuk daftar tag untuk CloudFront distribusi

Contoh berikut mendapat daftar tag untuk CloudFront distribusi:

aws cloudfront list-tags-for-resource \ --resource arn:aws:cloudfront::123456789012:distribution/EDFDVBD6EXAMPLE

Output:

{ "Tags": { "Items": [ { "Key": "DateCreated", "Value": "2019-12-04" }, { "Key": "Name", "Value": "Example name" }, { "Key": "Project", "Value": "Example project" } ] } }

Contoh kode berikut menunjukkan cara menggunakansign.

AWS CLI

Untuk menandatangani CloudFront URL

Contoh berikut tanda a CloudFront URL. Untuk menandatanganiURL, Anda memerlukan ID key pair (disebut ID Kunci Akses di Konsol AWS Manajemen) dan kunci pribadi dari CloudFront key pair penandatangan tepercaya. Untuk informasi selengkapnya tentang ditandatanganiURLs, lihat Menyajikan Konten Pribadi dengan Cookie yang Ditandatangani URLs dan Ditandatangani di Panduan CloudFront Pengembang Amazon.

aws cloudfront sign \ --url https://d111111abcdef8.cloudfront.net/private-content/private-file.html \ --key-pair-id APKAEIBAERJR2EXAMPLE \ --private-key file://cf-signer-priv-key.pem \ --date-less-than 2020-01-01

Output:

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
  • Untuk API detailnya, lihat Referensi AWS CLI Perintah Masuk.

Contoh kode berikut menunjukkan cara menggunakantag-resource.

AWS CLI

Untuk menandai CloudFront distribusi

tag-resourceContoh berikut menambahkan dua tag ke CloudFront distribusi yang ditentukan.

aws cloudfront tag-resource \ --resource arn:aws:cloudfront::123456789012:distribution/EDFDVBD6EXAMPLE \ --tags 'Items=[{Key=Name,Value="Example name"},{Key=Project,Value="Example project"}]'

Alih-alih menggunakan argumen baris perintah, Anda dapat memberikan tag dalam JSON file, seperti yang ditunjukkan pada contoh berikut:

aws cloudfront tag-resource \ --resource arn:aws:cloudfront::123456789012:distribution/EDFDVBD6EXAMPLE \ --tags file://tags.json

Isi dari tags.json:

{ "Items": [ { "Key": "Name", "Value": "Example name" }, { "Key": "Project", "Value": "Example project" } ] }

Perintah ini tidak menghasilkan output.

  • Untuk API detailnya, lihat TagResourcedi Referensi AWS CLI Perintah.

Contoh kode berikut menunjukkan cara menggunakanuntag-resource.

AWS CLI

Untuk menghapus tag dari CloudFront distribusi

Contoh berikut menghapus dua tag dari CloudFront distribusi dengan menggunakan argumen baris perintah:

aws cloudfront untag-resource \ --resource arn:aws:cloudfront::123456789012:distribution/EDFDVBD6EXAMPLE \ --tag-keys Items=Name,Project

Alih-alih menggunakan argumen baris perintah, Anda dapat memberikan kunci tag dalam JSON file, seperti yang ditunjukkan pada contoh berikut:

aws cloudfront untag-resource \ --resource arn:aws:cloudfront::123456789012:distribution/EDFDVBD6EXAMPLE \ --tag-keys file://tag-keys.json

File tersebut tag-keys.json adalah JSON dokumen di folder saat ini yang berisi berikut ini:

{ "Items": [ "Name", "Project" ] }

Ketika berhasil, perintah ini tidak memiliki output.

  • Untuk API detailnya, lihat UntagResourcedi Referensi AWS CLI Perintah.

Contoh kode berikut menunjukkan cara menggunakanupdate-cloud-front-origin-access-identity.

AWS CLI

Untuk memperbarui identitas akses CloudFront asal

Contoh berikut memperbarui identitas akses asal (OAI) dengan IDE74FTE3AEXAMPLE. Satu-satunya bidang yang dapat Anda perbarui adalah OAI'sComment.

Untuk memperbaruiOAI, Anda harus memiliki ID danETag. OAI OAIID dikembalikan dalam output perintah create-cloud-front-origin -access-identity dan list-cloud-front-origin -access-identities. Untuk mendapatkanETag, gunakan perintah get-cloud-front-origin -access-identity atau get-cloud-front-origin -. access-identity-config Gunakan --if-match opsi untuk menyediakan OAI'sETag.

aws cloudfront update-cloud-front-origin-access-identity \ --id E74FTE3AEXAMPLE \ --if-match E2QWRUHEXAMPLE \ --cloud-front-origin-access-identity-config \ CallerReference=cli-example,Comment="Example OAI Updated"

Anda dapat mencapai hal yang sama dengan menyediakan OAI konfigurasi dalam JSON file, seperti yang ditunjukkan pada contoh berikut:

aws cloudfront update-cloud-front-origin-access-identity \ --id E74FTE3AEXAMPLE \ --if-match E2QWRUHEXAMPLE \ --cloud-front-origin-access-identity-config file://OAI-config.json

File OAI-config.json adalah JSON dokumen dalam direktori saat ini yang berisi berikut ini:

{ "CallerReference": "cli-example", "Comment": "Example OAI Updated" }

Apakah Anda memberikan OAI konfigurasi dengan argumen baris perintah atau JSON file, outputnya sama:

{ "ETag": "E9LHASXEXAMPLE", "CloudFrontOriginAccessIdentity": { "Id": "E74FTE3AEXAMPLE", "S3CanonicalUserId": "cd13868f797c227fbea2830611a26fe0a21ba1b826ab4bed9b7771c9aEXAMPLE", "CloudFrontOriginAccessIdentityConfig": { "CallerReference": "cli-example", "Comment": "Example OAI Updated" } } }

Contoh kode berikut menunjukkan cara menggunakanupdate-distribution.

AWS CLI

Untuk memperbarui objek root default CloudFront distribusi

Contoh berikut memperbarui objek root default index.html untuk CloudFront distribusi dengan IDEDFDVBD6EXAMPLE:

aws cloudfront update-distribution --id EDFDVBD6EXAMPLE \ --default-root-object index.html

Output:

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

Untuk memperbarui CloudFront distribusi

Contoh berikut menonaktifkan CloudFront distribusi dengan ID EMLARXS9EXAMPLE dengan menyediakan konfigurasi distribusi dalam JSON file bernamadist-config-disable.json. Untuk memperbarui distribusi, Anda harus menggunakan --if-match opsi untuk menyediakan distribusiETag. Untuk mendapatkanETag, gunakan get-distribusi atau get-distribution-config perintah.

Setelah Anda menggunakan contoh berikut untuk menonaktifkan distribusi, Anda dapat menggunakan perintah hapus-distribusi untuk menghapusnya.

aws cloudfront update-distribution \ --id EMLARXS9EXAMPLE \ --if-match E2QWRUHEXAMPLE \ --distribution-config file://dist-config-disable.json

File tersebut dist-config-disable.json adalah JSON dokumen di folder saat ini yang berisi yang berikut ini. Perhatikan bahwa Enabled bidang diatur kefalse:

{ "CallerReference": "cli-1574382155-496510", "Aliases": { "Quantity": 0 }, "DefaultRootObject": "index.html", "Origins": { "Quantity": 1, "Items": [ { "Id": "awsexamplebucket.s3.amazonaws.com-1574382155-273939", "DomainName": "awsexamplebucket.s3.amazonaws.com", "OriginPath": "", "CustomHeaders": { "Quantity": 0 }, "S3OriginConfig": { "OriginAccessIdentity": "" } } ] }, "OriginGroups": { "Quantity": 0 }, "DefaultCacheBehavior": { "TargetOriginId": "awsexamplebucket.s3.amazonaws.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 }

Output:

{ "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-1574382155-273939", "DomainName": "awsexamplebucket.s3.amazonaws.com", "OriginPath": "", "CustomHeaders": { "Quantity": 0 }, "S3OriginConfig": { "OriginAccessIdentity": "" } } ] }, "OriginGroups": { "Quantity": 0 }, "DefaultCacheBehavior": { "TargetOriginId": "awsexamplebucket.s3.amazonaws.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 } } }

Contoh kode berikut menunjukkan cara menggunakanupdate-field-level-encryption-config.

AWS CLI

Untuk memperbarui konfigurasi CloudFront enkripsi tingkat lapangan

Contoh berikut memperbarui Comment bidang konfigurasi enkripsi tingkat lapangan dengan ID C3KM2WVD605UAY dengan menyediakan parameter dalam file. JSON

Untuk memperbarui konfigurasi enkripsi tingkat lapangan, Anda harus memiliki ID konfigurasi dan. ETag ID dikembalikan dalam output perintah create-field-level-encryption -config dan list-field-level-encryption -configs. Untuk mendapatkanETag, gunakan perintah get-field-level-encryption or get-field-level-encryption -config. Gunakan --if-match opsi untuk menyediakan konfigurasiETag.

aws cloudfront update-field-level-encryption-config \ --id C3KM2WVD605UAY \ --if-match E2P4Z4VU7TY5SG \ --field-level-encryption-config file://fle-config.json

File fle-config.json adalah JSON dokumen dalam direktori saat ini yang berisi berikut ini:

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

Output:

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

Contoh kode berikut menunjukkan cara menggunakanupdate-field-level-encryption-profile.

AWS CLI

Untuk memperbarui profil CloudFront enkripsi tingkat lapangan

Contoh berikut memperbarui profil enkripsi tingkat lapangan dengan ID. PPK0UOSIF5WSV Contoh ini memperbarui profil Name danComment, dan menambahkan FieldPatterns item kedua, dengan menyediakan parameter dalam JSON file.

Untuk memperbarui profil enkripsi tingkat lapangan, Anda harus memiliki ID profil dan. ETag ID dikembalikan dalam output perintah create-field-level-encryption -profile dan list-field-level-encryption -profiles. Untuk mendapatkanETag, gunakan perintah get-field-level-encryption -profile atau get-field-level-encryption -profile-config. Gunakan --if-match opsi untuk menyediakan profilETag.

aws cloudfront update-field-level-encryption-profile \ --id PPK0UOSIF5WSV \ --if-match E1QQG65FS2L2GC \ --field-level-encryption-profile-config file://fle-profile-config.json

File fle-profile-config.json adalah JSON dokumen dalam direktori saat ini yang berisi berikut ini:

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

Output:

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