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 → ทดสอบการอัปโหลด
1. Create and Secure the AWS Account
1. สร้างและรักษาความปลอดภัยบัญชี AWS
-
Go to aws.amazon.com and Create an AWS account
ไปที่ aws.amazon.com และสร้างบัญชี AWS -
Verify email, add credit card, choose Basic support
ยืนยันอีเมล เพิ่มบัตรเครดิต เลือก Basic support -
Sign in as Root user once
เข้าสู่ระบบในฐานะ Root user หนึ่งครั้ง -
Turn on MFA for root: IAM → Users → Security recommendations → "Enable MFA for root"
เปิด MFA สำหรับ root: IAM → Users → Security recommendations → "Enable MFA for root"
- AWS account created and MFA enabled for root user
สร้างบัญชี AWS และเปิด MFA สำหรับ root user แล้ว
2. Create an IAM User for n8n and Its Access Key
2. สร้าง IAM User สำหรับ n8n และ Access Key
-
Open IAM → Users → Create user
เปิด IAM → Users → Create user -
Name:
n8n-s3-uploader. No console access needed. Create user
ชื่อ: n8n-s3-uploader ไม่ต้องการ console access สร้าง user -
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) -
Open the user → Security credentials → Create access key → use "Application running outside AWS"
เปิด user → Security credentials → Create access key → ใช้ "Application running outside AWS" -
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 อีกครั้งหลังจากขั้นตอนนี้
- IAM user created and access keys saved securely
สร้าง IAM user และบันทึก access keys อย่างปลอดภัยแล้ว
3. Create the S3 Bucket
3. สร้าง S3 Bucket
Bucket Name Generator / เครื่องมือสร้างชื่อ Bucket
Project Name / ชื่อโปรเจค:
e.g., shantilink, myproject
Environment / สภาพแวดล้อม:
- Production
- Test
- Development
Generated Bucket Name / ชื่อ Bucket ที่สร้างขึ้น:
# Example: shantilink-assets-prod-2a
yourproject-assets-prod-xx
-
S3 → Create bucket
S3 → Create bucket -
Bucket name: global unique, e.g.
yourproject-assets-prod(use generator above)
ชื่อ Bucket: ต้องไม่ซ้ำทั่วโลก เช่นyourproject-assets-prod(ใช้เครื่องมือสร้างข้างบน) -
Region: pick yours (e.g.
ap-southeast-1)
Region: เลือกของคุณ (เช่น ap-southeast-1) -
Keep Block all public access ON for private buckets
เก็บ Block all public access เปิดไว้ สำหรับ bucket ส่วนตัว -
Create bucket
สร้าง bucket
- S3 bucket created with public access blocked
สร้าง S3 bucket และบล็อกการเข้าถึงสาธารณะแล้ว
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
{
"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/*"
}
]
}
Note: 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
- IAM policy created and attached to user
สร้าง IAM policy และแนบกับ user แล้ว
5. Create AWS Credentials in n8n
5. สร้าง AWS Credentials ใน n8n
-
In n8n: Credentials → New
ใน n8n: Credentials → New -
Search AWS → choose AWS credential
ค้นหา AWS → เลือก AWS credential -
Fill: / กรอก:
- Access Key ID: from step 2 / จากขั้นตอนที่ 2
- Secret Access Key: from step 2 / จากขั้นตอนที่ 2
- Region: ap-southeast-1 (or your region) / หรือ region ของคุณ
-
Save. Test if the credential allows listing S3.
บันทึก ทดสอบว่า credential สามารถแสดงรายการ S3 ได้หรือไม่
- AWS credentials configured in n8n and tested
ตั้งค่า AWS credentials ใน n8n และทดสอบแล้ว
6. Test an Upload with the AWS S3 Node in n8n
6. ทดสอบการอัปโหลดด้วย AWS S3 Node ใน n8n
-
Add HTTP Request (or Read Binary File) to produce a binary item (data)
-
Add AWS S3 node
-
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)
-
Run node. You should see ETag and Location in the output
- Successfully uploaded file to S3 via n8n
อัปโหลดไฟล์ไปยัง S3 ผ่าน n8n สำเร็จแล้ว
7. How to View the File
7. วิธีการดูไฟล์
Private Bucket (Recommended) / Bucket ส่วนตัว (แนะนำ):
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 นั้นเพื่อดูไฟล์
Public Access (Not Recommended for Most Cases) / การเข้าถึงสาธารณะ (ไม่แนะนำในกรณีส่วนใหญ่):
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:
{
"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
8. Quick Diagnostics
8. การแก้ไขปัญหาเบื้องต้น
Common Issues and Solutions / ปัญหาที่พบบ่อยและวิธีแก้ไข
AccessDenied when opening the object URL = object is private or bucket blocks public. Use a presigned URL or fix policy/ACL.
SignatureDoesNotMatch = wrong keys or region mismatch.
403 on upload = IAM policy missing s3:PutObject (and s3:PutObjectAcl if you set an ACL).
Wrong MIME in browser = set 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
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/*"
}
]
}
n8n S3 Node Configuration:
- Operation: Upload
- Bucket Name:
your-bucket-name - File Name:
your-filename.ext - Binary File: ON
- Input Binary Field: data
- Content Type: appropriate MIME type
Bucket URL Format:
https://bucket-name.s3.region.amazonaws.com/filename
Need help? Contact us at ShantiLink.com 💬