(cli): Support a least-privilege diff-only IAM role for `cdk diff`

オープン
#1,123 コメント 2 件 リアクション 5 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
aws, typescript
領域
cli, cloud, security

調査の方向性

CDK CLI の cdk diff エントリポイントから開始し、その change-set、deploy-role、asset-publishing ロールの引き受けを追跡します。これらの経路を提案されている diff-role オプションと比較します。完了の定義は、明示的および自動の選択が解決され、cdk diff が、deployment または execute の権限なしに change set と必要なアセットを作成できる least-privilege ロールを使用できることです。

索引モデルが issue の本文から書いたものです。

説明

aws-cdk effort/medium feature-request p2
Describe the feature

There is currently no way to run cdk diff using a read-only or least-privilege IAM role when using the AWS CDK CLI.

Even though cdk diff is a non-deploying operation, the CLI requires permissions equivalent to deployment roles (including assuming deploy and asset publishing roles). This makes it difficult to use cdk diff safely in CI environments.

I am proposing support in the CDK CLI for a diff-only IAM role that allows secure execution of cdk diff without granting full deployment capabilities.

Use Case

In CI pipelines, I want to run cdk diff automatically to provide visibility into infrastructure changes without introducing a manual approval gate.

Using a role with deployment-level permissions in CI is risky: if the workflow is modified or compromised, the role could be abused to deploy or modify infrastructure.

Today, there is no secure alternative:

  • cdk diff creates a CloudFormation change set
  • This requires assuming the deploy role
  • For stacks with assets, the CLI also attempts to assume file-publishing and image-publishing roles

As a result, it is currently impossible to run cdk diff with a read-only or least-privilege role using the CDK CLI, unless one builds a custom diff workflow outside the CLI.

Proposed Solution

Add first-class support in the CDK CLI for a diff-only role with limited permissions.

Conceptually, this role would:

  • Allow creation of CloudFormation change sets
  • Explicitly deny cloudformation:ExecuteChangeSet
  • Allow asset-related actions required for diffing:
    • S3 uploads for Code.fromAsset
    • Optional asset handling only when relevant
  • Have no permissions to deploy, update, or delete stacks

Possible implementation approaches:

  • Bootstrap an optional diff-role alongside existing toolkit roles
  • Allow explicitly specifying a diff role via CLI flags (e.g. cdk diff --role-arn ...)
  • Automatically select a diff role when running cdk diff

This would preserve accurate change-set–based diffs while significantly improving security for CI usage.

Other Information

No response

Acknowledgements
  • I may be able to implement this feature request
  • This feature might incur a breaking change
CDK version used

2.1105.0

Environment details (OS name and version, etc.)

Ubuntu 24.04

主要言語
TypeScript
スター
110
フォーク
138
平均マージ
1日 9時間
マージ済み PR(30日)
55

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

aws/aws-cdk-cli のほかの issue

aws/aws-cdk-cli の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。