For the complete documentation index, see llms.txt. This page is also available as Markdown.

AWS Endpoint Policy for Trusted S3 Buckets

An AWS VPC Endpoint Policy for Amazon S3 controls who can access specific S3 buckets when using a VPC Endpoint. This is useful for restricting access to trusted AWS accounts, IAM roles, or specific resources.


๐Ÿ“Œ Use Case: SecureCartโ€™s Trusted S3 Buckets

๐Ÿ“Œ Scenario: SecureCart stores customer order data and transaction logs in Amazon S3. To enhance security: โœ” Only SecureCartโ€™s AWS accounts should access S3 via VPC Endpoints. โœ” Public access to S3 should be blocked. โœ” Only specific IAM roles should have read/write access to the bucket.


โœ… Sample S3 VPC Endpoint Policy (Allow Only Trusted Accounts & IAM Roles)

jsonCopyEdit{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": "*",
      "Action": "s3:*",
      "Resource": [
        "arn:aws:s3:::securecart-private-bucket",
        "arn:aws:s3:::securecart-private-bucket/*"
      ],
      "Condition": {
        "StringEquals": {
          "aws:PrincipalAccount": "123456789012"
        }
      }
    },
    {
      "Effect": "Deny",
      "Principal": "*",
      "Action": "s3:*",
      "Resource": [
        "arn:aws:s3:::securecart-private-bucket",
        "arn:aws:s3:::securecart-private-bucket/*"
      ],
      "Condition": {
        "Bool": {
          "aws:SecureTransport": "false"
        }
      }
    }
  ]
}

๐Ÿ“Œ Explanation of Policy:

๐Ÿ”น Statement 1 (Allow Access for Trusted AWS Account) โœ” Allows all actions (s3:*) on SecureCartโ€™s S3 bucket. โœ” Restricts access to SecureCartโ€™s AWS Account (123456789012).

๐Ÿ”น Statement 2 (Deny Unencrypted Requests) โœ” Blocks requests where TLS (SSL) is not used (aws:SecureTransport: false). โœ” Ensures all access to SecureCartโ€™s S3 bucket happens over HTTPS only.


๐Ÿ“Œ Additional Enhancements

1๏ธโƒฃ Restrict Access to Specific IAM Roles

๐Ÿ”น Only allows IAM role SecureCartDataAccess to access the bucket.

2๏ธโƒฃ Restrict Access to a Specific VPC

๐Ÿ”น Ensures SecureCartโ€™s S3 bucket is only accessible from a specific VPC.

3๏ธโƒฃ Limit Access to Read-Only or Write-Only

  • Allow only read access (s3:GetObject) to certain roles.

  • Allow only write access (s3:PutObject) for specific workloads.


๐Ÿ“Œ Summary

๐Ÿš€ This VPC Endpoint Policy ensures SecureCartโ€™s S3 buckets are: โœ” Only accessible to SecureCartโ€™s AWS account. โœ” Restricted to IAM roles that should access it. โœ” Only reachable from a trusted VPC. โœ” Forces encryption (TLS/SSL) for all requests.

Hands-On Guide: Implementing a Secure VPC Endpoint Policy for Trusted S3 Buckets in SecureCartโ€™s AWS Environment

This guide walks through the step-by-step process of securing SecureCartโ€™s Amazon S3 buckets using a VPC Endpoint Policy that ensures: โœ” Only SecureCartโ€™s AWS account can access the bucket โœ” Only specific IAM roles can perform actions โœ” Access is restricted to a specific VPC โœ” Requests must use HTTPS (TLS/SSL)


๐Ÿ“Œ Step 1: Create a VPC Endpoint for Amazon S3

๐Ÿ“Œ Why? VPC Endpoints allow SecureCartโ€™s S3 bucket to be accessed privately from within the VPCโ€”without using the public internet.

โœ… Actions:

1๏ธโƒฃ Sign in to the AWS Management Console. 2๏ธโƒฃ Navigate to VPC โ†’ Endpoints โ†’ Create Endpoint. 3๏ธโƒฃ Select AWS Service and search for S3. 4๏ธโƒฃ Choose the VPC where SecureCartโ€™s applications are running. 5๏ธโƒฃ Select the private subnets that need access. 6๏ธโƒฃ Choose an appropriate security group (allowing outbound HTTPS traffic). 7๏ธโƒฃ Click Create Endpoint.

โœ… Result: A new VPC endpoint is created, allowing S3 access from within the VPC.


๐Ÿ“Œ Step 2: Attach a Secure Endpoint Policy

๐Ÿ“Œ Why? The endpoint policy restricts who can access S3 via the VPC Endpoint.

โœ… Actions:

1๏ธโƒฃ Navigate to the VPC Endpoint you just created. 2๏ธโƒฃ Click Policy โ†’ Edit Policy. 3๏ธโƒฃ Copy and paste the following policy (adjusting AWS Account ID, VPC ID, and IAM role names).

โœ” Restricts access to SecureCartโ€™s AWS Account (123456789012) โœ” Denies requests that are not encrypted (HTTPS required)

4๏ธโƒฃ Click Save.

โœ… Result: Now, only SecureCartโ€™s trusted AWS account can access the bucket, and unencrypted requests are denied.


๐Ÿ“Œ Step 3: Restrict Access to Specific IAM Roles

๐Ÿ“Œ Why? Only authorized IAM roles should have access.

โœ… Actions:

1๏ธโƒฃ Edit the VPC Endpoint Policy. 2๏ธโƒฃ Add the IAM Role Restriction:

๐Ÿ“Œ Example Updated Policy

โœ… Result: โœ” Only the IAM role SecureCartDataAccess can access the bucket. โœ” No unauthorized IAM roles or users can access it.


๐Ÿ“Œ Step 4: Enforce Access from a Specific VPC

๐Ÿ“Œ Why? Ensure S3 is only accessible from SecureCartโ€™s trusted VPC.

โœ… Actions:

1๏ธโƒฃ Edit the VPC Endpoint Policy. 2๏ธโƒฃ Add the VPC Restriction:

๐Ÿ“Œ Example Updated Policy

โœ… Result: โœ” Only requests originating from SecureCartโ€™s VPC (vpc-abcdef123456) are allowed. โœ” Even if an IAM role is authorized, access from an external network is denied.


๐Ÿ“Œ Step 5: Test & Validate the Secure Setup

๐Ÿ“Œ Why? Ensure SecureCartโ€™s security restrictions are working.

โœ… Actions:

1๏ธโƒฃ Try accessing S3 from an unauthorized IAM user โ†’ Request should be denied. 2๏ธโƒฃ Try accessing S3 without HTTPS โ†’ Request should be denied. 3๏ธโƒฃ Access S3 from a trusted IAM role & VPC โ†’ Request should be allowed. 4๏ธโƒฃ Monitor AWS CloudTrail logs to verify access patterns.

โœ… Final Result: SecureCartโ€™s S3 bucket is now fully locked down, allowing only trusted accounts, IAM roles, and VPC access while enforcing TLS encryption.


๐Ÿ“Œ Summary

๐Ÿš€ SecureCartโ€™s Trusted S3 VPC Endpoint Setup Achieves: โœ” Secure access without exposing S3 to the public internet. โœ” IAM Role-based access control for granular security. โœ” Restricts access to a specific AWS VPC. โœ” Forces HTTPS encryption to prevent data leaks.

Last updated