AI サービスのオプトアウトポリシーを OU に適用してみた

AI サービスのオプトアウトポリシーを OU に適用してみた

Clock Icon2025.03.03

こんにちは!クラウド事業本部コンサルティング部のたかくに(@takakuni_)です。

皆さんは AWS のサービス規約を、ご覧になったことはありますでしょうか?

いくつかの AWS で提供される AI サービスには、サービス向上のために AWS 側で収集したデータを利用できる権利を有するものがあります。該当するリソースは、サービス規約からご覧ください。(たとえば、Amazon Q Developer の無料利用枠 [1] などが挙げられます。)

https://aws.amazon.com/service-terms/?nc1=h_ls

ただし、利用者側は上記の権利を Organizations の AI サービスのオプトアウトポリシー、 利用する IDE のオプトアウト設定、該当するサービスごとに用意されているオプトアウトメカニズム等を利用することで、オプトアウトできます。

50.3. You agree and instruct that for Amazon CodeGuru Profiler, Amazon Comprehend, Amazon Lex, Amazon Polly, Amazon Rekognition, Amazon Textract, Amazon Transcribe, and Amazon Translate: (a) we may use and store AI Content that is processed by each of the foregoing AI Services to develop and improve the applicable AI Service and its underlying technologies; (b) we may use and store AI Content that is not personal data to develop and improve AWS and affiliate machine-learning and artificial-intelligence technologies; and (c) solely in connection with the development and improvement described in clauses (a) and (b), we may store such AI Content in an AWS region outside of the AWS region where you are using such AI Service. This Section does not apply to Amazon Comprehend Medical, Amazon Transcribe Medical, AWS HealthScribe, Amazon Comprehend Detect PII or any AI Service that is not listed in the first sentence of this Section 50.3. You may instruct AWS not to use and store AI Content processed by an AI Service to develop and improve that Service or technologies of AWS or its affiliates by configuring an AI services opt-out policy using AWS Organizations. For access to AI Services via AWS Builder ID, you may instruct AWS to refrain from using and storing AI Content processed by an AI Service to develop and improve that Service or technologies of AWS or its affiliates by using the opt-out mechanism indicated in the applicable service documentation.

50.13. Amazon Q. To help Amazon Q provide the most relevant information, we may use AI Content processed by Amazon Q, such as prompts and responses (“Amazon Q Content”), for service improvement as described below. Currently, this Section 50.13 applies only to Amazon Q Developer Free Tier, but we may add Amazon Q features from time to time as they launch. This Section 50.13 does not apply to Amazon Q Business or Amazon Q Developer Pro.

50.13.1. Service Improvement. You agree and instruct that we may use Amazon Q Content to develop and improve Amazon Q and its underlying technologies, and for that purpose we may store Amazon Q Content in an AWS region outside of the AWS region where you are using Amazon Q.

50.13.2. Other Service Improvement. You agree and instruct that we may also use Amazon Q Content that does not contain personal data to develop and improve AWS and affiliate machine-learning and artificial intelligence technologies including to train machine-learning models.

50.13.3. Further Instructions. You may instruct AWS not to use and store Amazon Q Content for service improvement as described in this Section 50.13 by (i) configuring an AI services opt-out policy using AWS Organizations, (ii) if you use Amazon Q in the IDE, by adjusting your settings in the IDE, or (iii) using the opt-out mechanism described in the Amazon Q documentation.

IDE の設定やオプトアウトメカニズムの利用は、 AWS を利用する個人に委ねられるため、 Organizations のオプトアウトポリシーを利用してガバナンスを効かせたいケースもあるのではないでしょうか。

そこで今回は Organizations で用意されている AI サービスのオプトアウトポリシーを利用し、 OU 配下に属する AWS アカウント全体に AI サービスのオプトアウトを適用してみたいと思います。

https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_ai-opt-out.html

AI Service オプトアウトポリシーは SCP と違い、管理アカウントにも適用可能なポリシーである点が特徴的です。

2025-03-03 at 23.39.10-Managing organization policies with AWS Organizations - AWS Organizations.png

引用:Managing organization policies with AWS Organizations - AWS Organizations

やってみる

今回利用する AWS アカウントの OU 設計は以下のとおりです。

Control Tower を有効にした AWS アカウントのため、 Security OU に Audit と Log Archive アカウントが存在し、Workload OU にワークロード用アカウントがいます。

Root OU 直下には管理アカウントのみが存在している状況です。

2024-09-12 at 21.27.52-AWS accounts  AWS Organizations  Global@2x.png

ポリシー管理の委任

現時点では Organizations のポリシー管理は、管理アカウントのみが利用できます。リスクヘッジの観点から、管理アカウント上での操作をなるべく減らしたいため、ポリシー管理を Audit アカウントへ委任します。

https://dev.classmethod.jp/articles/update-aws-organizations-delegated-policies/

適用前の Audit アカウントからみた Organizations のポリシー設定です。権限が付与されていないため、アクセス拒否されていることがわかります。

2024-09-13 at 08.04.16-ポリシー  AWS Organizations  Global@2x.png

それでは設定を適用します。管理アカウントの Organizations コンソールから「設定」、「委任」をクリックします。

2024-09-13 at 07.55.51-設定  AWS Organizations  Global@2x.png

検証のため、次のポリシーを適用します。

{
	"Version": "2012-10-17",
	"Statement": [
		{
			"Sid": "DelegatingNecessaryDescribeListActions",
			"Effect": "Allow",
			"Principal": {
				"AWS": "arn:aws:iam::MemberAccountId:root"
			},
			"Action": [
				"organizations:DescribeOrganization",
				"organizations:DescribeOrganizationalUnit",
				"organizations:DescribeAccount",
				"organizations:ListRoots",
				"organizations:ListOrganizationalUnitsForParent",
				"organizations:ListParents",
				"organizations:ListChildren",
				"organizations:ListAccounts",
				"organizations:ListAccountsForParent",
				"organizations:ListTagsForResource"
			],
			"Resource": "*"
		},
		{
			"Sid": "DelegatingNecessaryDescribeListActionsForSpecificPolicyType",
			"Effect": "Allow",
			"Principal": {
				"AWS": "arn:aws:iam::MemberAccountId:root"
			},
			"Action": [
				"organizations:DescribePolicy",
				"organizations:DescribeEffectivePolicy",
				"organizations:ListPolicies",
				"organizations:ListPoliciesForTarget",
				"organizations:ListTargetsForPolicy"
			],
			"Resource": "*"
		},
		{
			"Sid": "DelegatingAllPolicies",
			"Effect": "Allow",
			"Principal": {
				"AWS": "arn:aws:iam::MemberAccountId:root"
			},
			"Action": [
				"organizations:CreatePolicy",
				"organizations:UpdatePolicy",
				"organizations:DeletePolicy",
				"organizations:AttachPolicy",
				"organizations:DetachPolicy",
				"organizations:EnablePolicyType",
				"organizations:DisablePolicyType"
			],
			"Resource": "*"
		}
	]
}

もっと明確に絞りたい場合は、以下のブログを参考に Condition 句や Resource 句を設定すると良いかと思います。

https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_delegate_examples.html

https://dev.classmethod.jp/articles/aws-organizations-delegated-policy-manage/

委任ポリシーを適用すると、委任されたアカウント(今回だと Audit)の Organizations コンソールからポリシーやアカウント一覧が閲覧できるようになります。

2024-09-13 at 08.18.54-ポリシー  AWS Organizations  Global@2x.png

AI サービスのオプトアウトポリシーの適用

今回は Workload OU に対して、AI サービスのオプトアウトポリシーを適用してみたいと思います。「例 1: 組織内のすべてのアカウントで、すべての AI サービスをオプトアウトする」を参考にポリシーを適用します。

{
	"services": {
		"@@operators_allowed_for_child_policies": ["@@none"],
		"default": {
			"@@operators_allowed_for_child_policies": ["@@none"],
			"opt_out_policy": {
				"@@operators_allowed_for_child_policies": ["@@none"],
				"@@assign": "optOut"
			}
		}
	}
}

https://docs.aws.amazon.com/ja_jp/organizations/latest/userguide/orgs_manage_policies_ai-opt-out_syntax.html

@@ のような見慣れない文字列がありますね。ドキュメントによると次の意味があるようです。

  • services 直下の "@@operators_allowed_for_child_policies@@none にしていると、
    • 子アカウントまたは子 OU に対して、個別サービス用に新しいセクション(オプトイン/アウト)の追加を禁止する
  • default 直下の "@@operators_allowed_for_child_policies@@none にしていると、
    • (今後追加があった場合の)新しいセクションを追加を禁止する
      • 現在は opt_out_policy セクションのみ使えるが、今後何かのセクションが増えた時の備えに有効
  • opt_out_policy 直下の "@@operators_allowed_for_child_policies@@none にしていると、
    • 子アカウントまたは子 OU に対して、 @@assignキーの値(オプトイン/アウト)の変更を禁止する

ポリシーを作成をクリックします。

2024-09-13 at 09.59.00-AI サービスのオプトアウトポリシー  AWS Organizations  Global@2x.png

OptOutFromAllAIServicesForWorkloadOU という名前でポリシーを作成します。ポリシーのサイズが 2,500 文字以内のため、カウント機能がついているの良いですね。

2024-09-13 at 10.35.49-新しい AI サービスのオプトアウトポリシーを作成  AWS Organizations  Global.png

先ほどのポリシーを入力すると、 221 文字でした。

2024-09-13 at 10.38.00-新しい AI サービスのオプトアウトポリシーを作成  AWS Organizations  Global.png

ポリシーが作成されたので、アタッチします。

2024-09-13 at 10.39.05-AI サービスのオプトアウトポリシー  AWS Organizations  Global.png

ポリシーを適用したい OU を選択し「ポリシーのアタッチ」をクリックします。

2024-09-13 at 10.39.44-ポリシーをアタッチ  AWS Organizations  Global.png

ポリシーを確認すると、ターゲット欄に対象の OU が追加されていますね。

2024-09-13 at 10.41.42-OptOutFromAllAIServicesForWorkloadOU  AWS Organizations  Global.png

ちなみにですが、 Organizations の AWS アカウント管理側でも、どの OU や AWS アカウントにポリシーがアタッチされているか確認できます。

2024-09-13 at 10.45.20-Workload  AWS Organizations  Global.png

AI サービスをオプトインしてみる

現在、 Workload OU にて「すべての AI サービスをオプトアウトする」を適用しています。念の為、 Workload OU 内に属する AWS アカウント(Workload01)が AI サービスをオプトインできないか確認してみます。

ポリシー管理画面から再度「ポリシーを作成」をクリックします。

2024-09-13 at 10.49.01-AI サービスのオプトアウトポリシー  AWS Organizations  Global.png

OptInFromAmazonQDeveloperForWorkload01 と言う名前と、以下の内容でポリシーを作成します。

{
	"services": {
		"codewhisperer": {
			"opt_out_policy": {
				"@@assign": "optIn"
			}
		}
	}
}

同じ要領で「ポリシーのアタッチ」を選択します。

2024-09-13 at 10.52.37-AI サービスのオプトアウトポリシー  AWS Organizations  Global.png

AWS アカウント(Workload01)に適用してみます。

2024-09-13 at 10.53.14-ポリシーをアタッチ  AWS Organizations  Global.png

ポリシーは適用できましたが、「この AWS アカウントの有効な AI ポリシーを表示する」という項目がありますね。クリックしてみましょう。

2024-09-13 at 11.24.09-Workload01  AWS Organizations  Global.png

中身を確認すると、 AWS アカウントに直接適用した OptInFromAmazonQDeveloperForWorkload01 は無効化され、 OU から継承した OptOutFromAllAIServicesForWorkloadOU の内容が適用されています。

2024-09-13 at 11.25.16-有効なポリシー  AWS Organizations  Global.png

まとめ

以上、「AI サービスのオプトアウトポリシーを OU に適用してみる」でした。

AWS の AI サービスを積極的に利用したいが、ガバナンスも気になる方には必須の機能ですね。

このブログがどなたかの参考になれば幸いです。

クラウド事業本部コンサルティング部のたかくに(@takakuni_)でした!

脚注
  1. Amazon Q Business または Amazon Q Developer Pro は対象外です。 ↩︎

Share this article

facebook logohatena logotwitter logo

© Classmethod, Inc. All rights reserved.