# Create a Deployment Script

เพื่อให้การ spawn application instance ที่มี setting และติดตั้ง application ซ้ำๆ ทำได้ง่ายขึ้น คุณสามารถสร้างขั้นตอนการ setup และ ติดตั้ง application ต่างๆ ในรูปแบบของ cloud-config หรือ x-shellscript ได้

## Prerequisite

* มียอดคงเหลือใน Project มากกว่า 0 บาท หากไม่มี ศึกษาวิธีเติมเงินได้ที่ [ขั้นตอนการเติมเงินเข้าสู่ Project](https://docs-epc.gitbook.io/ncs-documents/nipa-cloud-space-overview/billing-and-wallet/topup-a-project-wallet)

## Instructions

### 1. เข้าสู่หน้า Deployment Scripts

ที่แถบเมนูทางซ้าย คลิกเลือกเมนู​ COMPUTE > Deployment Scripts เพื่อเข้าสู่หน้า Deployment Scripts&#x20;

### 2. คลิกปุ่มสร้าง Deployment Script

คลิกปุ่ม "CREATE" ที่ด้านขวาบนของหน้า จะปรากฏหน้าต่าง create deployment script ขึ้นมา

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

### 3. กำหนดค่าต่าง ๆ ของ Deployment Script

กำหนดค่าต่าง ๆ ของ deployment script ดังนี้

1. Name : ชื่อของ script ที่จะแสดงใน list และ แสดงในหน้า launch instance
2. Base image : เลือก image ที่จะใช้เป็น base ในการ launch instance ก่อน run script
3. Min disk : ไซส์ต่ำสุดของ volume ที่จะ boot script นี้ได้ โดยค่าเริ่มต้นจะอ้างอิงมาจาก base image แต่สามารถเปลี่ยนแปลงได้
4. Script Type : ประเภทของ script แบ่งเป็น 2 ประเภทคือ cloud-config (ศึกษาการเขียนเพิ่มเติมได้จาก <https://cloudinit.readthedocs.io/en/latest/explanation/format.html>) และ x-shellscript (ศึกษาการเขียนเพิ่มเดิมได้จาก <https://www.shellscript.sh/>)
5. Script : script ที่ตาม script type ที่เลือกไว้&#x20;

{% hint style="info" %}
หาก base image ถูกลบออกจากระบบ deployment script นี้จะไม่แสดงในหน้า launch instance จนกว่าจะ [update](/ncs-documents/compute/deployment-script/edit-a-deployment-script.md) base image เป็น image ที่มีอยู่จริงในระบบ
{% endhint %}

### 4. ตรวจสอบและยืนยันการสร้าง deployment script

ตรวจสอบรายละเอียดต่าง ๆ ที่กรอกให้เรียบร้อย

Script ที่ถูกสร้าง จะแสดงในรายการของ deployment script และใน source ของหน้า launch instance

<figure><img src="/files/73kNWJ3zq9iORHRBmKsj" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/xY4eXdPngcbK7v7UinTM" 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/compute/deployment-script/create-a-deployment-script.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.
