S3ApiSchema

class aws_cdk.aws_bedrockagentcore.S3ApiSchema(location, bucket_owner_account_id=None)

Bases: ApiSchema

Class to define an API Schema from an S3 object.

ExampleMetadata:

infused

Example:

gateway = agentcore.Gateway(self, "MyGateway",
    gateway_name="my-gateway"
)

# Create an API key credential provider in Token Vault
api_key_provider = agentcore.ApiKeyCredentialProvider(self, "MyApiKeyProvider",
    api_key_credential_provider_name="my-apikey"
)

bucket = s3.Bucket.from_bucket_name(self, "ExistingBucket", "my-schema-bucket")
s3my_schema = agentcore.ApiSchema.from_s3_file(bucket, "schemas/myschema.yaml")

# Add an OpenAPI target using the L2 construct directly
target = gateway.add_open_api_target("MyTarget",
    gateway_target_name="my-api-target",
    description="Target for external API integration",
    api_schema=s3my_schema,
    credential_provider_configurations=[
        agentcore.GatewayCredentialProvider.from_api_key_identity(api_key_provider,
            credential_location=agentcore.ApiKeyCredentialLocation.header(
                credential_parameter_name="X-API-Key"
            )
        )
    ]
)

# This makes sure your s3 bucket is available before target
target.node.add_dependency(bucket)
Parameters:
  • location (Union[Location, Dict[str, Any]])

  • bucket_owner_account_id (Optional[str]) – The account ID of the S3 bucket owner for cross-account access.

Methods

bind(scope)

Bind the schema to a construct.

Parameters:

scope (Construct)

Return type:

None

grant_permissions_to_role(role)

Grant permissions to the role.

Parameters:

role (IRole)

Return type:

None

Attributes

bucket_owner_account_id

The account ID of the S3 bucket owner for cross-account access.

inline_schema

The inline OpenAPI schema definition as a string, if using an inline schema.

Can be in JSON or YAML format.

s3_file

The S3 location of the API schema file, if using an S3-based schema.

Contains the bucket name and object key information.

Static Methods

classmethod from_inline(schema)

Creates an API Schema from an inline string.

Parameters:

schema (str) –

  • the JSON or YAML payload defining the schema (OpenAPI or Smithy).

Return type:

InlineApiSchema

classmethod from_local_asset(path)

Creates an API Schema from a local file.

Parameters:

path (str) –

  • the path to the local file containing the OpenAPI schema for the action group.

Return type:

AssetApiSchema

classmethod from_s3_file(bucket, object_key, bucket_owner_account_id=None)

Creates an API Schema from an S3 File.

Parameters:
  • bucket (IBucket) –

    • the bucket containing the local file containing the OpenAPI schema for the action group.

  • object_key (str) –

    • object key in the bucket.

  • bucket_owner_account_id (Optional[str]) –

    • optional The account ID of the Amazon S3 bucket owner. This ID is used for cross-account access to the bucket.

Return type:

S3ApiSchema