Forrest logo
back to the aws tool

aws-s3-presign:tldr:08062

aws-s3-presign: Generate a pre-signed URL valid for a specific lifetime.
$ aws s3 presign s3://${bucket_name}/${filename} --expires-in ${duration_in_seconds}
try on your machine

The command aws s3 presign is used in the AWS Command-Line Interface (CLI) to generate a pre-signed URL for downloading or uploading a file in an Amazon Simple Storage Service (S3) bucket. A pre-signed URL is a URL that grants temporary access to an S3 object, allowing users to perform specific actions on the object within a specified time period.

The command syntax is as follows:

aws s3 presign s3://${bucket_name}/${filename} --expires-in ${duration_in_seconds}

Here's the breakdown of the command:

  • aws s3 presign: This is the base command for generating a pre-signed URL.
  • s3://${bucket_name}/${filename}: This specifies the S3 bucket and the path to the file for which you want to generate a pre-signed URL.
    • ${bucket_name}: Replace this placeholder with the actual name of the S3 bucket.
    • ${filename}: Replace this placeholder with the name or path of the file within the bucket.
  • --expires-in ${duration_in_seconds}: This sets the expiration time for the generated pre-signed URL. The ${duration_in_seconds} placeholder should be replaced with a numerical value indicating the duration for which the URL will remain valid (in seconds).

When you run this command, AWS CLI will generate a pre-signed URL that allows temporary access to the specified file in the S3 bucket. You can then use this URL to perform actions like downloading or uploading the file, depending on the permissions associated with the role or IAM user used to generate the URL.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the aws tool