--- subcategory: "Bedrock AgentCore" layout: "aws" page_title: "AWS: aws_bedrockagentcore_gateway" description: |- Manages an AWS Bedrock AgentCore Gateway. --- # Resource: aws_bedrockagentcore_gateway Manages an AWS Bedrock AgentCore Gateway. With Gateway, developers can convert APIs, Lambda functions, and existing services into Model Context Protocol (MCP)-compatible tools. ## Example Usage ### Gateway with JWT Authorization ```terraform data "aws_iam_policy_document" "assume_role" { statement { effect = "Allow" actions = ["sts:AssumeRole"] principals { type = "Service" identifiers = ["bedrock-agentcore.amazonaws.com"] } } } resource "aws_iam_role" "example" { name = "bedrock-agentcore-gateway-role" assume_role_policy = data.aws_iam_policy_document.assume_role.json } resource "aws_bedrockagentcore_gateway" "example" { name = "example-gateway" role_arn = aws_iam_role.example.arn authorizer_type = "CUSTOM_JWT" authorizer_configuration { custom_jwt_authorizer { discovery_url = "https://accounts.google.com/.well-known/openid-configuration" allowed_audience = ["test1", "test2"] } } protocol_type = "MCP" } ``` ### Gateway with advanced JWT Authorization and MCP Configuration ```terraform resource "aws_bedrockagentcore_gateway" "example" { name = "mcp-gateway" description = "Gateway for MCP communication" role_arn = aws_iam_role.example.arn authorizer_type = "CUSTOM_JWT" authorizer_configuration { custom_jwt_authorizer { discovery_url = "https://auth.example.com/.well-known/openid-configuration" allowed_audience = ["app-client", "web-client"] allowed_clients = ["client-123", "client-456"] allowed_scopes = ["openid", "email"] } } protocol_type = "MCP" protocol_configuration { mcp { instructions = "Gateway for handling MCP requests" search_type = "SEMANTIC" supported_versions = ["2025-03-26", "2025-06-18"] } } } ``` ### Gateway with Interceptor Configuration ```terraform resource "aws_lambda_function" "interceptor" { filename = "interceptor.zip" function_name = "gateway-interceptor" role = aws_iam_role.lambda.arn handler = "index.handler" runtime = "python3.12" } resource "aws_bedrockagentcore_gateway" "example" { name = "gateway-with-interceptor" role_arn = aws_iam_role.example.arn authorizer_type = "AWS_IAM" protocol_type = "MCP" interceptor_configuration { interception_points = ["REQUEST", "RESPONSE"] interceptor { lambda { arn = aws_lambda_function.interceptor.arn } } input_configuration { pass_request_headers = true } } } ``` ## Argument Reference The following arguments are required: * `authorizer_type` - (Required) Type of authorizer to use. Valid values: `CUSTOM_JWT`, `AWS_IAM`, `NONE`, `AUTHENTICATE_ONLY`. When set to `CUSTOM_JWT`, `authorizer_configuration` block is required. * `name` - (Required) Name of the gateway. * `role_arn` - (Required) ARN of the IAM role that the gateway assumes to access AWS services. The following arguments are optional: * `authorizer_configuration` - (Optional) Configuration for request authorization. Required when `authorizer_type` is set to `CUSTOM_JWT`. See [`authorizer_configuration`](#authorizer_configuration-block) below. * `description` - (Optional) Description of the gateway. * `exception_level` - (Optional) Exception level for the gateway. Valid values: `DEBUG`. * `interceptor_configuration` - (Optional) List of interceptor configurations for the gateway. Minimum of 1, maximum of 2. See [`interceptor_configuration`](#interceptor_configuration-block) below. * `kms_key_arn` - (Optional) ARN of the KMS key used to encrypt the gateway data. * `policy_engine_configuration` - (Optional) Configuration for a policy engine associated with the gateway. A policy engine is a collection of policies that evaluates and authorizes agent tool calls. When associated with a gateway, the policy engine intercepts all agent requests and determines whether to allow or deny each action based on the defined policies. See [`policy_engine_configuration`](#policy_engine_configuration-block) below. * `protocol_configuration` - (Optional) Protocol-specific configuration for the gateway. See [`protocol_configuration`](#protocol_configuration-block) below. * `protocol_type` - (Optional) Protocol type for the gateway. Valid values: `MCP`. Omit this argument to create a gateway that routes traffic directly to HTTP targets such as AgentCore Runtime agents (see [`aws_bedrockagentcore_gateway_target`](bedrockagentcore_gateway_target.html.markdown) `target_configuration.http`). * `region` - (Optional) Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the [provider configuration](https://registry.terraform.io/providers/hashicorp/aws/latest/docs#aws-configuration-reference). * `tags` - (Optional) Key-value map of resource tags. If configured with a provider [`default_tags` configuration block](https://registry.terraform.io/providers/hashicorp/aws/latest/docs#default_tags-configuration-block) present, tags with matching keys will overwrite those defined at the provider-level. ### `authorizer_configuration` Block The `authorizer_configuration` block supports the following: * `custom_jwt_authorizer` - (Required) JWT-based authorization configuration block. See [`custom_jwt_authorizer`](#custom_jwt_authorizer-block) below. ### `custom_jwt_authorizer` Block The `custom_jwt_authorizer` block supports the following: * `allowed_audience` - (Optional) Set of allowed audience values for JWT token validation. * `allowed_clients` - (Optional) Set of allowed client IDs for JWT token validation. * `allowed_scopes` - (Optional) Set of scopes that are allowed to access the token. * `allowed_workload_configuration` - (Optional) Configuration restricting which workloads may use this authorizer. See [`allowed_workload_configuration`](#allowed_workload_configuration-block) below. * `custom_claim` - (Optional) Repeatable block to define a custom claim validation name, value, and operation. See [`custom_claim`](#custom_claim-block) below. * `discovery_url` - (Required) URL used to fetch OpenID Connect configuration or authorization server metadata. Must end with `.well-known/openid-configuration`. * `private_endpoint` - (Optional) Private endpoint used to reach the authorization server. See [`private_endpoint`](#private_endpoint-block) below. * `private_endpoint_overrides` - (Optional) Overrides for the private endpoints used to reach the authorization server. See [`private_endpoint_overrides`](#private_endpoint_overrides-block) below. ### `allowed_workload_configuration` Block * `hosting_environment` - (Optional) Hosting environments allowed to use the authorizer. Between 1 and 10 entries. See [`hosting_environment`](#hosting_environment-block) below. * `workload_identities` - (Optional) List of workload identity names allowed to use the authorizer. Between 1 and 10 entries. ### `hosting_environment` Block * `arn` - (Required) ARN of the hosting environment. ### `private_endpoint_overrides` Block * `domain` - (Required) Domain the override applies to. * `private_endpoint` - (Required) Private endpoint configuration. See [`private_endpoint`](#private_endpoint-block) below. ### `private_endpoint` Block Exactly one of the following must be specified: * `managed_vpc_resource` - (Optional) Managed VPC resource configuration. See [`managed_vpc_resource`](#managed_vpc_resource-block) below. * `self_managed_lattice_resource` - (Optional) Self-managed VPC Lattice resource configuration. See [`self_managed_lattice_resource`](#self_managed_lattice_resource-block) below. ### `managed_vpc_resource` Block * `endpoint_ip_address_type` - (Required) IP address type for the endpoint. Valid values are `IPV4` and `IPV6`. * `routing_domain` - (Optional) Routing domain for the endpoint. * `security_group_ids` - (Optional) IDs of the security groups for the endpoint. * `subnet_ids` - (Required) IDs of the subnets for the endpoint. * `tags` - (Optional) Tags to assign to the managed VPC resource. * `vpc_identifier` - (Required) Identifier of the VPC for the endpoint. ### `self_managed_lattice_resource` Block * `resource_configuration_identifier` - (Optional) Identifier of the VPC Lattice resource configuration. ### `custom_claim` Block The `custom_claim` block supports the following: * `authorizing_claim_match_value` - (Required) Configuration block to define the value or values to match for and the relationship of the match. See [`authorizing_claim_match_value`](#authorizing_claim_match_value-block) below. * `inbound_token_claim_name` - (Required) Name of the custom claim field to check. * `inbound_token_claim_value_type` - (Required) Data type of the claim value to check for. Valid values are `STRING` and `STRING_ARRAY`. ### `authorizing_claim_match_value` Block The `authorizing_claim_match_value` block supports the following: * `claim_match_operator` - (Required) Relationship between the claim field value and the value or values to match for. Valid values are `EQUALS`, `CONTAINS`, and `CONTAINS_ANY`. `EQUALS` can be used only when `inbound_token_claim_value_type` is `STRING`. `CONTAINS` or `CONTAINS_ANY` can be used only when `inbound_token_claim_value_type` is `STRING_ARRAY`. * `claim_match_value` - (Required) Value or values to match for. See [`claim_match_value`](#claim_match_value-block) below. ### `claim_match_value` Block The `claim_match_value` block supports the following: * `match_value_string` - (Optional) String value to match for. Must be specified when `claim_match_operator` is `EQUALS` or `CONTAINS`. Exactly one of `match_value_string` or `match_value_string_list` must be specified. * `match_value_string_list` - (Optional) List of strings to check for a match. Must be specified when `claim_match_operator` is `CONTAINS_ANY`. Exactly one of `match_value_string` or `match_value_string_list` must be specified. ### `interceptor_configuration` Block The `interceptor_configuration` block supports the following: * `input_configuration` - (Optional) Input configuration for the interceptor. See [`input_configuration`](#input_configuration-block) below. * `interception_points` - (Required) Set of interception points. Valid values: `REQUEST`, `RESPONSE`. * `interceptor` - (Required) Interceptor infrastructure configuration. See [`interceptor`](#interceptor-block) below. ### `interceptor` Block The `interceptor` block supports the following: * `lambda` - (Required) Lambda function configuration for the interceptor. See [`lambda`](#lambda-block) below. ### `lambda` Block The `lambda` block supports the following: * `arn` - (Required) ARN of the Lambda function to invoke for the interceptor. ### `input_configuration` Block The `input_configuration` block supports the following: * `pass_request_headers` - (Required) Whether to pass request headers to the interceptor. ### `policy_engine_configuration` Block The `policy_engine_configuration` block supports the following: * `arn` - (Required) ARN of the policy engine. The policy engine contains Cedar policies that define fine-grained authorization rules specifying who can perform what actions on which resources as agents interact through the gateway. * `mode` - (Required) Enforcement mode for the policy engine. Valid values: `LOG_ONLY`, `ENFORCE`. In `LOG_ONLY` mode, the policy engine evaluates actions and records traces but does not enforce decisions. In `ENFORCE` mode, the policy engine evaluates actions and enforces allow/deny decisions. ### `protocol_configuration` Block The `protocol_configuration` block supports the following: * `mcp` - (Optional) Model Context Protocol (MCP) configuration block. See [`mcp`](#mcp-block) below. ### `mcp` Block The `mcp` block supports the following: * `instructions` - (Optional) Instructions for the MCP protocol configuration. * `search_type` - (Optional) Search type for MCP. Valid values: `SEMANTIC`. * `session_configuration` - (Optional) Configuration block for session settings of the MCP gateway. See [`session_configuration`](#session_configuration-block) below. * `streaming_configuration` - (Optional) Configuration block for streaming settings of the MCP gateway. See [`streaming_configuration`](#streaming_configuration-block) below. * `supported_versions` - (Optional) Set of supported MCP protocol versions. ### `session_configuration` Block The `session_configuration` block supports the following: * `session_timeout_in_seconds` - (Optional) Integer value for session timeout in seconds. Must be between 900 and 28800. ### `streaming_configuration` Block The `streaming_configuration` block supports the following: * `enable_response_streaming` - (Optional) Whether to enable response streaming for the gateway. ## Attribute Reference This resource exports the following attributes in addition to the arguments above: * `gateway_arn` - ARN of the Gateway. * `gateway_id` - Unique identifier of the Gateway. * `gateway_url` - URL endpoint for the gateway. * `tags_all` - Map of tags assigned to the resource, including those inherited from the provider [`default_tags` configuration block](https://registry.terraform.io/providers/hashicorp/aws/latest/docs#default_tags-configuration-block). * `workload_identity_details` - Workload identity details for the gateway. See [`workload_identity_details`](#workload_identity_details-block) below. ### `workload_identity_details` Block The `workload_identity_details` block contains the following: * `workload_identity_arn` - ARN of the workload identity. ## Timeouts [Configuration options](https://developer.hashicorp.com/terraform/language/resources/syntax#operation-timeouts): * `create` - (Default `30m`) * `update` - (Default `30m`) * `delete` - (Default `30m`) ## Import In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import Bedrock AgentCore Gateway using the gateway ID. For example: ```terraform import { to = aws_bedrockagentcore_gateway.example id = "GATEWAY1234567890" } ``` Using `terraform import`, import Bedrock AgentCore Gateway using the gateway ID. For example: ```console % terraform import aws_bedrockagentcore_gateway.example GATEWAY1234567890 ```