简体   繁体   English

向IAM角色添加权限

[英]Adding permission to IAM role

I want to add permissions to my instance's IAM roles to allow for the use of Cloudwatch Log Service. 我想向我的实例的IAM角色添加权限,以允许使用Cloudwatch Log Service。 Upon looking at the Configuration Guide for the service, I see the following passage: 查看该服务的《 配置指南 》后,我看到以下段落:

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.

I'm having a hard time figuring exactly what this means. 我很难弄清楚这到底意味着什么。 When I created a new instance, I made an IAM role with the CloudWatchLogsFullAccess policy and an inline policy the configuration guide tells you to add: 创建新实例时,我使用CloudWatchLogsFullAccess策略和内联策略创建了IAM角色,配置指南告诉您添加:

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

This was for a new instance, however the above passage confuses me about adding permissions to existing instances. 这是一个新实例,但是以上内容使我对向现有实例添加权限感到困惑。 Can I just add the CloudWatchLogsFullAccess policy to the existing instance's role and that inline policy as well? 是否可以仅将CloudWatchLogsFullAccess策略添加到现有实例的角色以及该内联策略中?

While it was true an IAM role can be assigned to an instance only during instance launch, AWS announced in February 2017 that it is now possible to replace or attach an IAM role to an existing instance. 虽然确实可以仅在实例启动期间将IAM角色分配给实例,但AWS在2017年2月宣布,现在可以将IAM角色替换或附加到现有实例。

Using AWS Console : Easily Replace or Attach an IAM Role to an Existing EC2 Instance by Using the EC2 Console 使用AWS控制台使用EC2控制台轻松将IAM角色替换或附加到现有EC2实例

Using AWS CLI : Attach an AWS IAM Role to an Existing Amazon EC2 Instance by Using the AWS CLI 使用AWS CLI通过使用AWS CLI 将AWS IAM角色附加到现有Amazon EC2实例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM