AWS S3 Integration – Complete Setup Guide

Complete guide to set up AWS S3 credentials in n8n for file storage and automation workflows

Complete guide to set up AWS S3 credentials in n8n for file storage and automation workflows.
คู่มือการตั้งค่า AWS S3 สำหรับ n8n เพื่อจัดเก็บไฟล์และระบบอัตโนมัติ


📋 Overview

ภาพรวม

This guide covers the complete process: Create AWS account → Secure it → Create IAM user + keys → Create S3 bucket → Add least-privilege policy → Wire keys into n8n → Test upload.

คู่มือนี้ครอบคลุมกระบวนการทั้งหมด: สร้างบัญชี AWS → รักษาความปลอดภัย → สร้าง IAM user + keys → สร้าง S3 bucket → เพิ่ม policy ขั้นต่ำ → เชื่อมต่อกับ n8n → ทดสอบการอัปโหลด


Step 1: Create and Secure the AWS Account

ขั้นตอนที่ 1: สร้างและรักษาความปลอดภัยบัญชี AWS

  1. Go to aws.amazon.com and Create an AWS account
    ไปที่ aws.amazon.com และสร้างบัญชี AWS
  2. Verify email, add credit card, choose Basic support
    ยืนยันอีเมล เพิ่มบัตรเครดิต เลือก Basic support
  3. Sign in as Root user once
    เข้าสู่ระบบในฐานะ Root user หนึ่งครั้ง
  4. Turn on MFA for root: IAM → Users → Security recommendations → "Enable MFA for root"
    เปิด MFA สำหรับ root: IAM → Users → Security recommendations → "Enable MFA for root"

✅ Checklist:

  • AWS account created and MFA enabled for root user
    สร้างบัญชี AWS และเปิด MFA สำหรับ root user แล้ว

Step 2: Create an IAM User for n8n and Its Access Key

ขั้นตอนที่ 2: สร้าง IAM User สำหรับ n8n และ Access Key

  1. Open IAM → Users → Create user
    เปิด IAM → Users → Create user
  2. Name: n8n-s3-uploader. No console access needed. Create user
    ชื่อ: n8n-s3-uploader ไม่ต้องการ console access สร้าง user
  3. Open the new user → Permissions → Add permissions → Attach policies directly → click Create policy (we'll add a tight policy in step 4)
    เปิด user ใหม่ → Permissions → Add permissions → Attach policies directly → คลิก Create policy (เราจะเพิ่ม policy ในขั้นตอนที่ 4)
  4. Open the user → Security credentials → Create access key → use "Application running outside AWS"
    เปิด user → Security credentials → Create access key → ใช้ "Application running outside AWS"
  5. Copy Access key ID and Secret access key. Store securely. You will need both in n8n
    คัดลอก Access key ID และ Secret access key เก็บไว้อย่างปลอดภัย จะต้องใช้ทั้งคู่ใน n8n

⚠️ Important: Save your Access Key ID and Secret Access Key immediately. AWS will not show the secret key again after this step.
สำคัญ: บันทึก Access Key ID และ Secret Access Key ทันที AWS จะไม่แสดง secret key อีกครั้งหลังจากขั้นตอนนี้

✅ Checklist:

  • IAM user created and access keys saved securely
    สร้าง IAM user และบันทึก access keys อย่างปลอดภัยแล้ว

Step 3: Create the S3 Bucket

ขั้นตอนที่ 3: สร้าง S3 Bucket

🎯 Bucket Name Generator

เครื่องมือสร้างชื่อ Bucket

Use this naming pattern: {project-name}-assets-{environment}-{random}

Examples:

  • shantilink-assets-prod-a1
  • myproject-assets-test-b2
  • company-assets-dev-c3
  1. S3 → Create bucket
    S3 → Create bucket
  2. Bucket name: global unique, e.g. yourproject-assets-prod (use pattern above)
    ชื่อ Bucket: ต้องไม่ซ้ำทั่วโลก เช่น yourproject-assets-prod (ใช้รูปแบบด้านบน)
  3. Region: pick yours (e.g. ap-southeast-1)
    Region: เลือกของคุณ (เช่น ap-southeast-1)
  4. Keep Block all public access ON for private buckets
    เก็บ Block all public access เปิดไว้ สำหรับ bucket ส่วนตัว
  5. Create bucket
    สร้าง bucket

✅ Checklist:

  • S3 bucket created with public access blocked
    สร้าง S3 bucket และบล็อกการเข้าถึงสาธารณะแล้ว

Step 4: Grant Least-Privilege Permissions to That User

ขั้นตอนที่ 4: กำหนดสิทธิ์ขั้นต่ำให้กับ User

Create a policy that allows only this bucket. Replace the bucket name everywhere.

สร้าง policy ที่อนุญาตเฉพาะ bucket นี้เท่านั้น แทนที่ชื่อ bucket ทุกที่

IAM → Policies → Create policy → JSON
IAM → Policies → Create policy → JSON

📋 IAM Policy JSON:

{
  "Version": "2012-10-17",
  "Statement": [
    { 
      "Effect": "Allow", 
      "Action": ["s3:ListBucket"], 
      "Resource": "arn:aws:s3:::yourproject-assets-prod" 
    },
    { 
      "Effect": "Allow", 
      "Action": ["s3:GetObject","s3:PutObject","s3:DeleteObject"], 
      "Resource": "arn:aws:s3:::yourproject-assets-prod/*" 
    }
  ]
}

💡 If you plan to set ACL: public-read from n8n, also add:
หากคุณวางแผนที่จะตั้ง ACL: public-read จาก n8n ให้เพิ่ม:

{ "Effect": "Allow", "Action": ["s3:PutObjectAcl"], "Resource": "arn:aws:s3:::yourproject-assets-prod/*" }

Save as n8n-s3-uploader-policy, then Attach it to the n8n-s3-uploader user.

บันทึกเป็น n8n-s3-uploader-policy แล้วแนบกับ n8n-s3-uploader user

✅ Checklist:

  • IAM policy created and attached to user
    สร้าง IAM policy และแนบกับ user แล้ว

Step 5: Create AWS Credentials in n8n

ขั้นตอนที่ 5: สร้าง AWS Credentials ใน n8n

  1. In n8n: Credentials → New
    ใน n8n: Credentials → New
  2. Search AWS → choose AWS credential
    ค้นหา AWS → เลือก AWS credential
  3. Fill: / กรอก:
    • Access Key ID: from step 2 / จากขั้นตอนที่ 2
    • Secret Access Key: from step 2 / จากขั้นตอนที่ 2
    • Region: ap-southeast-1 (or your region) / หรือ region ของคุณ
  4. Save. Test if the credential allows listing S3.
    บันทึก ทดสอบว่า credential สามารถแสดงรายการ S3 ได้หรือไม่

✅ Checklist:

  • AWS credentials configured in n8n and tested
    ตั้งค่า AWS credentials ใน n8n และทดสอบแล้ว

Step 6: Test an Upload with the AWS S3 Node in n8n

ขั้นตอนที่ 6: ทดสอบการอัปโหลดด้วย AWS S3 Node ใน n8n

  1. Add HTTP Request (or Read Binary File) to produce a binary item (data)
  2. Add AWS S3 node
  3. Configure:
    • Credentials to connect with: your AWS credential
    • Resource: File
    • Operation: Upload
    • Bucket Name: yourproject-assets-prod
    • File Name: e.g. test.jpg
    • Binary File: ON
    • Input Binary Field: data
    • Additional Fields → Content Type: image/jpeg
    • Optional: ACL public-read (only if you enabled ACLs and want a public object)
  4. Run node. You should see ETag and Location in the output

✅ Checklist:

  • Successfully uploaded file to S3 via n8n
    อัปโหลดไฟล์ไปยัง S3 ผ่าน n8n สำเร็จแล้ว

Step 7: How to View the File

ขั้นตอนที่ 7: วิธีการดูไฟล์

Add another AWS S3 node with Operation: Get Presigned URL. Set an expiry (e.g. 3600 seconds). Use that URL to view the file.

เพิ่ม AWS S3 node อีกตัวด้วย Operation: Get Presigned URL ตั้งเวลาหมดอายุ (เช่น 3600 วินาที) ใช้ URL นั้นเพื่อดูไฟล์

Turn off Block public access at the bucket, add a bucket policy to allow reads, and/or upload with ACL: public-read. Example bucket policy:

ปิด Block public access ที่ bucket เพิ่ม bucket policy เพื่ออนุญาตการอ่าน และ/หรือ อัปโหลดด้วย ACL: public-read ตัวอย่าง bucket policy:

📋 Bucket Policy JSON (Public Read):

{
  "Version": "2012-10-17",
  "Statement": [{
    "Sid": "AllowPublicRead",
    "Effect": "Allow",
    "Principal": "*",
    "Action": "s3:GetObject",
    "Resource": "arn:aws:s3:::yourproject-assets-prod/*"
  }]
}

Then your URL will be: / แล้ว URL ของคุณจะเป็น:
https://yourproject-assets-prod.s3.ap-southeast-1.amazonaws.com/test.jpg


Step 8: Quick Diagnostics

ขั้นตอนที่ 8: การแก้ไขปัญหาเบื้องต้น

🔧 Common Issues and Solutions / ปัญหาที่พบบ่อยและวิธีแก้ไข

IssueCauseSolution
AccessDenied when opening the object URLobject is private or bucket blocks publicUse a presigned URL or fix policy/ACL
SignatureDoesNotMatchwrong keys or region mismatchVerify credentials and region
403 on uploadIAM policy missing s3:PutObjectAdd s3:PutObject (and s3:PutObjectAcl if you set an ACL)
Wrong MIME in browsermissing Content TypeSet Content Type on upload

🎉 Setup Complete! / การตั้งค่าเสร็จสมบูรณ์!

Your AWS S3 integration with n8n is now ready. You can: / การรวม AWS S3 กับ n8n ของคุณพร้อมแล้ว คุณสามารถ:

  • Upload files from n8n workflows to your S3 bucket / อัปโหลดไฟล์จาก n8n workflows ไปยัง S3 bucket ของคุณ
  • Generate presigned URLs for secure file access / สร้าง presigned URLs สำหรับการเข้าถึงไฟล์อย่างปลอดภัย
  • Use S3 for storing workflow outputs, images, documents, and more / ใช้ S3 สำหรับเก็บผลลัพธ์ของ workflow รูปภาพ เอกสาร และอื่นๆ
  • Integrate with other AWS services through n8n / รวมกับบริการ AWS อื่นๆ ผ่าน n8n

📚 Quick Reference

Essential URLs:

# AWS Management Console
https://aws.amazon.com/console/

# IAM Console
https://console.aws.amazon.com/iam/

# S3 Console
https://console.aws.amazon.com/s3/

# n8n Credentials
https://your-n8n-instance.com/credentials

Bucket Naming Pattern:

{project-name}-assets-{environment}-{random}
# Examples:
shantilink-assets-prod-a1
myproject-assets-test-b2
company-assets-dev-c3

Complete IAM Policy Template:

{
  "Version": "2012-10-17",
  "Statement": [
    { 
      "Effect": "Allow", 
      "Action": ["s3:ListBucket"], 
      "Resource": "arn:aws:s3:::your-bucket-name" 
    },
    { 
      "Effect": "Allow", 
      "Action": ["s3:GetObject","s3:PutObject","s3:DeleteObject"], 
      "Resource": "arn:aws:s3:::your-bucket-name/*" 
    }
  ]
}

AWS S3 Node Configuration:

Resource: File
Operation: Upload
Bucket Name: your-bucket-name
File Name: example.jpg
Binary File: ON
Input Binary Field: data
Content Type: image/jpeg
ACL: (optional) public-read

Common Regions:

# Asia Pacific
ap-southeast-1  # Singapore
ap-southeast-2  # Sydney
ap-northeast-1  # Tokyo
ap-south-1      # Mumbai

# US
us-east-1       # N. Virginia
us-west-2       # Oregon
us-west-1       # N. California

# Europe
eu-west-1       # Ireland
eu-central-1    # Frankfurt

Troubleshooting Commands:

# Test AWS CLI connection
aws s3 ls

# Check bucket permissions
aws s3api get-bucket-policy --bucket your-bucket-name

# Test presigned URL generation
aws s3 presign s3://your-bucket-name/your-file.txt --expires-in 3600

Need help? Contact us at ShantiLink.com 💬


Last updated: December 2024
อัปเดตล่าสุด: ธันวาคม 2024