CircleCIから複数のAWSアカウント、たとえばステージング環境とプロダクション環境(本番環境)へ、安全にデプロイする方法を記載します。 課題 CircleCIはAWSのCodePipeline等より使い勝手が良いのでAWSのプロダクション環境へのデプロイに使いたい しかしステージング環境とプロダクション環境は別のAWSアカウントで構築しておりIAMのアクセスキーの切り替えが必要 そしてIAM権限をAWSの外に出すのはセキュリティ上の懸念がある 対策 別アカウントなので認証情報の切り替えが必要 => CircleCIのContextsを利用する IAM権限をAWSの外に出すのはセキュリティ懸念がある => 利用するときだけIAMアクセスキーを有効化する Slackから簡単にキーの有効/無効を切り替えられるようにしておきましょう 順に説明してゆきます。 ブランチごとにAWS認証情報を切り