Using Service-Linked Roles for Amazon Compute Optimizer - Amazon Compute Optimizer
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Using Service-Linked Roles for Amazon Compute Optimizer

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

With a service-linked role,setting up Compute Optimizer doesn't require manually adding the necessary permissions. Compute Optimizer defines the permissions of its service-linked roles, and unless defined otherwise, only Compute Optimizer 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.

For information about other services that support service-linked roles, see Amazon 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 Compute Optimizer

Compute Optimizer uses the service-linked role that's named AWSServiceRoleForComputeOptimizer to access Amazon CloudWatch metrics for Amazon resources in the account.

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

  • compute-optimizer.amazonaws.com

The role permissions policy allows Compute Optimizer to complete the following actions on the specified resources:

  • Action: cloudwatch:GetMetricData on all Amazon resources.

  • Action: organizations:DescribeOrganization on all Amazon resources.

  • Action: organizations:ListAccounts on all Amazon resources.

  • Action: organizations:ListAWSServiceAccessForOrganization on all Amazon resources.

Service-Linked Role permissions

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

To allow an IAM entity to create a specific service-linked role for Compute Optimizer

Add the following policy to the IAM entity that needs to create the service-linked role.

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "iam:CreateServiceLinkedRole", "Resource": "arn:aws-cn:iam::*:role/aws-service-role/compute-optimizer.amazonaws.com/AWSServiceRoleForComputeOptimizer*", "Condition": {"StringLike": {"iam:AWSServiceName": "compute-optimizer.amazonaws.com"}} }, { "Effect": "Allow", "Action": "iam:PutRolePolicy", "Resource": "arn:aws-cn:iam::*:role/aws-service-role/compute-optimizer.amazonaws.com/AWSServiceRoleForComputeOptimizer" }, { "Effect": "Allow", "Action": "compute-optimizer:UpdateEnrollmentStatus", "Resource": "*" }, { "Effect": "Allow", "Action": "organizations:DescribeOrganization", "Resource": "*" } ] }

To allow an IAM entity to create any service-linked role

Add the following statement to the permissions policy for the IAM entity that needs to create a service-linked role, or any service role that includes the needed policies. This policy attaches a policy to the role.

{ "Effect": "Allow", "Action": "iam:CreateServiceLinkedRole", "Resource": "arn:aws-cn:iam::*:role/aws-service-role/*" }

Creating a Service-Linked Role for Compute Optimizer

You don't need to manually create a service-linked role. When you opt in to the Compute Optimizer service in the Amazon Web Services Management Console, the Amazon CLI, or the Amazon API, Compute Optimizer creates the service-linked role for you.

Important

If you completed an action in another service that uses the features supported by the service-linked role, the role can appear in your account. For more information, see A New Role Appeared in My IAM Account.

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

Editing a Service-Linked Role for Compute Optimizer

Compute Optimizer doesn't allow you to edit the AWSServiceRoleForComputeOptimizer service-linked role. After you create a service-linked role, you can't 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 Compute Optimizer

We recommend that, if you no longer need to use Compute Optimizer, you delete the AWSServiceRoleForComputeOptimizer service-linked role. That way you don’t have an unused entity that's not actively monitored or maintained. However, before you can manually delete the service-linked role, you must opt out of Compute Optimizer.

To opt out of Compute Optimizer

For information about opting out of Compute Optimizer, see Opting out your account.

To manually delete the service-linked role using IAM

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

Supported Regions for Compute Optimizer Service-Linked Roles

Compute Optimizer supports using service-linked roles in all of the Regions where the service is available. To view the currently supported Amazon Web Services Regions and endpoints for Compute Optimizer, see Compute Optimizer Endpoints and Quotas in the Amazon General Reference.