Use GetCloudFrontOriginAccessIdentity with an Amazon SDK or CLI - Amazon CloudFront
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Use GetCloudFrontOriginAccessIdentity with an Amazon SDK or CLI

The following code examples show how to use GetCloudFrontOriginAccessIdentity.

CLI
Amazon CLI

To get a CloudFront origin access identity

The following example gets the CloudFront origin access identity (OAI) with the ID E74FTE3AEXAMPLE, including its ETag and the associated S3 canonical ID. The OAI ID is returned in the output of the create-cloud-front-origin-access-identity and list-cloud-front-origin-access-identities commands.

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" } } }
PowerShell
Tools for PowerShell

Example 1: This example returns a specific Amazon CloudFront origin access identity, specified by the -Id parameter. Although the -Id parameter is not required, if you do not specify it, no results are returned.

Get-CFCloudFrontOriginAccessIdentity -Id E3XXXXXXXXXXRT

Output:

CloudFrontOriginAccessIdentityConfig Id S3CanonicalUserId ------------------------------------ -- ----------------- Amazon.CloudFront.Model.CloudFrontOr... E3XXXXXXXXXXRT 4b6e...

For a complete list of Amazon SDK developer guides and code examples, see Using CloudFront with an Amazon SDK. This topic also includes information about getting started and details about previous SDK versions.