简体   繁体   English

AWS实例配置文件与IAM用户角色

[英]AWS instance profile vs IAM user role

In terms of security, which option is better for handling permissions on a Jenkins EC2 instance, an instance profile or a IAM user with a role? 在安全性方面,哪个选项更适合处理Jenkins EC2实例,实例配置文件或具有角色的IAM用户的权限?

An instance profile allows anyone who has access to the box to run the specified aws cli commands. 实例配置文件允许有权访问该框的任何人运行指定的aws cli命令。 With an IAM jenkins user, one could limit who is able to run the aws cli commands by locking down credential files on the instance. 使用IAM jenkins用户,可以通过锁定实例上的凭据文件来限制谁能够运行aws cli命令。 Is there any benefit to using an instance profile? 使用实例配置文件有什么好处?

I think in your case both methods are comparable - please think what will happen when you have leakage of your IAM jenkins user access key (please note that security fixes comes to Jenkins quite often): intruder can access AWS API from his PC even without direct access to your infrastructure. 我认为在您的情况下,这两种方法是可比的-请考虑当您泄漏IAM jenkins用户访问密钥时会发生什么(请注意,Jenkins经常会进行安全修复):入侵者甚至可以直接从其PC访问AWS API访问您的基础架构。 So to avoid that problem you need probably to set proper policy as described here: https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_examples_aws_deny-ip.html but it means that you need to hardcode there your instance IP what can hit you in the future. 因此,为避免该问题,您可能需要按如下所述设置适当的策略: https : //docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_examples_aws_deny-ip.html,但这意味着您需要在此处对实例进行硬编码IP将来会给您带来什么影响。

On the other hand instance profile is more elastic but as you mentioned - when intruder has direct access to machine he can send request to AWS API. 另一方面,实例配置文件更具弹性,但是正如您提到的那样,当入侵者可以直接访问计算机时,他可以将请求发送到AWS API。 So I think you need to consider what level of security you need and how much time you want to spend on maintenance of that solution. 因此,我认为您需要考虑所需的安全级别以及要花多少时间来维护该解决方案。

The IAM role can't be directly attached to the Jenkins instance , so create a profile and ref IAM role in it and then attach that profile to you instance. IAM角色不能直接附加到Jenkins实例,因此请在其中创建配置文件并引用IAM角色,然后将该配置文件附加到您的实例。 Passing credential file to instance is not among best practices. 将凭证文件传递到实例不是最佳实践。 If i join your company and get access to the key , then even after leaving the company i will have access to those keys which i can use in future provided you don't remove those keys and generally on instances people keep the keys stagnant because of it's use by multiple applications. 如果我加入了您的公司并可以访问该密钥,那么即使您离开公司后,我也将可以访问那些将来可以使用的密钥,前提是您不删除这些密钥,并且在某些情况下,人们通常会因为以下原因而使密钥停滞不前它被多个应用程序使用。

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

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