LoginSignup
1
0

More than 3 years have passed since last update.

達成感溢れるCodePipeline承認(物理)

Last updated at Posted at 2019-06-19

どうしても手動がないと落ち着かない人たちのために、CI/CDへSORACOM LTE-M Buttonから承認をできるようにしました。
ぜひ「承認実行!」と叫んで押していただきたい。

デモ

構成

今回は練習もかねてCodeStarでCodeシリーズを初期化しています。
CodePipeline承認フロー.png
※Manual approvalは文中で追加します。

Lambdaの作成

IAMロール

通常のIAMロールのほかPipelineを操作するので以下を追加してください

IAM
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": "codepipeline:GetPipelineState",
            "Resource": "arn:aws:codepipeline:【リージョン】:【アカウント】:【パイプライン名】"
        },
        {
            "Sid": "VisualEditor1",
            "Effect": "Allow",
            "Action": "codepipeline:PutApprovalResult",
            "Resource": "arn:aws:codepipeline:【リージョン】:【アカウント】:【パイプライン名】/【ステージ名】/【アクション名】"
        }
    ]
}

※パイプライン/ステージ/アクションは名前です。IDの類いではありませんので注意

Lambdaのコード

こちらのgistからコピペしてください。
ダブルクリックに承認、それ以外に否認を割り当てています。

Pipelineへ承認の追加

  1. 「ステージを追加する」を押下
  2. IAMで設定した名前に合うステージ名を付ける
  3. 「アクショングループを追加する」を押下
  4. IAMで設定した名前に合うアクション名を付ける
  5. アクションプロバイダー「Manual approval」を選択
  6. 「完了」を押下
  7. 「保存する」を押下

※本説明はCodePipelineがCodeStar等であらかじめ承認以外ができている前提です。

ボタンの設定

プレイスメントの属性として以下を定義してください

属性の名前
actionName 【パイプライン名】
pipelineName 【ステージ名】
stageName 【アクション名】

参考文献

https://docs.aws.amazon.com/ja_jp/codepipeline/latest/userguide/approvals-approve-or-reject.html#approvals-approve-or-reject-cli
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/codepipeline.html
https://docs.aws.amazon.com/ja_jp/codepipeline/latest/userguide/iam-access-control-identity-based.html

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0