Documentation
¶
Overview ¶
Package bedrockagentcorecontrol emulates the Amazon Bedrock AgentCore control plane.
Index ¶
- Variables
- type AuthSession
- type Handler
- func (h *Handler) ChaosOperations() []string
- func (h *Handler) ChaosRegions() []string
- func (h *Handler) ChaosServiceName() string
- func (h *Handler) ExtractOperation(c *echo.Context) string
- func (h *Handler) ExtractResource(c *echo.Context) string
- func (h *Handler) GetSupportedOperations() []string
- func (h *Handler) Handler() echo.HandlerFunc
- func (h *Handler) MatchPriority() int
- func (h *Handler) Name() string
- func (h *Handler) Reset()
- func (h *Handler) Restore(ctx context.Context, data []byte) error
- func (h *Handler) RouteMatcher() service.Matcher
- func (h *Handler) Snapshot(ctx context.Context) []byte
- type InMemoryBackend
- func (b *InMemoryBackend) AccountID() string
- func (b *InMemoryBackend) DataPlane() dataplane.Control
- func (b *InMemoryBackend) Region() string
- func (b *InMemoryBackend) Reset()
- func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
- func (b *InMemoryBackend) SetAllowExternalTargets(allow bool)
- func (b *InMemoryBackend) SetJWKSProvider(p JWKSProvider)
- func (b *InMemoryBackend) SetKeyChecker(c cmek.KeyChecker)
- func (b *InMemoryBackend) SetLifecycleDelay(d time.Duration)
- func (b *InMemoryBackend) SetReferences(r References)
- func (b *InMemoryBackend) SetSigV4Secret(secret string)
- func (b *InMemoryBackend) SetTrustedRoots(extra *x509.CertPool)
- func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
- func (b *InMemoryBackend) VerifyUserJWT(ctx context.Context, token string) (string, error)
- type JWKSProvider
- type LambdaInvoker
- type ObjectChecker
- type Provider
- type References
- type Resource
- type ResourcePolicy
- type RestAPIHost
- type RestAPIRequest
- type RestAPIResponse
- type RoleChecker
- type SecretStore
- type TokenVault
- type Version
Constants ¶
This section is empty.
Variables ¶
ErrRestAPIHostUnavailable is returned by a RestAPIHost that has no API Gateway behind it.
Functions ¶
This section is empty.
Types ¶
type AuthSession ¶
type AuthSession struct {
Created time.Time `json:"created"`
Expires time.Time `json:"expires"`
ID string `json:"id"`
State string `json:"state"`
Account string `json:"account"`
Region string `json:"region"`
Kind string `json:"kind"`
ProviderID string `json:"providerId"`
GatewayID string `json:"gatewayId,omitempty"`
TargetID string `json:"targetId,omitempty"`
UserID string `json:"userId"`
ReturnURL string `json:"returnUrl,omitempty"`
CustomState string `json:"customState,omitempty"`
Status string `json:"status"`
AccessToken string `json:"accessToken,omitempty"`
RefreshToken string `json:"refreshToken,omitempty"`
Scopes []string `json:"scopes,omitempty"`
Bound bool `json:"bound,omitempty"`
}
AuthSession is one three-legged OAuth authorization of a gateway target or of a workload user.
type Handler ¶
type Handler struct {
Backend *InMemoryBackend
DefaultRegion string
// contains filtered or unexported fields
}
Handler serves the AgentCore control-plane REST-JSON API.
func (*Handler) ChaosOperations ¶
ChaosOperations lists the fault-injectable operations.
func (*Handler) ChaosRegions ¶
ChaosRegions lists the regions this handler serves.
func (*Handler) ChaosServiceName ¶
ChaosServiceName returns the lowercase service name for fault rules.
func (*Handler) ExtractOperation ¶
ExtractOperation returns the operation name.
func (*Handler) ExtractResource ¶
ExtractResource returns the resource ARN or identifier the request addresses.
func (*Handler) GetSupportedOperations ¶
GetSupportedOperations lists every implemented operation.
func (*Handler) Handler ¶
func (h *Handler) Handler() echo.HandlerFunc
Handler returns the echo handler.
func (*Handler) MatchPriority ¶
MatchPriority returns the routing priority.
func (*Handler) RouteMatcher ¶
RouteMatcher matches by SigV4 signing name (or SDK user agent) plus a known path shape.
type InMemoryBackend ¶
type InMemoryBackend struct {
// contains filtered or unexported fields
}
InMemoryBackend is the AgentCore control-plane state; one coarse lock guards every table.
func NewInMemoryBackend ¶
func NewInMemoryBackend(accountID, region string) *InMemoryBackend
NewInMemoryBackend creates an empty backend.
func (*InMemoryBackend) AccountID ¶
func (b *InMemoryBackend) AccountID() string
AccountID returns the default account.
func (*InMemoryBackend) DataPlane ¶
func (b *InMemoryBackend) DataPlane() dataplane.Control
DataPlane returns the seam the AgentCore data plane resolves control-plane resources through.
func (*InMemoryBackend) Region ¶
func (b *InMemoryBackend) Region() string
Region returns the default Region.
func (*InMemoryBackend) Restore ¶
func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
Restore loads a snapshot; an incompatible version is discarded.
func (*InMemoryBackend) SetAllowExternalTargets ¶
func (b *InMemoryBackend) SetAllowExternalTargets(allow bool)
SetAllowExternalTargets lets gateway targets and JWKS fetches reach hosts outside loopback.
func (*InMemoryBackend) SetJWKSProvider ¶
func (b *InMemoryBackend) SetJWKSProvider(p JWKSProvider)
SetJWKSProvider resolves signing keys of issuers hosted by the emulator (Cognito user pools).
func (*InMemoryBackend) SetKeyChecker ¶
func (b *InMemoryBackend) SetKeyChecker(c cmek.KeyChecker)
SetKeyChecker resolves kmsKeyArn and encryptionKeyArn members against AWS KMS; nil disables the lookup.
func (*InMemoryBackend) SetLifecycleDelay ¶
func (b *InMemoryBackend) SetLifecycleDelay(d time.Duration)
SetLifecycleDelay keeps resources in CREATING, UPDATING and DELETING for d; zero settles immediately.
func (*InMemoryBackend) SetReferences ¶
func (b *InMemoryBackend) SetReferences(r References)
SetReferences wires lookups of resources owned by other services.
func (*InMemoryBackend) SetSigV4Secret ¶
func (b *InMemoryBackend) SetSigV4Secret(secret string)
SetSigV4Secret sets the secret AWS_IAM gateways verify request signatures against.
func (*InMemoryBackend) SetTrustedRoots ¶
func (b *InMemoryBackend) SetTrustedRoots(extra *x509.CertPool)
SetTrustedRoots adds CAs trusted (besides the system roots) by outbound gateway target, JWKS and OAuth requests.
func (*InMemoryBackend) Snapshot ¶
func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
Snapshot serialises the backend state.
func (*InMemoryBackend) VerifyUserJWT ¶
VerifyUserJWT verifies a user token's signature against the JWKS of its issuer and returns its subject. The issuer is read from the unverified token, so the JWKS is fetched only from loopback unless external targets are enabled.
type JWKSProvider ¶
JWKSProvider resolves RSA signing keys of issuers hosted by the emulator (Cognito user pools).
type LambdaInvoker ¶
type LambdaInvoker interface {
InvokeLambda(ctx context.Context, functionARN, clientContext string, payload []byte) (
result []byte, functionError string, err error)
}
LambdaInvoker runs a Lambda function in-process; functionError is the X-Amz-Function-Error value.
type ObjectChecker ¶
ObjectChecker is the optional References extension that tests an S3 object exists without reading it.
type Provider ¶
type Provider struct{}
Provider implements service.Provider for the Bedrock AgentCore control plane.
func (*Provider) Init ¶
func (p *Provider) Init(ctx *service.AppContext) (service.Registerable, error)
Init builds the backend and handler.
type References ¶
type References interface {
ECRRepositoryExists(account, region, repository string) bool
LambdaFunctionExists(arn string) bool
SecretExists(arn string) bool
// ReadObjectUpTo reads at most limit bytes; an object larger than limit is reported as tooLarge, not buffered.
ReadObjectUpTo(bucket, key string, limit int64) (data []byte, found, tooLarge bool)
}
References resolves resources owned by other emulated services; nil members skip the check.
type Resource ¶
type Resource struct {
Created time.Time `json:"created"`
Updated time.Time `json:"updated"`
SettleAt time.Time `json:"settleAt"`
Doc map[string]any `json:"doc"`
Tags map[string]string `json:"tags,omitempty"`
Aux map[string]any `json:"aux,omitempty"`
Account string `json:"account"`
Region string `json:"region"`
Kind string `json:"kind"`
Parent string `json:"parent,omitempty"`
ParentARN string `json:"parentArn,omitempty"`
ID string `json:"id"`
ARN string `json:"arn,omitempty"`
Status string `json:"status,omitempty"`
Transition string `json:"transition,omitempty"`
Versions []Version `json:"versions,omitempty"`
Deleting bool `json:"deleting,omitempty"`
System bool `json:"system,omitempty"`
}
Resource is one AgentCore control-plane resource. Doc holds the caller-supplied members verbatim (JSON-decoded); server-assigned identity, status, timestamps and tags live in typed fields.
type ResourcePolicy ¶
ResourcePolicy is the resource-based policy attached to a runtime, endpoint or gateway ARN.
type RestAPIHost ¶
type RestAPIHost interface {
RestAPIExport(region, restAPIID, stage string) (map[string]any, error)
InvokeRestAPI(ctx context.Context, region string, req RestAPIRequest) (RestAPIResponse, error)
}
RestAPIHost reaches REST APIs of the emulated API Gateway: it exports a stage as OpenAPI 3 and serves a request through the stage's data-plane path.
type RestAPIRequest ¶
type RestAPIRequest struct {
Headers map[string]string
Query map[string]string
APIID string
Stage string
Method string
Path string
Body []byte
}
RestAPIRequest is an in-process call to a REST API stage.
type RestAPIResponse ¶
RestAPIResponse is the stage's reply.
type RoleChecker ¶
RoleChecker is the optional References extension that verifies IAM roles exist.
type SecretStore ¶
type SecretStore interface {
PutSecret(account, region, name, value string) (string, error)
GetSecret(arn string) (string, bool)
DeleteSecret(arn string)
}
SecretStore is the optional References extension that persists credential provider secrets in Secrets Manager.
type TokenVault ¶
type TokenVault struct {
Modified time.Time `json:"modified"`
KMS map[string]any `json:"kms"`
Key string `json:"key"`
}
TokenVault is the per-account token vault configuration.
type Version ¶
type Version struct {
Created time.Time `json:"created"`
Doc map[string]any `json:"doc"`
ID string `json:"id"`
Branch string `json:"branch,omitempty"`
Parents []string `json:"parents,omitempty"`
}
Version is an immutable snapshot taken on create and on every update of a versioned resource.
Source Files
¶
- args.go
- cmek.go
- dataplane.go
- engine.go
- errors.go
- handler.go
- hooks.go
- hooks_data.go
- hooks_gateway.go
- hooks_memory.go
- hooks_policy.go
- hooks_runtime.go
- jwks_cache.go
- kinds.go
- mcp_apigw.go
- mcp_auth.go
- mcp_call.go
- mcp_http.go
- mcp_modern.go
- mcp_openapi.go
- mcp_outbound.go
- mcp_search.go
- mcp_tools.go
- models.go
- oauth_flow.go
- ops.go
- ops_special.go
- persistence.go
- provider.go
- quotas.go
- registry_sync.go
- spec.go
- status.go
- store.go
- validate.go
- validate_nested.go
- xref.go