Tutorial AWS Lengkap: Belajar EC2, S3, dan IAM dari Nol

Belajar AWS paling efektif kalau langsung praktik. Pada panduan ini kamu akan membuat IAM User, menjalankan EC2 Instance, menyiapkan S3 Bucket, lalu menghubungkan EC2 ke S3 menggunakan IAM Role.
Setiap langkah ditulis detail sesuai urutan nyata yang sudah dijalankan: mulai dari IAM User β EC2 β S3 β IAM Role β Tes Upload. Disertai penjelasan menu yang dipilih, opsi yang diaktifkan, hingga hasil akhir yang diharapkan. π₯β
π§± Persyaratan
- Akun AWS aktif (pakai Free Tier bila memungkinkan).
- Pilih region terdekat (contoh yang kamu pakai: ap-southeast-2 – Sydney/Singapore) – bebas untuk region. π
1) Buat IAM User untuk Login (bukan Root) π
Console path: IAM β Users β Create user
- User name:
masdika-lab
. - Centang Provide user access to the AWS Management Console.
- User type: pilih I want to create an IAM user (bukan Identity Center).
- Console password: pilih Autogenerated password.
- Centang Users must create a new password at next signβin.
- Set permissions (Step 2):
- Untuk lab, pilih Attach policies directly lalu centang:
AdministratorAccess
βIAMUserChangePassword
β
- Untuk lab, pilih Attach policies directly lalu centang:
- Review and create β klik Create user.
- Simpan signβin URL, username, dan password sementara.
- Login ulang ke Console pakai
masdika-lab
lalu ganti password. (Aktifkan MFA setelahnya). π
Outcome: Punya user nonβroot untuk semua langkah selanjutnya.
2) Launch EC2 Ubuntu (Web Server) π₯οΈ
Console path: EC2 β Instances β Launch instance
- Name:
masdika-lab-ec2
. - AMI: Ubuntu Server 24.04 LTS (Free Tier eligible).
- Instance type:
t2.micro
β . - Key pair:
Create new key pair
β downloadmasdika-lab.pem
. - Network settings:
- Auto-assign public IP: Enable.
- Security group (baru):
- SSH (22) β My IP β (lebih aman dari Anywhere).
- HTTP (80) β Anywhere (0.0.0.0/0, ::/0) π
- (Opsional) HTTPS (443) β Anywhere.
- Storage: default 8 GB (gp2/gp3) β cukup.
- Klik Launch instance β tunggu status Running + Status checks: 2/2 passed.
Ambil Public IPv4 dari detail instance.
SSH dari komputer:
chmod 400 masdika-lab.pem
ssh -i masdika-lab.pem ubuntu@<EC2_PUBLIC_IP>
Jika “Permission denied (publickey)”: cek key, aturan SG (SSH=My IP), dan
chmod 400
sudah benar.
Install web server:
sudo apt update && sudo apt install -y nginx
Uji di browser: http://<EC2_PUBLIC_IP>
β tampil halaman default Nginx β

3) Buat S3 Bucket untuk Static Website πͺ£
Console path: S3 β Create bucket
- Bucket name:
masdika-lab-bucket
(harus unik global). - Region: sama dengan EC2.
- Object ownership: ACLs disabled (recommended).
- Block Public Access: uncheck βBlock all public accessβ β ketik confirm.
- Default encryption: pilih SSEβS3 (default). (Bucket Key abaikan/Disable).
- (Opsional) Versioning: Disable untuk lab.
- Klik Create bucket.
Upload file (di dalam bucket): Upload β Add files β pilih index.html
.
- Storage class:
Standard
. - Server-side encryption (per object): Donβt specify (cukup SSEβS3 default bucket).
- Klik Upload.
Aktifkan Static Website Hosting:
Properties β Static website hosting β Enable
- Index document:
index.html
. - Catat Website endpoint contoh:
http://masdika-lab-bucket.s3-website-ap-southeast-2.amazonaws.com
Jadikan objek bisa dibaca publik (Bucket Policy): Permissions β Bucket policy
β tempel JSON:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::masdika-lab-bucket/*"
}
]
}
Uji: buka Website endpoint β halaman index.html
tampil β

Kalau 403 AccessDenied: biasanya lupa uncheck Block public access atau policy belum disimpan.
4) Buat IAM Role agar EC2 Bisa Akses S3 (Tanpa Access Key) π«
Console path: IAM β Roles β Create role
- Trusted entity type: AWS service.
- Use case: EC2 β Next.
- Add permissions: centang
AmazonS3FullAccess
(untuk lab β mudah dites). - Role name:
EC2S3Role
β Create role.
Pasang role ke instance:
EC2 β Instances β pilih instance β Actions β Security β Modify IAM role β pilih EC2S3Role β Update
.- Cek tab Security β kolom IAM Role sudah terisi
EC2S3Role
.
Tes dari EC2 (CLI):
# kalau belum ada CLI
sudo apt update && sudo apt install -y awscli
# tampilkan daftar bucket
aws s3 ls
# kirim file uji ke S3
cd ~
echo "Hello from EC2 π" > test.html
aws s3 cp test.html s3://masdika-lab-bucket/
Uji di browser: http://<endpoint-website>/test.html
β tampil teks Hello from EC2 π β

5) (Opsional) Ganti ke Policy Minimal (Bucket-Scope) π§°
Agar lebih aman daripada AmazonS3FullAccess
, buat policy khusus bucket ini saja.
Policy JSON (minimal akses):
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["s3:ListBucket"],
"Resource": "arn:aws:s3:::masdika-lab-bucket"
},
{
"Effect": "Allow",
"Action": ["s3:GetObject", "s3:PutObject", "s3:DeleteObject"],
"Resource": "arn:aws:s3:::masdika-lab-bucket/*"
}
]
}
Langkah: IAM β Policies β Create policy β JSON β Paste β Name: EC2S3BucketOnly β Create
β attach policy ini ke EC2S3Role, lalu hapus AmazonS3FullAccess
dari role.
β Ringkasan Hasil
- IAM User
masdika-lab
untuk login aman (bukan root) π - EC2 Ubuntu (t2.micro) + Nginx berjalan π
- S3 Static Website aktif dengan bucket policy π
- IAM Role EC2S3Role sukses β EC2 upload ke S3 tanpa access key π
π§Ή Cleanup (biar hemat biaya) πΈ
- Terminate instance EC2 kalau sudah selesai.
- Empty & Delete bucket S3 (hapus objek dulu baru bucketβnya).
- Hapus IAM Role/Policy yang tidak dipakai.
- (Opsional) Hapus Security Group dan Key Pair kalau memang khusus lab ini.
π‘ Troubleshooting Cepat
- 403 AccessDenied di S3 β Block Public Access masih ON atau policy belum benar.
- 404 di S3 website β nama file bukan
index.html
atau salah path. - SSH gagal β Security Group SSH bukan My IP, atau
chmod 400
belum dijalankan. aws
command not found β instalawscli
dulu.- Tidak menemukan βModify IAM roleβ β pastikan pilih menu
Actions β Security
pada instance yang benar.
Selamat! π Kamu sudah menyelesaikan lab dasar AWS mencakup Compute, Storage, dan IAM. Lanjutannya kamu bisa tambah CloudFront (CDN + HTTPS), RDS untuk database, atau CodePipeline untuk CI/CD. π

Lab ini disusun dengan pendekatan praktis step-by-step, sehingga bahkan pemula bisa langsung mengikuti tanpa bingung. Kita mulai dari menyiapkan akun AWS…

Amazon EC2 (Elastic Compute Cloud) adalah layanan cloud dari AWS (Amazon Web Services) yang memungkinkan kamu untuk membuat dan menjalankan…