CodePipeline で SNS を設定した承認アクションが即却下される事象を回避するには
困っていた内容
CodePipeline で Amazon SNS トピックを設定した承認アクションを追加しました。
パイプラインを実行すると、承認アクションが自動的に「失敗しました」になり、ステータスは「却下されました」でした。
却下はしていませんが、なぜ失敗したのでしょうか。
どう対応すればいいの?
パイプラインの「履歴」から「実行概要」を確認してください。
2025年4月時点の挙動として、SNS トピックを設定した承認アクションで SNS の権限が許可されていない場合、承認アクションは自動的に却下されます。
また「実行概要」には次のようなエラーが表示されます。
The Pipeline or Action role does not have permission to publish to topics in Amazon SNS. Add the sns:Publish permission to the role’s policy, and then try again.
そのため、CodePipeline のサービスロールで SNS の権限を許可していない場合は、サービスロールに権限を追加してください。
なお、付与する権限のサンプルはドキュメントに記載があります。
Amazon SNS アクセス権限を CodePipeline サービスロールに付与する - AWS CodePipeline
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "sns:Publish",
"Resource": "*"
}
]
}
また、エラーは AWS CLI のlist-action-executionsコマンドからも確認できます。
$ aws codepipeline list-action-executions \
--pipeline-name hato-CodePipeline-Approve
...(中略)...
"output": {
"outputArtifacts": [],
"executionResult": {
"externalExecutionId": "378bc66c-a836-46e5-8659-9897eed2118a",
"externalExecutionSummary": "The Pipeline or Action role does not have permission to publish to topics in Amazon SNS. Add the sns:Publish permission to the role’s policy, and then try again.",
"errorDetails": {
"code": "PermissionError"
}
},
"outputVariables": {}
}
},