Using service-linked roles for Amazon Inspector - Amazon Inspector

Using service-linked roles for Amazon Inspector

Amazon Inspector uses AWS Identity and Access Management (IAM) service-linked roles. A service-linked role is a unique type of IAM role that is linked directly to Amazon Inspector. Service-linked roles are predefined by Amazon Inspector and include all the permissions that the service requires to call other AWS services on your behalf.

A service-linked role makes setting up Amazon Inspector easier because you don’t have to manually add the necessary permissions. Amazon Inspector defines the permissions of its service-linked roles, and unless defined otherwise, only Amazon Inspector can assume its roles. The defined permissions include the trust policy and the permissions policy, and that permissions policy cannot be attached to any other IAM entity.

You can delete a service-linked role only after first deleting their related resources. This protects your Amazon Inspector resources because you can't inadvertently remove permission to access the resources.

For information about other services that support service-linked roles, see AWS Services That Work with IAM and look for the services that have Yes in the Service-Linked Role column. Choose a Yes with a link to view the service-linked role documentation for that service.

Service-linked role permissions for Amazon Inspector

Amazon Inspector uses the service-linked role named AWSServiceRoleForAmazonInspector2.

The AWSServiceRoleForAmazonInspector2 service-linked role trusts the following services to assume the role:

  • inspector2.amazonaws.com

The permissions policy named AmazonInspector2ServiceRolePolicy allows Amazon Inspector to perform tasks such as:

  • Use Amazon EC2 actions to retrieve information about your instances and network paths.

  • Use AWS Systems Manager actions to retrieve inventory from your Amazon EC2 instances.

  • Use Amazon ECR actions to retrieve information about your container images.

  • Use AWS Organizations actions to describe associated accounts.

For details about updates to the AWSServiceRoleForAmazonInspector2 policy, see Amazon Inspector updates to AWS managed policies.

You must configure permissions to allow an IAM entity (such as a user, group, or role) to create, edit, or delete a service-linked role. For more information, see Service-Linked Role Permissions in the IAM User Guide.

Creating a service-linked role for Amazon Inspector

You don't need to manually create a service-linked role. When you enable the service in the AWS Management Console, the AWS CLI, or the AWS API, Amazon Inspector creates the service-linked role for you.

Editing a service-linked role for Amazon Inspector

Amazon Inspector does not allow you to edit the AWSServiceRoleForAmazonInspector2 service-linked role. After you create a service-linked role, you cannot change the name of the role because various entities might reference the role. However, you can edit the description of the role using IAM. For more information, see Editing a Service-Linked Role in the IAM User Guide.

Deleting a service-linked role for Amazon Inspector

If you no longer need to use Amazon Inspector, we recommend that you delete the AWSServiceRoleForAmazonInspector2 service-linked role. Before you can delete the role, you must disable Amazon Inspector in each AWS Region where it's enabled. When you disable Amazon Inspector, it doesn't delete the role for you. Therefore, if you enable Amazon Inspector again, it can use the existing role. That way you don’t have an unused entity that is not actively monitored or maintained. However, you must clean up the resources for your service-linked role before you can manually delete it.

If you delete this service-linked role and then need to create it again, you can use the same process to re-create the role in your account. When you enable Inspector, Inspector re-creates the service-linked role for you.

Note

If the Amazon Inspector service is using the role when you try to delete the resources, then the deletion might fail. If that happens, wait for a few minutes and try the operation again.

To manually delete the service-linked role using IAM

Use the IAM console, the AWS CLI, or the AWS API to delete the AWSServiceRoleForAmazonInspector2 service-linked role. For more information, see Deleting a Service-Linked Role in the IAM User Guide.