【问题标题】:Adding permission to IAM role向 IAM 角色添加权限
【发布时间】:2017-10-18 02:10:23
【问题描述】:

我想向我的实例的 IAM 角色添加权限,以允许使用 Cloudwatch 日志服务。在查看服务的Configuration Guide 时,我看到以下段落:

The CloudWatch Logs agent supports IAM roles and users. 
If your instance already has an IAM role associated with it, make sure that you include the IAM policy below. 
If you don't already have an IAM role assigned to your instance, 
  you'll need to use your IAM credentials for the next steps because you cannot assign an IAM role to an existing instance; 
  you can only specify a role when you launch a new instance.

我很难弄清楚这到底意味着什么。当我创建一个新实例时,我使用 CloudWatchLogsFullAccess 策略和配置指南告诉您添加的内联策略创建了一个 IAM 角色:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "logs:CreateLogGroup",
        "logs:CreateLogStream",
        "logs:PutLogEvents",
        "logs:DescribeLogStreams"
    ],
      "Resource": [
        "arn:aws:logs:*:*:*"
    ]
  }
 ]
}

这是一个新实例,但是上面的段落让我对向现有实例添加权限感到困惑。我可以将CloudWatchLogsFullAccess 策略添加到现有实例的角色以及该内联策略吗?

【问题讨论】:

    标签: amazon-web-services amazon-iam


    【解决方案1】:

    虽然 IAM 角色确实只能在实例启动期间分配给实例,但 AWS 在 2017 年 2 月宣布,现在可以将 IAM 角色替换或附加到现有实例。

    使用 AWS 控制台Easily Replace or Attach an IAM Role to an Existing EC2 Instance by Using the EC2 Console

    使用 AWS CLIAttach an AWS IAM Role to an Existing Amazon EC2 Instance by Using the AWS CLI

    【讨论】:

    • 准确吗?我有一个脚本,它创建一个 RDS 集群,然后分配一个角色(在这种情况下,添加 S3 访问)Add-RDSRoleToDBCluster -DBClusterIdentifier $cluster.DBClusterIdentifier ` -RoleArn $roleARN ` -Credential $credentials ` -Region $paramHash 。地区;不过值得一提的是,这是RDS,不使用Lambda(IIRC)是无法正常继承角色的。
    • @mbourgon 回答时是准确的(2016 年 8 月 26 日)。 AWS 在 2017 年增加了为正在运行的实例分配角色的支持。
    猜你喜欢
    • 2022-07-27
    • 1970-01-01
    • 2021-01-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-08-18
    • 1970-01-01
    • 2020-12-06
    相关资源
    最近更新 更多