Home icon

Implement single-exchange tokens for short-lived Amazon S3 presigned URLs with Terraform

Storage Blog



This article explains how to implement a serverless application that generates single-use tokens for secure, short-lived S3 presigned URL access using Terraform.

  • Single-use tokens prevent presigned URL reuse, reducing security risks from shared URLs
  • Tokens exchanged exactly once for very-short-duration presigned URLs via API Gateway
  • Lambda generates secure tokens stored in DynamoDB with configurable TTL expiration
  • AWS WAF protects API with rate limiting and managed rule sets
  • DynamoDB conditional writes prevent race conditions on token reuse attempts
  • Solution deployable with Terraform from provided GitHub repository
  • Testing demonstrated via AWS CloudShell with example commands provided
  • Best practices include custom domains, VPC integration, Cognito authorization, and observability tools

This solution enables long-lived access tokens that outlive S3's 7-day presigned URL maximum while minimizing public exposure of actual presigned URLs.



Go to article

The AWS News Feed is currently looking for gold sponsors. If you want to support the AWS community and reach a large audience of AWS professionals, consider sponsoring the AWS News Feed.

Related articles

Apr 29
2026
AWS Transfer Family Terraform module now supports Okta and Microsoft Entra ID integration examples
May 14
2025
Securing Amazon S3 presigned URLs for serverless applications
May 18
2026
Ensure Code Integrity for AWS Lambda Functions with Automated Code Signing Using Terraform
Apr 27
2026
Shift-Left Tag Compliance using AWS Organizations and Terraform

The AWS News Feed is currently looking for silver sponsors. If you want to support the AWS community and reach a large audience of AWS professionals, consider sponsoring the AWS News Feed.