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
      • Ingress
    • Helm Chart
    • Isito-EnvoyFilter
    • Apache Kafka
      • Kafka
      • Kafka Connect
      • Lenses
    • Vault
    • Longhorn – Storage
    • VictoriaMetrics
  • CI/CD
    • ArgoCD
    • ArgoWorkflows
    • Spinnaker
    • Jenkins
  • Coding
    • Terraform
      • GCP – Google Cloud
      • AWS – Amazon Web Service
    • Golang
    • Laravel
    • Jquery & JavaScript
    • Git
    • Selenium
  • Log & Monitor
    • Prometheus
    • Grafana
    • ELK
      • Kibana
      • Logstash
  • BareMetal
  • 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

  • 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

[Terraform] – Terraform Beginner – Lesson 3: Terraform with AWS AWS - Amazon Web Service
[Terraform] – Terraform Beginner – Lesson 8: Terraform Functions and Conditional Expressions AWS - Amazon Web Service
[Terraform] – Terraform Beginner – Lesson 4: Remote State AWS - Amazon Web Service
[Terraform] – Terraform Beginner – Lesson 2: Working with Terraform. AWS - Amazon Web Service
[Terraform] Error: Error acquiring the state lock AWS - Amazon Web Service
[Terraform] – Terraform Beginner – Lesson 9: Terraform with AWS – part 2 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

  • [Argocd/Vault] Integrate Vault inside Argocd by the plugin July 1, 2022
  • [Vault] Using Service Acount of Kubernetes to login Vault system. June 28, 2022
  • Protected: My Assignment  June 24, 2022
  • [Spinnaker] Spinnaker writes too many logs – Reduce spinnaker log level June 22, 2022
  • [Jenkins] Jobs will be created automatically by Jenkins Job Builder June 20, 2022

Archives

  • 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

  • BareMetal
  • CI/CD
    • ArgoCD
    • ArgoWorkflows
    • Jenkins
    • Spinnaker
  • Coding
    • Git
    • Golang
    • Jquery & JavaScript
    • Laravel
    • Selenium
    • Terraform
      • AWS – Amazon Web Service
      • GCP – Google Cloud
  • Kubernetes & Container
    • Apache Kafka
      • Kafka
      • Kafka Connect
      • Lenses
    • Docker
    • Helm Chart
    • Isito-EnvoyFilter
    • Kubernetes
      • Ingress
    • Longhorn – Storage
    • Vault
    • VictoriaMetrics
  • Log & Monitor
    • ELK
      • Kibana
      • Logstash
    • Grafana
    • Prometheus
  • Uncategorized
  • Admin

Copyright © 2022 NimTechnology.