Tạo IAM Role

  1. Truy cập AWS Management Console

    • Tìm IAM
    • Chọn IAM

    Create IAM Role

  2. Trong giao diện IAM

    • Chọn Policies
    • Chọn Create policies

    Create IAM Role

  3. Trong giao diện Create policies

    • Copy đoạn policy dưới đây:
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "AllowReadingMetricsFromCloudWatch",
      "Effect": "Allow",
      "Action": [
        "cloudwatch:DescribeAlarmsForMetric",
        "cloudwatch:ListMetrics",
        "cloudwatch:GetMetricStatistics",
        "cloudwatch:GetMetricData"
      ],
      "Resource": "*"
    },
    {
      "Sid": "AllowReadingTagsInstancesRegionsFromEC2",
      "Effect": "Allow",
      "Action": ["ec2:DescribeTags", "ec2:DescribeInstances", "ec2:DescribeRegions"],
      "Resource": "*"
    },
    {
      "Sid": "AllowReadingResourcesForTags",
      "Effect": "Allow",
      "Action": "tag:GetResources",
      "Resource": "*"
    }
  ]
}
  • Chọn JSON và tiến hành paste đoạn json policy vào text area

Create IAM Role

  • Chọn Next

Create IAM Role

  1. Trong giao diện Create policy

    • Nhập tên policy là GrafanaAccessPolicy

    Create IAM Role

  2. Trong phần Tag nhập giá trị key và value

    • Key, nhập Name
    • Value, nhập GrafanaAccessPolicy
    • Chọn Create policy

    Create IAM Role

  3. Vậy chúng ta đã tạo policy cho Role thành công

    Create IAM Role

  4. Trong giao diện IAM

    • Chọn Roles
    • Chọn Create role

    Create IAM Role

  5. Trong giao diện Select trusted entity

    • Chọn AWS service
    • Chọn EC2

    Create IAM Role

    • Kéo xuống và chọn Next

    Create IAM Role

  6. Trong giao diện Add permissions

    • Tìm và chọn GrafanaAccessPolicy
    • Chọn Next

    Create IAM Role

  7. Trong bước Name, review and create

    • Role name, nhập GrafanaAccessRole
    • Description, nhập Role for Grafana Access

    Create IAM Role

  8. Kéo xuống và chọn Create role

    Create IAM Role

    Create IAM Role

  9. Hoàn thành tạo role cho EC2 instance