Skip to content

NimTechnology

Trình bày các công nghệ CLOUD một cách dễ hiểu.

  • Kubernetes & Container
    • Docker
    • Kubernetes
      • Gateway API
      • Ingress
      • Pod
    • Helm Chart
    • OAuth2 Proxy
    • Isito-EnvoyFilter
    • Apache Kafka
      • Kafka
      • Kafka Connect
      • Lenses
    • Vault
    • Longhorn – Storage
    • VictoriaMetrics
    • MetalLB
    • Kong Gateway
  • CI/CD
    • ArgoCD
    • ArgoWorkflows
    • Argo Events
    • Spinnaker
    • Jenkins
    • Harbor
    • TeamCity
    • Git
      • Bitbucket
  • Coding
    • DevSecOps
    • Terraform
      • GCP – Google Cloud
      • AWS – Amazon Web Service
      • Azure Cloud
    • Golang
    • Laravel
    • Python
    • Jquery & JavaScript
    • Selenium
  • Log, Monitor & Tracing
    • DataDog
    • Prometheus
    • Grafana
    • ELK
      • Kibana
      • Logstash
  • BareMetal
    • NextCloud
  • Toggle search form

[Terraform] Infrastructure Automation With Terraform – Lesson 1: Setup AWS

Posted on May 10, 2022May 10, 2022 By nim No Comments on [Terraform] Infrastructure Automation With Terraform – Lesson 1: Setup AWS

Ở bài về beginer terraform mình đã hướng dẫn cách tạo tài khoản AWS free 1 năm

Contents

Toggle
  • 1) Create account and login console
  • 2) Setup AWS Account
  • 3) Give IAM users access to billing information
  • 4) Setup AWS IAM account
    • 4.1) Create Custom Policy.
    • 4.2) Create Group
    • 4.3) Create User
  • 5) Set MFA on IAM account
  • 6) Create budget in AWS

1) Create account and login console

[AWS] – Terraform Beginner – Lesson 1: Create a Free Account of AWS

Lúc này user của bạn sẽ là user root
Đa số ta sẽ được khuyên là sửa sử dụng user root càng ít càng tốt.

Vậy giờ chúng ta vào mục tiếp theo là:

2) Setup AWS Account

Bạn nên active MFA

Hiện tại mình đang lab nên cũng không cần active MFA

3) Give IAM users access to billing information

Để hạn chế tối đa việc sử dựng tài khoản root thì chúng ta cần config cho IAM user có quyền access vào Billing.

4) Setup AWS IAM account

Ở user root -> search IAM

4.1) Create Custom Policy.

thực hiện create policy

Bạn có thể tham khảo links:
https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_examples_aws_my-sec-creds-self-manage.html

Và config bên dưới này:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "AllowViewAccountInfo",
            "Effect": "Allow",
            "Action": [
                "iam:GetAccountPasswordPolicy",
                "iam:GetAccountSummary",
                "iam:ListVirtualMFADevices",
                "iam:ListUsers"
            ],
            "Resource": "*"
        },
        {
            "Sid": "AllowManageOwnPasswords",
            "Effect": "Allow",
            "Action": [
                "iam:ChangePassword",
                "iam:GetUser"
            ],
            "Resource": "arn:aws:iam::*:user/${aws:username}"
        },
        {
            "Sid": "AllowManageOwnAccessKeys",
            "Effect": "Allow",
            "Action": [
                "iam:CreateAccessKey",
                "iam:DeleteAccessKey",
                "iam:ListAccessKeys",
                "iam:UpdateAccessKey"
            ],
            "Resource": "arn:aws:iam::*:user/${aws:username}"
        },
        {
            "Sid": "AllowManageOwnSigningCertificates",
            "Effect": "Allow",
            "Action": [
                "iam:DeleteSigningCertificate",
                "iam:ListSigningCertificates",
                "iam:UpdateSigningCertificate",
                "iam:UploadSigningCertificate"
            ],
            "Resource": "arn:aws:iam::*:user/${aws:username}"
        },
        {
            "Sid": "AllowManageOwnSSHPublicKeys",
            "Effect": "Allow",
            "Action": [
                "iam:DeleteSSHPublicKey",
                "iam:GetSSHPublicKey",
                "iam:ListSSHPublicKeys",
                "iam:UpdateSSHPublicKey",
                "iam:UploadSSHPublicKey"
            ],
            "Resource": "arn:aws:iam::*:user/${aws:username}"
        },
        {
            "Sid": "AllowManageOwnGitCredentials",
            "Effect": "Allow",
            "Action": [
                "iam:CreateServiceSpecificCredential",
                "iam:DeleteServiceSpecificCredential",
                "iam:ListServiceSpecificCredentials",
                "iam:ResetServiceSpecificCredential",
                "iam:UpdateServiceSpecificCredential"
            ],
            "Resource": "arn:aws:iam::*:user/${aws:username}"
        },
        {
            "Sid": "AllowManageOwnVirtualMFADevice",
            "Effect": "Allow",
            "Action": [
                "iam:CreateVirtualMFADevice",
                "iam:DeleteVirtualMFADevice"
            ],
            "Resource": "arn:aws:iam::*:mfa/${aws:username}"
        },
        {
            "Sid": "AllowManageOwnUserMFA",
            "Effect": "Allow",
            "Action": [
                "iam:DeactivateMFADevice",
                "iam:EnableMFADevice",
                "iam:ListMFADevices",
                "iam:ResyncMFADevice"
            ],
            "Resource": "arn:aws:iam::*:user/${aws:username}"
        },
        {
            "Sid": "DenyAllExceptListedIfNoMFA",
            "Effect": "Deny",
            "NotAction": [
                "iam:CreateVirtualMFADevice",
                "iam:EnableMFADevice",
                "iam:GetUser",
                "iam:ListMFADevices",
                "iam:ListVirtualMFADevices",
                "iam:ResyncMFADevice",
                "sts:GetSessionToken",
                "iam:ListUsers"
            ],
            "Resource": "*",
            "Condition": {
                "BoolIfExists": {
                    "aws:MultiFactorAuthPresent": "false"
                }
            }
        }
    ]
}


Bạn copy config bên trên và paste như hình bên dưới.

Bạn có thể add thêm tag để gợi nhớ
Mình thì bỏ qua add tag và click next để review.

4.2) Create Group

CHọn policy chúng ta vừa tạo trước đó

và add thêm policy này. AdministratorAccess

Thế là tạo 1 group

4.3) Create User

Ở phần này chúng ta click vào tên group,
Điều này user sẽ được add vào group Admins và kế thừa các quền của group này.
Vậy đã tạo user xong!

5) Set MFA on IAM account

Giờ bạn login vào web aws bằng user IAM
Bạn sẽ mở lại file csv mà bạn download ở bước tạo user.
Truy cập vào console login link.

cứ thế là login thôi.
Đổi pass
Đa login thành công

Bạn quest mã QR code -> Lần thử nhất điền mã code đầu tiên –> chờ đổi mã code -> diền mã code tiếp thứ 2 vào

Giờ bạn logout và login lại thì thấy aws sẽ bắt nhập thêm MFA nhé

6) Create budget in AWS

Enter your budgeted amount ($): Số này tính bằng đơn vị Dollar. Mình ví dụ trong 1 tháng mình chỉ được tiêu 10$ thì mình set là 10.

add alert
Nếu cost của mình đặt 50% budgeted amount thì nó gửi alert đểm email mà mình
cuối cùng là bảng review tất cả

Click Create budget thôi.

AWS - Amazon Web Service

Post navigation

Previous Post: [Grafana] Error updating options: origin not allowed when you upgrade the Grafana.
Next Post: [Docker] “unsafe repository” when building the Docker image.

More Related Articles

[Golang/Redis/Riot] Redis migration from old to new infrastructure. AWS - Amazon Web Service
An AWS IAM Security Tooling Reference [2024] AWS - Amazon Web Service
Experiences for IP Addresses Shortage on EKS Clusters AWS - Amazon Web Service
[AWS] Login Argocd via Cognito in AWS ArgoCD
The Hidden Costs of CloudWatch: Why It’s So Expensive AWS - Amazon Web Service
[Terraform] Error: InvalidPermission.Duplicate: the specified rule AWS - Amazon Web Service

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Tham Gia Group DevOps nhé!
Để Nim có nhiều động lực ra nhiều bài viết.
Để nhận được những thông báo mới nhất.

Recent Posts

  • [Telegram/Openclaw] Configure openclaw bot in a Telegram group. March 31, 2026
  • Tutorial: Gateway API + Traefik + oauth2-proxy (Microsoft Entra ID) March 30, 2026
  • Full + incremental backup: When restoring, do deleted files come back? March 27, 2026
  • [K8S] Create long-lived kubeconfig on k8s March 23, 2026
  • [Android Phone] How to ssh to Android Phone. March 20, 2026

Archives

  • March 2026
  • February 2026
  • January 2026
  • December 2025
  • November 2025
  • October 2025
  • September 2025
  • August 2025
  • July 2025
  • June 2025
  • May 2025
  • April 2025
  • March 2025
  • February 2025
  • January 2025
  • December 2024
  • November 2024
  • October 2024
  • September 2024
  • August 2024
  • July 2024
  • June 2024
  • May 2024
  • April 2024
  • March 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023
  • September 2023
  • August 2023
  • July 2023
  • June 2023
  • May 2023
  • April 2023
  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021

Categories

  • AI
    • OpenClaw
  • BareMetal
    • NextCloud
  • CI/CD
    • Argo Events
    • ArgoCD
    • ArgoWorkflows
    • Git
      • Bitbucket
    • Harbor
    • Jenkins
    • Spinnaker
    • TeamCity
  • Coding
    • DevSecOps
    • Golang
    • Jquery & JavaScript
    • Laravel
    • NextJS 14 & ReactJS & Type Script
    • Python
    • Selenium
    • Terraform
      • AWS – Amazon Web Service
      • Azure Cloud
      • GCP – Google Cloud
  • Kubernetes & Container
    • Apache Kafka
      • Kafka
      • Kafka Connect
      • Lenses
    • Docker
    • Helm Chart
    • Isito-EnvoyFilter
    • Kong Gateway
    • Kubernetes
      • Gateway API
      • Ingress
      • Pod
    • Longhorn – Storage
    • MetalLB
    • OAuth2 Proxy
    • Vault
    • VictoriaMetrics
  • Log, Monitor & Tracing
    • DataDog
    • ELK
      • Kibana
      • Logstash
    • Fluent
    • Grafana
    • Prometheus
  • Uncategorized
  • Admin

Copyright © 2026 NimTechnology.