Bind Bedrock Batch Output to an Approved KMS Key
Amazon Bedrock batch inference can write output with a customer managed KMS key selected through s3EncryptionKeyId. A safe design binds the submitted key ARN to the output bucket and prefix, grants the batch service role only the required cryptographic actions, and restricts key use through Amazon S3. DeepInspect can inspect the submission while AWS KMS, IAM, and S3 enforce encryption after submission.

Amazon Bedrock batch inference accepts an optional s3EncryptionKeyId inside the output S3 configuration. That field chooses the KMS resource used when Bedrock writes model responses to S3. The submitted identifier is only the first gate. The batch service role needs permission to generate encryption material, the KMS policy must recognize that role, and S3 must accept the encrypted write. I would treat those four controls as one release artifact.
TL;DR
- Pin
s3EncryptionKeyIdto a reviewed customer managed KMS ARN for each approved output location. - Grant the Bedrock batch service role
kms:GenerateDataKeyfor output andkms:Decryptonly when encrypted input requires it. - Restrict KMS use through
s3.REGION.amazonaws.com, because S3 makes the KMS request on behalf of the role. - Keep the KMS policy, IAM policy, S3 bucket policy, and HTTP submission rule aligned and test the completed object metadata.
The API field selects output encryption
The Amazon Bedrock S3 output configuration reference defines three fields: required s3Uri, optional s3BucketOwner, and optional s3EncryptionKeyId. AWS accepts a KMS ARN, alias ARN, identifier, or alias name under the current pattern. The field can be between 1 and 2,048 characters.
AWS's batch job creation guide says output uses an AWS managed KMS resource by default. The console exposes a custom encryption choice under advanced encryption settings, while the API carries that choice in s3EncryptionKeyId.
A production route should convert that broad provider surface into one exact decision. Bind the output S3 bucket and prefix to a fully qualified customer managed KMS ARN. Also bind the expected bucket owner, job Region, model, and service-role ARN. Reject aliases and bare UUIDs at the submission boundary when resource identity must remain stable across releases.
The parameter allowlisting guide gives the general pattern: provider acceptance defines valid syntax, while route policy defines the identifiers this workload may select.
Four policies participate in one encrypted write
The first policy sits on the authenticated caller that can submit CreateModelInvocationJob. That IAM identity needs the Bedrock job action and permission to pass the approved service role under the deployment's IAM design.
The second policy belongs to the service role Bedrock assumes for the job. AWS's custom batch service-role guide requires kms:GenerateDataKey when a customer managed KMS resource protects output. The same guide assigns kms:Decrypt when customer-managed encryption protects input files. Keep those actions in separate statements when input and output use different KMS resources.
The third control is the KMS policy. AWS describes this policy as the primary access mechanism for a KMS resource. IAM allows become effective only when the KMS policy enables that path or grants the principal directly. A role policy containing kms:GenerateDataKey therefore supplies only one side of authorization.
The fourth control is S3. The output bucket policy can deny PutObject requests whose KMS identifier differs from the approved ARN. That deny remains active for direct writes and later job execution.
The ViaService value names S3
AWS's batch role documentation gives a precise condition for customer managed KMS resources: kms:ViaService should equal s3.REGION.amazonaws.com. The page explicitly says to name Amazon S3 rather than Amazon Bedrock because the role's KMS calls occur through S3 while reading input or writing output.
That condition reduces the ways the batch role can use the KMS resource. It should appear in the role's IAM permission and can also appear in the KMS policy when the deployment needs the same restriction there. Use the actual S3 Region in the service name. AWS KMS documents kms:ViaService as a single-valued condition for forward access sessions.
My blunt opinion is that bedrock.REGION.amazonaws.com looks plausible enough to survive a casual review and wrong enough to break the job. Print the resolved ViaService value beside the KMS ARN in the deployment evidence.
Extra encryption-context restrictions require care. Amazon S3 uses the object ARN as its default KMS encryption context without an S3 Bucket Key, and the bucket ARN when an S3 Bucket Key is enabled. A KMS policy that assumes one shape can reject the other. Test the real bucket configuration before requiring kms:EncryptionContext:aws:s3:arn values.
Full KMS ARNs remove account ambiguity
Amazon S3's SSE-KMS guide recommends a fully qualified KMS ARN for cross-account operations. An alias can resolve inside the requester's account, creating the possibility that S3 encrypts with a KMS resource owned by the requester instead of the bucket owner.
Use a KMS ARN in route policy even for same-account jobs. It includes the Region, account, and immutable identifier in one string. Resolve any operator-facing alias during deployment, then store the resulting KMS ARN in the approved manifest. A later alias retarget should trigger a new review rather than silently changing the cryptographic resource behind a stable label.
S3 also requires the KMS resource to live in the same Region as the bucket. Validate that relationship before accepting the job. The KMS policy is Regional too, so copying a policy document to another Region never grants access to the original cryptographic resource.
On the release screen, show the full KMS ARN in monospace text. Put the output bucket and prefix directly below it. A green badge labeled alias/batch-output hides the account and Region that the reviewer needs to see.
S3 policy can require the exact KMS ARN
Amazon S3 documents a bucket-policy pattern that denies s3:PutObject when the request lacks SSE-KMS with the designated KMS resource. Its stronger example compares s3:x-amz-server-side-encryption-aws-kms-key-id with one complete KMS ARN and denies a different value.
Use that resource policy as a backstop for the output prefix. The HTTP submission rule can reject an unapproved s3EncryptionKeyId before Bedrock sees the job, while the S3 deny governs the actual write later. The controls operate at different times and protect different paths.
Preserve evidence from both points. At submission, record the caller, route, s3Uri, bucket owner, KMS ARN, service role, policy version, and returned jobArn. After completion, inspect representative output object metadata and CloudTrail KMS events. AWS's S3 guide identifies GenerateDataKey and Decrypt as cryptographic operations available for CloudTrail review.
The AI audit log schema guide provides a base record for keeping submitted identifiers separate from the storage evidence collected after the job.
Failure testing must include delayed job errors
AWS warns that missing KMS permissions can leave the initial job submission accepted. The job then fails a few minutes later with a message about validating S3 GetObject or PutObject permissions, without naming KMS. Release tests need to cover the asynchronous failure path rather than stopping at the HTTP 200 response and returned jobArn.
Run fixtures that change one element at a time:
- Replace the approved KMS ARN with another KMS resource in the same account
- Supply an alias or bare identifier where policy requires the full ARN
- Use a KMS ARN from another Region
- Keep the KMS resource and change the output bucket or prefix
- Remove
kms:GenerateDataKeyfrom the service-role policy - Remove the service-role grant or IAM-enabling statement from the KMS policy
- Change
kms:ViaServiceto the Bedrock service name - Require an object encryption context while the bucket uses an S3 Bucket Key
- Attempt a direct
PutObjectwith a different KMS resource
The gateway fixtures should fail before AWS credentials are attached. AWS integration fixtures should prove that the KMS policy and bucket policy deny the later operation. A success fixture should wait for job completion and verify the output object's KMS identifier.
The AWS Bedrock audit logs guide explains why provider and application records need explicit correlation when an operator investigates that delayed failure.
DeepInspect
DeepInspect can inspect authenticated user or agent HTTP submissions to CreateModelInvocationJob. It can require the approved full KMS ARN for a named output bucket and prefix, bind that selection to the expected Bedrock service role, reject caller overrides, and record the submission decision with the returned job identifier.
AWS KMS, IAM, S3 bucket policy, and the Bedrock service role control the cryptographic operation after submission. DeepInspect cannot edit or enforce those policies, validate the eventual S3 object by itself, or govern a batch job submitted through a direct AWS route that bypasses the proxy. Post-job evidence collection remains an AWS operations responsibility.
Book a technical deep dive at deepinspect.ai.
Frequently asked questions
- Which KMS action does Bedrock batch output need?
AWS specifies
kms:GenerateDataKeyfor the batch service role when output uses a customer managed KMS resource. Encrypted input under a customer managed KMS resource needskms:Decrypt. Multipart behavior and other S3 workflows can add requirements, so test the exact batch path and bucket configuration.- Should the KMS policy principal be Bedrock or the batch role?
The batch service role is the principal using the KMS resource through Amazon S3 for this workflow. Grant the approved role the required action and restrict the request with
kms:ViaServiceset to the regional S3 service name. Keep the Bedrock trust relationship on the role as a separate IAM control.- Can an IAM policy alone grant access to the KMS resource?
AWS KMS requires the KMS policy to enable IAM permissions or grant the principal. An allow on the service role has no effect when the KMS policy supplies no authorization path. Review both policies together.
- Does the submission response prove output encryption worked?
The response proves that Bedrock accepted the job request and returned a
jobArn. AWS documents delayed failures for missing KMS permissions. Completion status, S3 object encryption metadata, and KMS CloudTrail events provide the later evidence.