Access S3 data through an access grant - Amazon Simple Storage Service

Access S3 data through an access grant

After a grantee obtains temporary credentials through their access grant, they can use these temporary credentials to call Amazon S3 API operations to access your data.

Grantees can access S3 data by using the AWS Command Line Interface (AWS CLI), the AWS SDKs, and the Amazon S3 REST API.

After the grantee obtains their temporary credentials from S3 Access Grants, they can set up a profile with these credentials to retrieve the data.

To install the AWS CLI, see Installing the AWS CLI in the AWS Command Line Interface User Guide.

To use the following example commands, replace the user input placeholders with your own information.

Example – Set up a profile
aws configure set aws_access_key_id "$accessKey" --profile access-grants-consumer-access-profile aws configure set aws_secret_access_key "$secretKey" --profile access-grants-consumer-access-profile aws configure set aws_session_token "$sessionToken" --profile access-grants-consumer-access-profile

To use the following example command, replace the user input placeholders with your own information.

Example – Get the S3 data

The grantee can use the get-object AWS CLI command to access the data. The grantee can also use put-object, ls, and other S3 AWS CLI commands.

aws s3api get-object \ --bucket DOC-EXAMPLE-BUCKET1 \ --key myprefix \ --region us-east-2 \ --profile access-grants-consumer-access-profile

This section provides examples of how grantees can access your S3 data by using the AWS SDKs.

Java

For examples of how to get S3 data by using temporary credentials, see how to get an object by using the AWS SDKs and Amazon S3 code examples for the AWS SDK for Java 2.x.