Skip to content
v2.278.0

GatewayTargetOpenApiProps Struct ​

Properties for creating an OpenAPI-based Gateway Target.

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,
		}),
	},
})

Properties ​

apiSchemaApiSchemaapi_schemaApiSchemaapiSchemaApiSchemaApiSchemaApiSchemaApiSchemaApiSchema required #
The OpenAPI schema defining the API.
credentialProviderConfigurationsoptionalICredentialProviderConfig[]credential_provider_configurationsoptionaltyping.List[ICredentialProviderConfig]credentialProviderConfigurationsoptionalList<ICredentialProviderConfig>CredentialProviderConfigurationsoptionalICredentialProviderConfig[]CredentialProviderConfigurationsoptional*[]ICredentialProviderConfig #
Credential providers for authentication OpenAPI targets support API key and OAuth authentication (not IAM).

Default: If not provided, defaults to IAM role which will fail at runtime

descriptionoptionalstringdescriptionoptionalstrdescriptionoptionalStringDescriptionoptionalstringDescriptionoptional*string #
Optional description for the gateway target The description can have up to 200 characters.

Default: No description

gatewayIGatewaygatewayIGatewaygatewayIGatewayGatewayIGatewayGatewayIGateway required #
The gateway this target belongs to.
gatewayTargetNameoptionalstringgateway_target_nameoptionalstrgatewayTargetNameoptionalStringGatewayTargetNameoptionalstringGatewayTargetNameoptional*string #
The name of the gateway target The name must be unique within the gateway Pattern: ^([0-9a-zA-Z][-]?){1,100}$.

Default: auto generate

validateOpenApiSchemaoptionalbooleanvalidate_open_api_schemaoptionalboolvalidateOpenApiSchemaoptionalBooleanValidateOpenApiSchemaoptionalboolValidateOpenApiSchemaoptional*bool = true #
Whether to validate the OpenAPI schema (only applies to inline schemas) Note: Validation is only performed for inline schemas during CDK synthesis.

S3 and asset-based schemas cannot be validated at synthesis time.