# Create Bucket Policy

## Prerequisite

* มียอดคงเหลือใน project มากกว่า 0 บาท ([ขั้นตอนการเติมเงินเข้าสู่ project](/ncs-documents/nipa-cloud-space-overview/billing-and-wallet/topup-a-project-wallet.md))
* ต้องมี bucket สร้างเอาไว้แล้ว ([ขั้นตอนในการสร้าง bucket](/ncs-documents/storage/object-storage-s3/create-an-object-storage-bucket.md))

## Instructions

### 1. เข้าสู่ Project

กดเลือก project จากหน้า Projects Management เพื่อเข้าสู่หน้า Project Detail

<figure><img src="/files/80ioiee7LfAr4JNwZi2j" alt=""><figcaption></figcaption></figure>

### 2. เข้าสู่หน้า Bucket List

เลือก menu Object Storage - Buckets บน sidebar เพื่อเข้าสู่หน้า Bucket List

### 3. เข้าสู่หน้า Bucket Detail

click ที่ชื่อของ bucket ที่ต้องการแก้ไข policy เพื่อเข้าสู่หน้า Bucket Detail

<figure><img src="/files/bbrjJhlESFkLITiLT1cS" alt=""><figcaption></figcaption></figure>

### 4. สร้าง Bucket Policy

เข้าสู่หน้า Create Bucket Policy โดย click ที่ปุ่ม Add Policy ในส่วนของ Policies ส่วนล่างของหน้า Bucket Detail

<figure><img src="/files/Za5HKMuYStdzbB8uZvNk" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/wZjIo2WsSSgs4lGPnGRL" alt=""><figcaption></figcaption></figure>

ค่าที่ต้อง set ในการสร้าง bucket policy ประกอบด้วย

1. **Policy Name**: ชื่อของ policy ที่แสดงในรายการ policy
2. **Target Type**: ประเภทของ policy ว่าจะ apply policy นี้ใน level ใดบ้าง
   1. **Object/Path**: สำหรับ policy ที่จะ apply policy นี้ ที่ object เช่น การ Get Object หรือ Delete Object\
      โดยกำหนด Target ให้เป็น object หรือ wildcard path เช่น `[bucket name]/home/index.html` หรือ `[bucket name]/document/*`
   2. **Bucket**: สำหรับ policy ที่จะ apply ที่ตัว bucket เช่น List Bucket หรือ Get Bucket Logging\
      โดย target จะถูกระบุเป็น `[bucket name] โดยอัตโนมัติ`
   3. **Custom**: สำหรับ policy ที่จะ apply ทั้งที่ bucket และ object ภายใน bucket
3. **Effect**: ระบุวิธีการ verify policy โดยกำหนดถ้ากำหนดเป็น allow จะเป็นการ**ยอมให้** user ที่ระบุ สามารถทำ action ที่ระบุ ใน target ที่ระบุไว้ใน policy ได้\
   ในทางกลับกัน ถ้ากำหนดเป็น deny จะให้ผลตรงกันข้าม คือ **ไม่ยอมให้** user ที่ระบุ สามารถทำ action ที่ระบุ ใน target ที่ระบุไว้ใน policy ได้
4. **Sub-User(s)**: รายการของ user ที่ได้รับผลจาก polocy นี้ สามารถระบุเป็น "Everyone applied for this policy" เพื่อให้ apply ทั้งหมด รวมถึงการใช้งานที่ไม่มีการ authenticate บน ACL public ด้วย
5. **Actions**: รายการของ action ของ policy นี้ โดยรายการของ action จะเปลี่ยนไปตาม Target Type

{% hint style="info" %}
policy ที่ถูกสร้างไว้ก่อน release [4.15.5](/ncs-documents/release-notes/v4.15.x-v4.15.0-v4.15.9/v4.15.5.md) และกำหนด target ไว้ทั้งแบบ bucket และ object/path จะแสดง Target Type เป็น Custom
{% endhint %}

### 5. สร้างสำเร็จ

เมื่อเลือกตัวเลือกต่างๆ เรียบร้อยแล้ว ให้ click ปุ่ม CREATE เพื่อ confirm \
หลังจากนั้นระบบจะแสดง policy ดังกล่าวในรายการ policy

<figure><img src="/files/W0fQLtb2yXZjDAz9zTx3" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs-epc.gitbook.io/ncs-documents/storage/object-storage-s3/create-bucket-policy.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
