Skip to content
v2.277.0

Experimental

@aws-cdk/aws-bedrock-agentcore-alpha is an experimental (alpha) package: its API may change in any release, without a major version bump.

GatewayProps Struct ​

Properties for defining a Gateway.

Example ​

ts

// Create a Policy engine
const policyEngine = new agentcore.PolicyEngine(this, "MyPolicyEngine", {
  policyEngineName: "my_policy_engine",
  description: "Policy engine for access control",
});

const gateway = new agentcore.Gateway(this, "MyGateway", {
  gatewayName: "my-gateway",
  policyEngineConfiguration: {
    policyEngine: policyEngine,
    mode: agentcore.PolicyEngineMode.ENFORCE, // Default is LOG_ONLY
  },
});

// Add policy to policy engine
policyEngine.addPolicy("AllowAllActions", {
  definition: `
    permit(
      principal,
      action,
      resource == AgentCore::Gateway::"${gateway.gatewayArn}"
    );
  `,
  description: "Allow all actions on specific gateway (development)",
  validationMode: agentcore.PolicyValidationMode.IGNORE_ALL_FINDINGS, // This will ignore all cedar warnings
});

// you can add multiple policies to the policy engine
policyEngine.addPolicy("SpecificToolPolicy", {
  definition: `
    permit(
      principal is AgentCore::OAuthUser,
      action == AgentCore::Action::"WeatherTool__get_forecast",
      resource == AgentCore::Gateway::"${gateway.gatewayArn}"
    );
  `,
  description: "Allow specific weather tool access",
  validationMode: agentcore.PolicyValidationMode.FAIL_ON_ANY_FINDINGS, // This will fail policy creation for any cedar warning
});
python
# Create a Policy engine
policy_engine = agentcore.PolicyEngine(self, "MyPolicyEngine",
    policy_engine_name="my_policy_engine",
    description="Policy engine for access control"
)

gateway = agentcore.Gateway(self, "MyGateway",
    gateway_name="my-gateway",
    policy_engine_configuration=agentcore.GatewayPolicyEngineConfig(
        policy_engine=policy_engine,
        mode=agentcore.PolicyEngineMode.ENFORCE
    )
)

# Add policy to policy engine
policy_engine.add_policy("AllowAllActions",
    definition=f"""
        permit(
          principal,
          action,
          resource == AgentCore::Gateway::\"{gateway.gatewayArn}\"
        );
      """,
    description="Allow all actions on specific gateway (development)",
    validation_mode=agentcore.PolicyValidationMode.IGNORE_ALL_FINDINGS
)

# you can add multiple policies to the policy engine
policy_engine.add_policy("SpecificToolPolicy",
    definition=f"""
        permit(
          principal is AgentCore::OAuthUser,
          action == AgentCore::Action::\"WeatherTool__get_forecast\",
          resource == AgentCore::Gateway::\"{gateway.gatewayArn}\"
        );
      """,
    description="Allow specific weather tool access",
    validation_mode=agentcore.PolicyValidationMode.FAIL_ON_ANY_FINDINGS
)
java
// Create a Policy engine
PolicyEngine policyEngine = PolicyEngine.Builder.create(this, "MyPolicyEngine")
        .policyEngineName("my_policy_engine")
        .description("Policy engine for access control")
        .build();

Gateway gateway = Gateway.Builder.create(this, "MyGateway")
        .gatewayName("my-gateway")
        .policyEngineConfiguration(GatewayPolicyEngineConfig.builder()
                .policyEngine(policyEngine)
                .mode(PolicyEngineMode.ENFORCE)
                .build())
        .build();

// Add policy to policy engine
policyEngine.addPolicy("AllowAllActions", AddPolicyOptions.builder()
        .definition(String.format("%n    permit(%n      principal,%n      action,%n      resource == AgentCore::Gateway::\"%s\"%n    );%n  ", gateway.getGatewayArn()))
        .description("Allow all actions on specific gateway (development)")
        .validationMode(PolicyValidationMode.IGNORE_ALL_FINDINGS)
        .build());

// you can add multiple policies to the policy engine
policyEngine.addPolicy("SpecificToolPolicy", AddPolicyOptions.builder()
        .definition(String.format("%n    permit(%n      principal is AgentCore::OAuthUser,%n      action == AgentCore::Action::\"WeatherTool__get_forecast\",%n      resource == AgentCore::Gateway::\"%s\"%n    );%n  ", gateway.getGatewayArn()))
        .description("Allow specific weather tool access")
        .validationMode(PolicyValidationMode.FAIL_ON_ANY_FINDINGS)
        .build());
csharp
// Install: dotnet add package Amazon.CDK.AWS.Bedrock.Agentcore.Alpha
// Create a Policy engine
var policyEngine = new PolicyEngine(this, "MyPolicyEngine", new PolicyEngineProps {
    PolicyEngineName = "my_policy_engine",
    Description = "Policy engine for access control"
});

var gateway = new Gateway(this, "MyGateway", new GatewayProps {
    GatewayName = "my-gateway",
    PolicyEngineConfiguration = new GatewayPolicyEngineConfig {
        PolicyEngine = policyEngine,
        Mode = PolicyEngineMode.ENFORCE
    }
});

// Add policy to policy engine
policyEngine.AddPolicy("AllowAllActions", new AddPolicyOptions {
    Definition = $@"
        permit(
          principal,
          action,
          resource == AgentCore::Gateway::""{gateway.gatewayArn}""
        );
      ",
    Description = "Allow all actions on specific gateway (development)",
    ValidationMode = PolicyValidationMode.IGNORE_ALL_FINDINGS
});

// you can add multiple policies to the policy engine
policyEngine.AddPolicy("SpecificToolPolicy", new AddPolicyOptions {
    Definition = $@"
        permit(
          principal is AgentCore::OAuthUser,
          action == AgentCore::Action::""WeatherTool__get_forecast"",
          resource == AgentCore::Gateway::""{gateway.gatewayArn}""
        );
      ",
    Description = "Allow specific weather tool access",
    ValidationMode = PolicyValidationMode.FAIL_ON_ANY_FINDINGS
});
go
// Install: go get github.com/aws/aws-cdk-go/awsbedrockagentcorealpha/v2
// Create a Policy engine
policyEngine := agentcore.NewPolicyEngine(this, jsii.String("MyPolicyEngine"), &PolicyEngineProps{
	PolicyEngineName: jsii.String("my_policy_engine"),
	Description: jsii.String("Policy engine for access control"),
})

gateway := agentcore.NewGateway(this, jsii.String("MyGateway"), &GatewayProps{
	GatewayName: jsii.String("my-gateway"),
	PolicyEngineConfiguration: &GatewayPolicyEngineConfig{
		PolicyEngine: policyEngine,
		Mode: agentcore.PolicyEngineMode_ENFORCE(),
	},
})

// Add policy to policy engine
policyEngine.AddPolicy(jsii.String("AllowAllActions"), &AddPolicyOptions{
	Definition: fmt.Sprintf("\n    permit(\n      principal,\n      action,\n      resource == AgentCore::Gateway::\"%v\"\n    );\n  ", gateway.GatewayArn),
	Description: jsii.String("Allow all actions on specific gateway (development)"),
	ValidationMode: agentcore.PolicyValidationMode_IGNORE_ALL_FINDINGS(),
})

// you can add multiple policies to the policy engine
policyEngine.AddPolicy(jsii.String("SpecificToolPolicy"), &AddPolicyOptions{
	Definition: fmt.Sprintf("\n    permit(\n      principal is AgentCore::OAuthUser,\n      action == AgentCore::Action::\"WeatherTool__get_forecast\",\n      resource == AgentCore::Gateway::\"%v\"\n    );\n  ", gateway.*GatewayArn),
	Description: jsii.String("Allow specific weather tool access"),
	ValidationMode: agentcore.PolicyValidationMode_FAIL_ON_ANY_FINDINGS(),
})

Properties ​

authorizerConfigurationoptionalIGatewayAuthorizerConfigauthorizer_configurationoptionalIGatewayAuthorizerConfigauthorizerConfigurationoptionalIGatewayAuthorizerConfigAuthorizerConfigurationoptionalIGatewayAuthorizerConfigAuthorizerConfigurationoptionalIGatewayAuthorizerConfig#
The authorizer configuration for the gateway.

Default: A default authorizer will be created using Cognito

descriptionoptionalstringdescriptionoptionalstrdescriptionoptionalStringDescriptionoptionalstringDescriptionoptional*string#
Optional description for the gateway Valid characters are a-z, A-Z, 0-9, _ (underscore), - (hyphen) and spaces The description can have up to 200 characters.

Default: No description

exceptionLeveloptionalGatewayExceptionLevelexception_leveloptionalGatewayExceptionLevelexceptionLeveloptionalGatewayExceptionLevelExceptionLeveloptionalGatewayExceptionLevelExceptionLeveloptionalGatewayExceptionLevel#
The verbosity of exception messages Use DEBUG mode to see granular exception messages from a Gateway.

Default: Exception messages are sanitized for presentation to end users

gatewayNameoptionalstringgateway_nameoptionalstrgatewayNameoptionalStringGatewayNameoptionalstringGatewayNameoptional*string#
The name of the gateway Valid characters are a-z, A-Z, 0-9, _ (underscore) and - (hyphen) The name must be unique within your account.

Default: auto generate

interceptorConfigurationsoptionalIInterceptor[]interceptor_configurationsoptionaltyping.List[IInterceptor]interceptorConfigurationsoptionalList<IInterceptor>InterceptorConfigurationsoptionalIInterceptor[]InterceptorConfigurationsoptional*[]IInterceptor#
Interceptor configurations for the gateway.

Default: No interceptors

notes

Interceptors allow you to run custom code during each gateway invocation:

  • REQUEST interceptors execute before the gateway calls the target
  • RESPONSE interceptors execute after the target responds

A gateway can have at most one REQUEST interceptor and one RESPONSE interceptor.

kmsKeyoptionalIKeykms_keyoptionalIKeykmsKeyoptionalIKeyKmsKeyoptionalIKeyKmsKeyoptionalIKey#
The AWS KMS key used to encrypt data associated with the gateway.

Default: No encryption

policyEngineConfigurationoptionalGatewayPolicyEngineConfigpolicy_engine_configurationoptionalGatewayPolicyEngineConfigpolicyEngineConfigurationoptionalGatewayPolicyEngineConfigPolicyEngineConfigurationoptionalGatewayPolicyEngineConfigPolicyEngineConfigurationoptionalGatewayPolicyEngineConfig#
The policy engine configuration for this gateway.

Default: No policy engine (requests are not subject to Cedar policy authorization)

When provided, the specified policy engine will be associated with this gateway. All agent requests through this gateway will be evaluated against the Cedar policies defined in the policy engine.

protocolConfigurationoptionalIGatewayProtocolConfigprotocol_configurationoptionalIGatewayProtocolConfigprotocolConfigurationoptionalIGatewayProtocolConfigProtocolConfigurationoptionalIGatewayProtocolConfigProtocolConfigurationoptionalIGatewayProtocolConfig#
The protocol configuration for the gateway.

Default: A default protocol configuration will be created using MCP with following params supportedVersions: [MCPProtocolVersion.MCP_2025_03_26], searchType: McpGatewaySearchType.SEMANTIC, instructions: "Default gateway to connect to external MCP tools",

roleoptionalIRoleroleoptionalIRoleroleoptionalIRoleRoleoptionalIRoleRoleoptionalIRole#
The IAM role that provides permissions for the gateway to access AWS services.

Default: A new role will be created

tagsoptional{ [key: string]: string }tagsoptionaltyping.Mapping[str, str]tagsoptionalMap<String, String>TagsoptionalIDictionary<string, string>Tagsoptional*map[string]*string#
Tags for the gateway A list of key:value pairs of tags to apply to this Gateway resource.

Default: No tags