Creates an IAM role assumable via EKS IRSA for workloads to invoke Amazon Bedrock models.
- Trust policy restricted to a specified Kubernetes ServiceAccount via IRSA
- Least-privilege Bedrock invoke actions with optional model and region scoping
- Optional read-only access for model discovery
- Outputs for annotating your Kubernetes ServiceAccount
cluster_oidc_url(string, required): EKS cluster OIDC issuer URL (e.g.,https://oidc.eks.<region>.amazonaws.com/id/<id>)service_account_namespace(string, required): Namespace of the allowed ServiceAccountservice_account_name(string, required): Name of the allowed ServiceAccountallowed_model_ids(list(string), optional): Bedrock foundation model IDs to allow (e.g.,anthropic.claude-3-haiku-20240307)allow_all_models(bool, defaultfalse): Iftrue, allow invoking all models (Resource="*")bedrock_regions(list(string), required): Regions to scope permissionsinclude_read_actions(bool, defaultfalse): IncludeListFoundationModelsandGetFoundationModelrole_name(string, optional): Explicit IAM role name; default name isbedrock-invoke-<namespace>-<name>role_max_session_duration(number, default3600): Max session duration in secondstags(map(string), optional): Resource tagsadditional_policy_statements(list(any), optional): Extra statements merged into the Bedrock policy
Validation enforces that either allow_all_models = true or allowed_model_ids is non-empty.
role_arn: IAM role ARN to use in the ServiceAccount annotationrole_name: IAM role nameservice_account_annotation_key: Alwayseks.amazonaws.com/role-arnservice_account_annotation_value: Same asrole_arnassume_role_policy: Rendered trust policy JSON (for inspection)bedrock_policy: Rendered Bedrock invoke policy JSON (for inspection)
Annotate your ServiceAccount with the role ARN:
metadata:
annotations:
eks.amazonaws.com/role-arn: <output role_arn>- The module derives the OIDC provider ARN from the provided
cluster_oidc_urland the current AWS account. - Bedrock foundation model ARNs are of the form:
arn:<partition>:bedrock:<region>::foundation-model/<model_id>. - Specify one or more regions in
bedrock_regionsto permit invocation.