# Hosting Static Website using Amazon S3

Hello everyone. ကျွန်တော်ဒီနေ့ sharing လုပ်ပေးမှာကတော့ Amazon S3 ကိုအသုံးပြီး static website တစ်ခုဘယ်လိုတည်‌ဆောက်မလဲဆိုတာကို sharing လုပ်ပေးမှာဖြစ်ပါတယ် ။

Demo အနေနဲ့ကိုတော့ ကျွန်‌‌တော်ကတော့ html file တစ်ခုကိုအသုံးပြုပြီး static website အနေနဲ့ host လုပ်ပြသွားပါမယ်. So let’s get started ။

ပထမဆုံးအနေနဲ့ Amazon Portal ‌ကိုအရင်ဝင်ပြီး‌ ပြီး‌တော့ S3 bucket တစ်ခုကို create အရင်လုပ်ပါမယ် ။

click Search bar and type “S3”

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1725648046986/267f1e7f-54dc-4493-bbb4-007f1278c493.png align="center")

and then click s3 button and create a bucket

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1725648073669/02b96671-209f-45cd-b348-7012d367d97e.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1725648086077/969137a7-12af-43f7-99c7-43f21f5b1115.png align="center")

create bucket လုပ်ပြီးသွားတဲ့အခါ ပထမဆုံး bucket အတွက် name တစ်ခုပေးရပါမယ် ။ Name ကတော့ ကိုယ်အဆင်ပြေတဲ့ naming ကိုပေးလို့ရပါတယ် ။

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1725648152105/9465bb08-4f54-4712-baac-302a25fe4e2d.png align="center")

ပြီးသွားရင်တော့ ဒီနေရာမှာသတိထားရမှာက **<mark>Block public access</mark>** ပါပဲ, AWS က default အရ bucket ကို public access မရအောင် block လုပ်ထားပါတယ် ။

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1725648269562/0de6675e-20d3-4ce5-9a56-9183d698de26.png align="center")

အကယ်၍ block public access ကို off မလုပ်ခဲ့ရင်တော့ user တွေက bucket ကို public ကနေ access လုပ်လို့ရမှာမဟုတ်ပါဘူး ။ ဒီတော့ ကျွန်တော်တို့ block access ကို untick လုပ်ပြီး‌တော့ current setting changes လုပ်ထားတာကို acknowledge လုပ်ပါတယ်ဆိုပြီး box မှာ tick လုပ်‌ပေးရပါမယ် ။

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1725648459651/f1c01580-5adf-4b77-949b-b6340ae4e07b.png align="center")

ပြီးရင်တော့ ကျန်တဲ့ setting တွေကို default အတိုင်းထားပြီး bucket ကို create လုပ်လိုက်ပါမယ် ။

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1725648600115/3a0e6d24-8c36-447d-b4cd-3e165549b36f.png align="center")

ဒါဆိုရင်တော့ S3 dashboard မှာ create လုပ်ထားတဲ့ bucket လေးပေါ်လာပါပြီ ။

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1725648644995/db7108dc-e6cf-45bc-afd0-ca72b3f72e42.png align="center")

---

အခုကျွန်တော်တို့ backet create လုပ်ပြီးသွာပြီဆိုတော့ website အတွက်လိုအပ်တဲ့ content file ကို upload လုပ်ပါမယ် ။ Upload လုပ်ဖို့အတွက် create လုပ်ထားတဲ့ bucket ကို double click လုပ်ပြီးတော့ဝင်ပြီး file ကို upload လုပ်ပေးရပါမယ် ။

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1725649047615/31868b7f-373f-43f3-b237-93f3c48357e0.png align="center")

Demo မှာ‌‌တော့ html file ‌‌လေးကို upload လုပ်ပြီးသုံးထားပါတယ်. Add file ကိုနှိပ်ပြီး content file ကို ရွေးပြီး upload လုပ်လိုက်ယုံပါပဲ ။

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1725649093793/e4f48165-8357-498c-a158-0c3848c53def.png align="center")

ပြီးရင်တော့ upload ကို click လုပ်ပြီး save လုပ်လိုက်ရပါမယ် ။

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1725649202699/c18321f7-4fa2-4c9a-941c-edfb1e09c163.png align="center")

Now the file has been uploaded.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1725649403856/0970d9e5-c21b-4ab4-ad9d-06d7369d3e94.png align="center")

---

File upload လုပ်ပြီးသွားတဲ့အခါကျရင် bucket က static website hosting လုပ်လို့ရအောင် static website hosing feature ကို on လုပ်ပေးရပါမယ် ။ Feature ကို on လုပ်ဖို့ဆိုရင် Properties ထဲကိုသွားရပါမယ် ။

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1725649539531/6bfed79b-8afa-4376-baba-4329a473406e.png align="center")

Scroll down to the end . Static website hosting ဆိုပြီးတွေ့ပါလိမ့်မယ် ။ Edit button ကို click လုပ်ပြီးတော့ enable box ကို tick လုပ်ပေးပြီး‌‌တော့ index document ဆိုတဲ့နေရမှာ index.html ဆို ပြီး ဖြည့်ရပါမယ် ပြီးရင်တော့ကျန်တာကို default အတိုင်းထားပြီး save changes လုပ်လိုက်ပါမယ် ။

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1725649590477/4ff88b79-9a4a-489c-a2cc-982227d0963f.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1725649651714/8930c8e9-cdc7-459a-85ac-52bf28dec364.png align="center")

အခု static website hosting feature ကို enable လုပ်ပြီးသွားပြီဆိုတော့ နောက်ထက်တစ်ခုအနေနဲ့ bucket အတွက် policy တခုကို attach လုပ်ပေးရပါမယ် ။ Policy attach လုပ်ဖို့ဆိုရင် Permission tab ထဲက bucket policy ထဲမှာသွားပြီး edit လုပ်ပေးရပါမယ် ။

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1725649814558/b8a6b413-73d3-4040-8944-3def33851323.png align="center")

Edit လုပ်တဲ့အခါမှာ policy ရဲ့ resource နေရာမှာကိုယ့်ရဲ့ bucket name ကိုထည့်ပေးရပါမယ် ။ ဒီနေရာမှာတော့ ကျွန်တော် bucket create လုပ်ထားတဲ့ name ဖြစ်တဲ့ `vitaltechmyanmar` ဆိုတာကိုထည့်လိုက်မှာဖြစ်ပါတယ် ။

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1725649890787/ba25cbd0-62a1-4f3d-b98f-7642eb08dbdc.png align="center")

ပြီးသွားရင်တော့ scroll down ‌and save changes လုပ်လိုက်ပြီးရင်ရပါပြီ ။ ဒါဆိုရင် ကျွန်တော်တို့ website hosting လုပ်တဲ့ step တွေပြီးသွားပြီဆိုတော့ website ကို access တာအဆင်ပြေလားမပြေလားတချက်ကြည့်ကြည့်ရအောင် ။

---

ကျွန်တော်တို့ create လုပ်ထားတဲ့ website က accessရမရစမ်းဖို့အတွက်ဆိုရင်တော့ bucket ထဲက index.html ထဲကိုဝင် ပြီးတော့ properties ထဲက Object URL ကို copy လုပ်ပြီး တခြား tab တစ်ခုမှာ paste လုပ်ကြည့်ပါမယ် ။

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1725650150645/7c9e39ee-d74d-42f4-859f-e2d66e318550.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1725650157856/aa33787f-69b8-487b-8793-a8c8922a5fce.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1725650212962/5b9f2e49-c27c-448a-a322-4a03c841fe9f.png align="center")

ဒါဆို ကျွန်တော်တို့ host လုပ်ထားတဲ့ static website လေးကို public ကနေ access လုပ်လိုရသွားပါပြီ .......

---

အခုဆိုရင်တော့ကျွန်တော်တို့က static website တစ်ခုကို amazon ရဲ့ s3 bucket ကိုအသုံးပြုပြီးတော့ လွယ်လွယ်ကူကူတည်ဆောက်သွားတာဖြစ်ပါတယ် ။ အဆင်ပြေကျမယ်လို့ မျှော်လင့်ပါတယ် ။ အားလုံးပဲ အချိန်ပေးပြီး ဖတ်ရှုပေးတဲ့အတွက်လဲ ကျေးဇူးတင်ပါတယ် ခင်ဗျ ။
