Skip to content
v2.278.0

GatewayCredentialProvider Class ​

Factory class for creating different Gateway Credential Providers.

Example ​

ts

const gateway = new agentcore.Gateway(this, "MyGateway", {
  gatewayName: "my-gateway",
});

// Outbound auth: ApiKeyCredentialProvider + bindForGatewayApiKeyTarget, or ARNs from console/API
const apiKeyIdentityArn = "arn:aws:bedrock-agentcore:us-east-1:123456789012:token-vault/abc123/apikeycredentialprovider/my-apikey"
const apiKeySecretArn = "arn:aws:secretsmanager:us-east-1:123456789012:secret:my-apikey-secret-abc123"

const opneapiSchema = agentcore.ApiSchema.fromLocalAsset(path.join(__dirname, "mySchema.yml"));
opneapiSchema.bind(this);

// Create a gateway target with OpenAPI Schema
const target = agentcore.GatewayTarget.forOpenApi(this, "MyTarget", {
  gatewayTargetName: "my-api-target",
  description: "Target for external API integration",
  gateway: gateway,  // Note: you need to pass the gateway reference
  apiSchema: opneapiSchema,
  credentialProviderConfigurations: [
    agentcore.GatewayCredentialProvider.fromApiKeyIdentityArn({
     providerArn: apiKeyIdentityArn,
     secretArn: apiKeySecretArn
    }),
  ],
});
python
gateway = agentcore.Gateway(self, "MyGateway",
    gateway_name="my-gateway"
)

# Outbound auth: ApiKeyCredentialProvider + bindForGatewayApiKeyTarget, or ARNs from console/API
api_key_identity_arn = "arn:aws:bedrock-agentcore:us-east-1:123456789012:token-vault/abc123/apikeycredentialprovider/my-apikey"
api_key_secret_arn = "arn:aws:secretsmanager:us-east-1:123456789012:secret:my-apikey-secret-abc123"

opneapi_schema = agentcore.ApiSchema.from_local_asset(path.join(__dirname, "mySchema.yml"))
opneapi_schema.bind(self)

# Create a gateway target with OpenAPI Schema
target = agentcore.GatewayTarget.for_open_api(self, "MyTarget",
    gateway_target_name="my-api-target",
    description="Target for external API integration",
    gateway=gateway,  # Note: you need to pass the gateway reference
    api_schema=opneapi_schema,
    credential_provider_configurations=[
        agentcore.GatewayCredentialProvider.from_api_key_identity_arn(
            provider_arn=api_key_identity_arn,
            secret_arn=api_key_secret_arn
        )
    ]
)
java
Gateway gateway = Gateway.Builder.create(this, "MyGateway")
        .gatewayName("my-gateway")
        .build();

// Outbound auth: ApiKeyCredentialProvider + bindForGatewayApiKeyTarget, or ARNs from console/API
String apiKeyIdentityArn = "arn:aws:bedrock-agentcore:us-east-1:123456789012:token-vault/abc123/apikeycredentialprovider/my-apikey";
String apiKeySecretArn = "arn:aws:secretsmanager:us-east-1:123456789012:secret:my-apikey-secret-abc123";

AssetApiSchema opneapiSchema = ApiSchema.fromLocalAsset(path.join(__dirname, "mySchema.yml"));
opneapiSchema.bind(this);

// Create a gateway target with OpenAPI Schema
GatewayTarget target = GatewayTarget.forOpenApi(this, "MyTarget", GatewayTargetOpenApiProps.builder()
        .gatewayTargetName("my-api-target")
        .description("Target for external API integration")
        .gateway(gateway) // Note: you need to pass the gateway reference
        .apiSchema(opneapiSchema)
        .credentialProviderConfigurations(List.of(GatewayCredentialProvider.fromApiKeyIdentityArn(ApiKeyCredentialProviderOptions.builder()
                .providerArn(apiKeyIdentityArn)
                .secretArn(apiKeySecretArn)
                .build())))
        .build());
csharp
// Install: dotnet add package Amazon.CDK.Lib
var gateway = new Gateway(this, "MyGateway", new GatewayProps {
    GatewayName = "my-gateway"
});

// Outbound auth: ApiKeyCredentialProvider + bindForGatewayApiKeyTarget, or ARNs from console/API
var apiKeyIdentityArn = "arn:aws:bedrock-agentcore:us-east-1:123456789012:token-vault/abc123/apikeycredentialprovider/my-apikey";
var apiKeySecretArn = "arn:aws:secretsmanager:us-east-1:123456789012:secret:my-apikey-secret-abc123";

var opneapiSchema = ApiSchema.FromLocalAsset(path.Join(__dirname, "mySchema.yml"));
opneapiSchema.Bind(this);

// Create a gateway target with OpenAPI Schema
var target = GatewayTarget.ForOpenApi(this, "MyTarget", new GatewayTargetOpenApiProps {
    GatewayTargetName = "my-api-target",
    Description = "Target for external API integration",
    Gateway = gateway,  // Note: you need to pass the gateway reference
    ApiSchema = opneapiSchema,
    CredentialProviderConfigurations = new [] { GatewayCredentialProvider.FromApiKeyIdentityArn(new ApiKeyCredentialProviderOptions {
        ProviderArn = apiKeyIdentityArn,
        SecretArn = apiKeySecretArn
    }) }
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
gateway := agentcore.NewGateway(this, jsii.String("MyGateway"), &GatewayProps{
	GatewayName: jsii.String("my-gateway"),
})

// Outbound auth: ApiKeyCredentialProvider + bindForGatewayApiKeyTarget, or ARNs from console/API
apiKeyIdentityArn := "arn:aws:bedrock-agentcore:us-east-1:123456789012:token-vault/abc123/apikeycredentialprovider/my-apikey"
apiKeySecretArn := "arn:aws:secretsmanager:us-east-1:123456789012:secret:my-apikey-secret-abc123"

opneapiSchema := agentcore.ApiSchema_FromLocalAsset(path.join(__dirname, jsii.String("mySchema.yml")))
opneapiSchema.Bind(this)

// Create a gateway target with OpenAPI Schema
target := agentcore.GatewayTarget_ForOpenApi(this, jsii.String("MyTarget"), &GatewayTargetOpenApiProps{
	GatewayTargetName: jsii.String("my-api-target"),
	Description: jsii.String("Target for external API integration"),
	Gateway: gateway,
	 // Note: you need to pass the gateway reference
	ApiSchema: opneapiSchema,
	CredentialProviderConfigurations: []ICredentialProviderConfig{
		agentcore.GatewayCredentialProvider_FromApiKeyIdentityArn(&ApiKeyCredentialProviderOptions{
			ProviderArn: apiKeyIdentityArn,
			SecretArn: apiKeySecretArn,
		}),
	},
})

Initializer ​

ts
new GatewayCredentialProvider()
python
GatewayCredentialProvider()
java
new GatewayCredentialProvider()
csharp
new GatewayCredentialProvider()
go
NewGatewayCredentialProvider()

Methods ​

fromApiKeyIdentity(provider: IApiKeyCredentialProvider, options?: FromApiKeyIdentityOptions): ICredentialProviderConfig@staticmethod def from_api_key_identity(provider: IApiKeyCredentialProvider, options: typing.Optional[FromApiKeyIdentityOptions] = None) -> ICredentialProviderConfigpublic static ICredentialProviderConfig fromApiKeyIdentity(IApiKeyCredentialProvider provider, FromApiKeyIdentityOptions options)public static ICredentialProviderConfig FromApiKeyIdentity(IApiKeyCredentialProvider provider, FromApiKeyIdentityOptions? options = null)func FromApiKeyIdentity(Provider IApiKeyCredentialProvider, Options FromApiKeyIdentityOptions) ICredentialProviderConfig static #
Create an API key outbound auth configuration from a Token Vault {@link IApiKeyCredentialProvider} construct.

Prefer this over {@link GatewayCredentialProvider.fromApiKeyIdentityArn} when the provider is defined in CDK.

fromApiKeyIdentityArn(props: ApiKeyCredentialProviderOptions): ICredentialProviderConfig@staticmethod def from_api_key_identity_arn(props: ApiKeyCredentialProviderOptions) -> ICredentialProviderConfigpublic static ICredentialProviderConfig fromApiKeyIdentityArn(ApiKeyCredentialProviderOptions props)public static ICredentialProviderConfig FromApiKeyIdentityArn(ApiKeyCredentialProviderOptions props)func FromApiKeyIdentityArn(Props ApiKeyCredentialProviderOptions) ICredentialProviderConfig static #
Create an API key credential provider from Identity ARN Use this method when you have the Identity ARN as a string.
1 parameter · returns

Parameters

  • propspropspropspropsProps — - The configuration properties for the API key credential provider.

Returns: ICredentialProviderConfig configured for API key authentication

fromIamRole(props?: GatewayIamRoleCredentialProviderProps): ICredentialProviderConfig@staticmethod def from_iam_role(props: typing.Optional[GatewayIamRoleCredentialProviderProps] = None) -> ICredentialProviderConfigpublic static ICredentialProviderConfig fromIamRole(GatewayIamRoleCredentialProviderProps props)public static ICredentialProviderConfig FromIamRole(GatewayIamRoleCredentialProviderProps? props = null)func FromIamRole(Props GatewayIamRoleCredentialProviderProps) ICredentialProviderConfig static #
Create an IAM role credential provider.
notes

The gateway authenticates outbound requests using its own execution role (SigV4). Provide service and optionally region to explicitly choose the SigV4 signing service / region instead of relying on the gateway's inference from the target endpoint. Useful for cross-region calls and for targets where the service can't be inferred from the URL. Explicit service / region is only supported for MCP Server and OpenAPI targets; other target types must use the bare fromIamRole().

fromOauthIdentity(provider: IOAuth2CredentialProvider, options: FromOauthIdentityOptions): ICredentialProviderConfig@staticmethod def from_oauth_identity(provider: IOAuth2CredentialProvider, options: FromOauthIdentityOptions) -> ICredentialProviderConfigpublic static ICredentialProviderConfig fromOauthIdentity(IOAuth2CredentialProvider provider, FromOauthIdentityOptions options)public static ICredentialProviderConfig FromOauthIdentity(IOAuth2CredentialProvider provider, FromOauthIdentityOptions options)func FromOauthIdentity(Provider IOAuth2CredentialProvider, Options FromOauthIdentityOptions) ICredentialProviderConfig static #
Create an OAuth outbound auth configuration from a Token Vault {@link IOAuth2CredentialProvider} construct.

Prefer this over {@link GatewayCredentialProvider.fromOauthIdentityArn} when the provider is defined in CDK.

fromOauthIdentityArn(props: OAuthConfiguration): ICredentialProviderConfig@staticmethod def from_oauth_identity_arn(props: OAuthConfiguration) -> ICredentialProviderConfigpublic static ICredentialProviderConfig fromOauthIdentityArn(OAuthConfiguration props)public static ICredentialProviderConfig FromOauthIdentityArn(OAuthConfiguration props)func FromOauthIdentityArn(Props OAuthConfiguration) ICredentialProviderConfig static #
Create an OAuth credential provider from Identity ARN Use this method when you have the Identity ARN as a string.
1 parameter · returns

Parameters

  • propspropspropspropsProps — - The configuration properties for the OAuth credential provider.

Returns: ICredentialProviderConfig configured for OAuth authentication