Using Service-Linked Roles for AWS Compute Optimizer - AWS Compute Optimizer

Using Service-Linked Roles for AWS Compute Optimizer

AWS Compute Optimizer 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 Compute Optimizer. Service-linked roles are predefined by Compute Optimizer and include all of the permissions that the service requires to call other AWS services on your behalf.

A service-linked role makes setting up Compute Optimizer easier because you don’t have to manually add 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 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 Compute Optimizer

Compute Optimizer uses the service-linked role named AWSServiceRoleForComputeOptimizer – Role to access Amazon CloudWatch metrics for AWS 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 AWS resources.

  • Action: organizations:DescribeOrganization on all AWS resources.

  • Action: organizations:ListAccounts on all AWS resources.

  • Action: organizations:ListAWSServiceAccessForOrganization on all AWS resources.

Service-Linked Role permissions

You must configure permissions to allow an IAM entity (such as a user, group, or role) to create a service-linked role for Compute Optimizer. 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: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:iam::*:role/aws-service-role/compute-optimizer.amazonaws.com/AWSServiceRoleForComputeOptimizer" } ] }

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: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 AWS Management Console, the AWS CLI, or the AWS API, Compute Optimizer creates the service-linked role for you.

Important

This service-linked role can appear in your account if you completed an action in another service that uses the features supported by this role. 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 does not allow you to edit the AWSServiceRoleForComputeOptimizer 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 Compute Optimizer

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

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 AWS CLI, or the AWS 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. For more information, see AWS Regions and Endpoints.