

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# AWS CodeStar Notifications のサービスにリンクされたロールの使用
<a name="using-service-linked-roles"></a>

AWS CodeStar Notifications は AWS Identity and Access Management 、(IAM)[ サービスにリンクされたロール](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_terms-and-concepts.html#iam-term-service-linked-role)を使用します。サービスにリンクされたロールは、 AWS CodeStar Notifications に直接リンクされた一意のタイプの IAM ロールです。サービスリンクロールは AWS CodeStar Notifications によって事前に定義されており、サービスがユーザーに代わって AWS の他のサービスを呼び出すために必要なすべての許可が含まれています。このロールは、通知ルールを初めて作成したときに自動的に作成されます。ユーザーがロールを作成する必要はありません。

サービスにリンクされたロールを使用すると、手動でアクセス許可を追加する必要がないため、 AWS CodeStar Notifications の設定が簡単になります。 AWS CodeStar Notifications は、サービスにリンクされたロールのアクセス許可を定義し、特に定義されている場合を除き、 AWS CodeStar Notifications のみがそのロールを引き受けることができます。定義される許可は信頼ポリシーと許可ポリシーに含まれており、その許可ポリシーを他の IAM エンティティにアタッチすることはできません。

サービスにリンクされたロールを削除するには、まず関連するリソースを削除する必要があります。これにより、リソースへのアクセス許可が誤って削除されないため、 AWS CodeStar Notifications リソースが保護されます。

サービスにリンクされたロールをサポートしているその他のサービスの詳細については、「[IAM と連携するAWS のサービス](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_aws-services-that-work-with-iam.html)」を参照してください。

## AWS CodeStar Notifications のサービスにリンクされたロールのアクセス許可
<a name="slr-permissions"></a>

AWS CodeStar Notifications は、AWSServiceRoleForCodeStarNotifications サービスにリンクされたロールを使用して、ツールチェーンで発生するイベントに関する情報を取得し、指定したターゲットに通知を送信します。

AWSServiceRoleForCodeStarNotifications サービスリンクロールは、以下のサービスを信頼してロールを引き受けます。
+ `codestar-notifications.amazonaws.com`

ロールのアクセス許可ポリシーにより、 AWS CodeStar Notifications は指定されたリソースに対して次のアクションを実行できます。
+ アクション: `PutRule`。対象リソース: `CloudWatch Event rules that are named awscodestar-notifications-*`
+ アクション: `CloudWatch Event rules that are named awscodestar-notifications-*` 上で `DescribeRule`
+ アクション: `PutTargets`。対象リソース: `CloudWatch Event rules that are named awscodestar-notifications-*`
+ アクション: `CreateTopic` (`create Amazon SNS topics for use with AWS CodeStar Notifications with the prefix CodeStarNotifications-` が対象)
+ アクション: `GetCommentsForPullRequests`。対象リソース: `all comments on all pull requests in all CodeCommit repositories in the AWS account`
+ アクション: `all comments on all commits in all CodeCommit repositories in the AWS account` 上で `GetCommentsForComparedCommit`
+ アクション: `all commits in all CodeCommit repositories in the AWS account` 上で `GetDifferences`
+ アクション: `all comments on all commits in all CodeCommit repositories in the AWS account` 上で `GetCommentsForComparedCommit`
+ アクション: `all commits in all CodeCommit repositories in the AWS account` 上で `GetDifferences`
+ アクション: `all AWS Chatbot clients in the AWS account` 上で `DescribeSlackChannelConfigurations`
+ アクション: `all AWS Chatbot clients in the AWS account` 上で `UpdateSlackChannelConfiguration`
+ アクション: `all actions in all pipelines in the AWS account` 上で `ListActionExecutions`
+ アクション: `GetFile`。対象リソース: `all files in all CodeCommit repositories in the AWS account unless otherwise tagged`

これらのアクションは、AWSServiceRoleForCodeStarNotifications サービスにリンクされたロールのポリシーステートメントで確認できます。

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Action": [
                "events:PutTargets",
                "events:PutRule",
                "events:DescribeRule"
            ],
            "Resource": "arn:aws:events:*:*:rule/awscodestarnotifications-*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "sns:CreateTopic"
            ],
            "Resource": "arn:aws:sns:*:*:CodeStarNotifications-*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "codecommit:GetCommentsForPullRequest",
                "codecommit:GetCommentsForComparedCommit",
                "codecommit:GetDifferences",
                "chatbot:DescribeSlackChannelConfigurations",
                "chatbot:UpdateSlackChannelConfiguration",
                "codepipeline:ListActionExecutions"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "codecommit:GetFile"
            ],
            "Resource": "*",
            "Condition": {
                "StringNotEquals": {
                    "aws:ResourceTag/ExcludeFileContentFromNotifications": "true"
                }
            },
            "Effect": "Allow"
        }
    ]
}
```

------

サービスリンクロールの作成、編集、削除を IAM エンティティ (ユーザー、グループ、ロールなど) に許可するにはアクセス許可を設定する必要があります。詳細については、「*IAM ユーザーガイド*」の「[サービスリンクロールの許可](https://docs.aws.amazon.com/IAM/latest/UserGuide/using-service-linked-roles.html#service-linked-role-permissions)」を参照してください。

## AWS CodeStar Notifications のサービスにリンクされたロールの作成
<a name="create-slr"></a>

サービスリンクロールを手動で作成する必要はありません。開発者ツールコンソールまたは AWS CLI または SDKs の CreateNotificationRule API を使用して、通知ルールを作成できます。API を直接呼び出すこともできます。使用する方法にかかわらず、サービスにリンクされたロールが作成されます。

このサービスリンクロールを削除した後で再度作成する必要が生じた場合は同じ方法でアカウントにロールを再作成できます。開発者ツールコンソールまたは AWS CLI または SDKs の CreateNotificationRule API を使用して、通知ルールを作成できます。API を直接呼び出すこともできます。使用する方法にかかわらず、サービスにリンクされたロールが作成されます。

## AWS CodeStar Notifications のサービスにリンクされたロールの編集
<a name="edit-slr"></a>

サービスにリンクされたロールを作成すると、多くのエンティティによってロールが参照される可能性があるため、名前を変更することはできません。ただし、IAM を使用してロールの説明を編集することはできます。詳細については、「*IAM ユーザーガイド*」の「[サービスリンクロールの編集](https://docs.aws.amazon.com/IAM/latest/UserGuide/using-service-linked-roles.html#edit-service-linked-role)」を参照してください。

## AWS CodeStar Notifications のサービスにリンクされたロールの削除
<a name="delete-slr"></a>

サービスにリンクされたロールが必要な機能またはサービスが不要になった場合には、そのロールを削除することをお勧めします。そうすることで、使用していないエンティティがアクティブにモニタリングされたり、メンテナンスされたりすることがなくなります。削除する前に、サービスにリンクされたロールのリソースをクリーンアップする必要があります。 AWS CodeStar Notifications の場合、これは AWS アカウントでサービスロールを使用するすべての通知ルールを削除することを意味します。

**注記**  
リソースを削除しようとしたときに AWS CodeStar Notifications サービスがロールを使用している場合は、削除が失敗する可能性があります。失敗した場合は数分待ってから操作を再試行してください。

**AWSServiceRoleFor AWS CodeStar Notificationsで使用される CodeStar Notifications リソースを削除するには AWSServiceRoleForCodeStarNotifications**

1. [https://console.aws.amazon.com/codesuite/settings/notifications](https://console.aws.amazon.com/codesuite/settings/notifications/) で AWS デベロッパーツールコンソールを開きます。
**注記**  
通知ルールは、作成された AWS リージョンに適用されます。複数の AWS リージョンに通知ルールがある場合は、リージョンセレクタを使用して を変更します AWS リージョン。

1. リストに表示されるすべての通知ルールを選択し、 [**Delete (削除)**] を選択します。

1. 通知ルールを作成したすべての AWS リージョンで、これらのステップを繰り返します。

****IAM を使用**して、サービスにリンクされたロールを削除するには**

IAM コンソール AWS CLI、または AWS Identity and Access Management API を使用して、AWSServiceRoleForCodeStarNotifications サービスにリンクされたロールを削除します。詳細については、「[IAM ユーザーガイド](https://docs.aws.amazon.com/IAM/latest/UserGuide/using-service-linked-roles.html#delete-service-linked-role)」の「*サービスリンクロールの削除*」を参照してください。

## AWS CodeStar Notifications サービスにリンクされたロールでサポートされているリージョン
<a name="slr-regions"></a>

AWS CodeStar Notifications は、サービスが利用可能なすべての AWS リージョンでサービスにリンクされたロールの使用をサポートしています。詳細については、「[AWS のリージョンとエンドポイント](https://docs.aws.amazon.com/general/latest/gr/rande.html)」および「[AWS CodeStar Notifications](https://docs.aws.amazon.com/general/latest/gr/codestar_notifications.html)」を参照してください。