Skip to content

fix(datazone): add Bedrock KMS authorization for tooling key and provisioning role#47

Open
marcinc wants to merge 2 commits into
aws:mainfrom
marcinc:fix/bedrock-kms-guardrail-access
Open

fix(datazone): add Bedrock KMS authorization for tooling key and provisioning role#47
marcinc wants to merge 2 commits into
aws:mainfrom
marcinc:fix/bedrock-kms-guardrail-access

Conversation

@marcinc

@marcinc marcinc commented May 20, 2026

Copy link
Copy Markdown

Issue #, if available: #46

Addresses three gaps in the KMS authorization chain preventing Bedrock blueprint environments (AmazonBedrockGuardrail, AmazonBedrockKnowledgeBase, etc.) from deploying

Description of changes:

  1. The tooling KMS key policy lacked a bedrock.amazonaws.com principal statement. Bedrock calls kms:GenerateDataKey/kms:Decrypt/kms:DescribeKey as a service principal when creating CMK-encrypted resources; without this grant the CF resource handler fails with AccessDeniedException. Scoped to the domain account via aws:SourceAccount.

  2. The ToolingKmsCreateGrant statement in domainKmsAdminPolicy was incomplete: kms:RetireGrant was missing (so CF cannot retire grants on resource deletion), the condition used StringLike instead of StringEquals for kms:CallerAccount (semantically imprecise for an exact-match), and kms:GrantIsForAWSResource was absent (allowing arbitrary non-service grants on the tooling key).

  3. The default blueprint provisioning role (domainDefaultBlueprintProvisioningRole) was not attached to the kms-admin managed policy, so kms:CreateGrant was denied at IAM evaluation before the key policy was consulted. The cross-account provisioning role already had this attachment; the primary account path did not.

Tests:

  • datazone-l3-construct.test.ts: assert BedrockEncryption statement on tooling key and kms-admin policy attachment on the default provisioning role
  • app.test.ts and sm-studio-domain.test.ts: Lambda/Docker mocks to prevent test failures in environments without a Docker daemon

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

marcinc added 2 commits May 22, 2026 16:29
…isioning role

Three gaps in the KMS authorization chain prevented Bedrock blueprint environments
(AmazonBedrockGuardrail, AmazonBedrockKnowledgeBase, etc.) from deploying:

1. The tooling KMS key policy lacked a bedrock.amazonaws.com principal statement.
   Bedrock calls kms:GenerateDataKey/kms:Decrypt/kms:DescribeKey as a service
   principal when creating CMK-encrypted resources; without this grant the CF
   resource handler fails with AccessDeniedException. Scoped to the domain account
   via aws:SourceAccount.

2. The ToolingKmsCreateGrant statement in domainKmsAdminPolicy was incomplete:
   kms:RetireGrant was missing (so CF cannot retire grants on resource deletion),
   the condition used StringLike instead of StringEquals for kms:CallerAccount
   (semantically imprecise for an exact-match), and kms:GrantIsForAWSResource was
   absent (allowing arbitrary non-service grants on the tooling key).

3. The default blueprint provisioning role (domainDefaultBlueprintProvisioningRole)
   was not attached to the kms-admin managed policy, so kms:CreateGrant was denied
   at IAM evaluation before the key policy was consulted. The cross-account
   provisioning role already had this attachment; the primary account path did not.

Tests:
- datazone-l3-construct.test.ts: assert BedrockEncryption statement on tooling key
  and kms-admin policy attachment on the default provisioning role
- app.test.ts and sm-studio-domain.test.ts: Lambda/Docker mocks to prevent test
  failures in environments without a Docker daemon
…changes

Regenerated sagemaker app diff baselines to include the KMS policy
changes from the datazone L3 construct fix: StringLike→StringEquals for
kms:CallerAccount, added kms:RetireGrant and GrantIsForAWSResource
condition to ToolingKmsCreateGrant, added kms-admin policy on the default
blueprint provisioning role, and added BedrockEncryption KMS statement
for bedrock.amazonaws.com.
@marcinc marcinc force-pushed the fix/bedrock-kms-guardrail-access branch 2 times, most recently from 9218d9b to 8f01e66 Compare May 22, 2026 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant