fis

package
v1.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 28 Imported by: 0

README

Fault Injection Simulator

Parity grade: A · SDK aws-sdk-go-v2/service/fis@v1.37.18 · last audited 2026-07-12 (f8a54fdb)

Coverage

Metric Value
Operations audited 26 (14 ok, 12 other)
Feature families 3 (3 ok)
Known gaps 4
Deferred items 2
Resource leaks clean
Known gaps
  • Experiment reports (ExperimentReportConfiguration / ExperimentReport / GetExperiment "experimentReport" + "experimentReportConfiguration" fields) are entirely unimplemented — not in models.go, not in wire DTOs. Real FIS added this feature after the original build-out.
  • Running-experiment ExperimentTarget DTO omits Filters/ResourceTags/SelectionMode (present on the real wire shape as informational metadata alongside the resolved ResourceArns); ExperimentAction DTO omits Description. Both are additive, non-breaking omissions (zero-value on absence), not incorrect on the fields that are present.
  • "startAfter" dependency waiting in executeActionsOrdered is a no-op (topoSortActions already produces a valid topological order, so the loop's if !completed[dep] { continue } never actually blocks) — functionally correct today because execution is sequential and single-threaded, but if actions ever run concurrently this would need a real wait/signal, not a comment-only guard.
  • Experiment/action provider quota-vs-lock race: StartExperiment reads experimentCount/leverEngaged under RLock, releases it, then re-locks to write — two concurrent StartExperiment calls could both pass the maxExperiments=1000 check before either writes. Low real-world impact (large headroom, not attacker-adjacent in an emulator), not fixed this sweep.
Deferred
  • Experiment report configuration / report generation feature surface (see gaps)
  • Built-in action catalog completeness vs the full real AWS FIS action list (gopherstack ships a curated subset across EC2/RDS/ECS/EKS/DynamoDB/Lambda/SSM/network/CloudWatch/Kinesis + the aws:fis:inject-api-*/wait built-ins; real AWS has more actions per service and evolves this list independently of the API shape)

More

Documentation

Overview

Package fis provides an in-memory implementation of the AWS Fault Injection Service (FIS) API. It supports experiment templates, experiment lifecycle management, and auto-discovered FIS actions from other registered services.

Index

Constants

This section is empty.

Variables

View Source
var ErrActionNotFound = errors.New("ActionNotFound")

ErrActionNotFound is returned when a FIS action is not found.

View Source
var ErrExperimentNotFound = errors.New("ExperimentNotFound")

ErrExperimentNotFound is returned when an experiment is not found.

View Source
var ErrExperimentNotRunning = errors.New("ExperimentNotRunning")

ErrExperimentNotRunning is returned when trying to stop an experiment that is not running.

View Source
var ErrNilAppContext = errors.New("AppContext is required")

ErrNilAppContext is returned by Init when appCtx is nil.

View Source
var ErrResourceNotFound = errors.New("ResourceNotFound")

ErrResourceNotFound is returned when a tagged resource ARN is not known.

View Source
var ErrSafetyLeverEngaged = errors.New("SafetyLeverEngaged")

ErrSafetyLeverEngaged is returned when StartExperiment is blocked by an engaged safety lever.

View Source
var ErrSafetyLeverNotFound = errors.New("SafetyLeverNotFound")

ErrSafetyLeverNotFound is returned when the safety lever ID does not match this account.

View Source
var ErrTargetAccountConfigNotFound = errors.New("TargetAccountConfigurationNotFound")

ErrTargetAccountConfigNotFound is returned when a target account configuration is not found.

View Source
var ErrTargetResourceTypeNotFound = errors.New("TargetResourceTypeNotFound")

ErrTargetResourceTypeNotFound is returned when a target resource type is not found.

View Source
var ErrTemplateNotFound = errors.New("ExperimentTemplateNotFound")

ErrTemplateNotFound is returned when an experiment template is not found.

View Source
var ErrTooManyExperiments = errors.New("ServiceQuotaExceededException")

ErrTooManyExperiments is returned when the experiment count would exceed the cap.

View Source
var ErrTooManyTags = errors.New("TooManyTagsException")

ErrTooManyTags is returned when adding tags would exceed the 50-tag limit.

View Source
var ErrValidation = errors.New("ValidationException")

ErrValidation is returned when a required field is missing or has an invalid value.

Functions

This section is empty.

Types

type ActionParameter

type ActionParameter struct {
	Description string
	Required    bool
}

ActionParameter describes a parameter accepted by an action.

type ActionSummary

type ActionSummary struct {
	Targets     map[string]ActionTarget
	Parameters  map[string]ActionParameter
	Tags        map[string]string
	ID          string
	Arn         string
	Description string
}

ActionSummary is the response model for GetAction / ListActions.

type ActionTarget

type ActionTarget struct {
	ResourceType string
}

ActionTarget describes the target resource type required by an action.

type ConfigProvider

type ConfigProvider interface {
	GetFISSettings() Settings
}

ConfigProvider is a private interface to extract FIS configuration from the abstract AppContext Config.

type Experiment

type Experiment struct {
	CreationTime      time.Time                    `json:"creationTime"`
	StartTime         time.Time                    `json:"startTime"`
	ExperimentOptions *ExperimentExperimentOptions `json:"experimentOptions"`
	Targets           map[string]ExperimentTarget  `json:"targets"`
	Actions           map[string]ExperimentAction  `json:"actions"`
	LogConfiguration  *ExperimentLogConfiguration  `json:"logConfiguration"`
	Tags              map[string]string            `json:"tags"`
	EndTime           *time.Time                   `json:"endTime"`

	Status                           ExperimentStatus          `json:"status"`
	ExperimentTemplateID             string                    `json:"experimentTemplateID"`
	RoleArn                          string                    `json:"roleArn"`
	ID                               string                    `json:"id"`
	Arn                              string                    `json:"arn"`
	StopConditions                   []ExperimentStopCondition `json:"stopConditions"`
	TargetAccountConfigurationsCount int                       `json:"targetAccountConfigurationsCount,omitempty"`
	// contains filtered or unexported fields
}

Experiment is the in-memory representation of a running FIS experiment.

type ExperimentAction

type ExperimentAction struct {
	Parameters map[string]string      `json:"parameters"`
	Targets    map[string]string      `json:"targets"`
	StartTime  *time.Time             `json:"startTime"`
	EndTime    *time.Time             `json:"endTime"`
	Status     ExperimentActionStatus `json:"status"`
	ActionID   string                 `json:"actionID"`
}

ExperimentAction tracks the state of an individual experiment action.

type ExperimentActionStatus

type ExperimentActionStatus struct {
	Status string `json:"status"`
	Reason string `json:"reason"`
}

ExperimentActionStatus holds the status and reason for a single action.

type ExperimentCloudWatchLogsConfiguration

type ExperimentCloudWatchLogsConfiguration struct {
	LogGroupArn string `json:"logGroupArn"`
}

ExperimentCloudWatchLogsConfiguration holds the CloudWatch log group ARN.

type ExperimentExperimentOptions

type ExperimentExperimentOptions struct {
	AccountTargeting          string `json:"accountTargeting"`
	EmptyTargetResolutionMode string `json:"emptyTargetResolutionMode"`
}

ExperimentExperimentOptions controls account and target resolution behaviour.

type ExperimentLogConfiguration

type ExperimentLogConfiguration struct {
	CloudWatchLogsConfiguration *ExperimentCloudWatchLogsConfiguration `json:"cloudWatchLogsConfiguration"`
	S3Configuration             *ExperimentS3Configuration             `json:"s3Configuration"`
	LogSchemaVersion            int                                    `json:"logSchemaVersion"`
}

ExperimentLogConfiguration holds resolved log configuration for an experiment.

type ExperimentResolvedTarget

type ExperimentResolvedTarget struct {
	ResourceType         string
	TargetName           string
	ResolvedArns         []string
	TargetResourcesCount int
}

ExperimentResolvedTarget holds the resolved resources for a single target group.

type ExperimentS3Configuration

type ExperimentS3Configuration struct {
	BucketName string `json:"bucketName"`
	Prefix     string `json:"prefix"`
}

ExperimentS3Configuration holds the S3 bucket for experiment logs.

type ExperimentStatus

type ExperimentStatus struct {
	Error  *ExperimentStatusError `json:"error,omitempty"`
	Status string                 `json:"status"`
	Reason string                 `json:"reason,omitempty"`
}

ExperimentStatus holds the status string, an optional human-readable reason, and structured error info.

type ExperimentStatusError

type ExperimentStatusError struct {
	Code      string `json:"code,omitempty"`
	Location  string `json:"location,omitempty"`
	AccountID string `json:"accountId,omitempty"`
}

ExperimentStatusError holds structured error info for failed experiments. Field names mirror the real AWS FIS wire shape (types.ExperimentError): "code" and "location", not "exceptionName" — the real deserializer discards unknown keys, so a mismatched field name silently reaches SDK callers as an always-nil Code.

type ExperimentStopCondition

type ExperimentStopCondition struct {
	Source string `json:"source"`
	Value  string `json:"value"`
}

ExperimentStopCondition mirrors ExperimentTemplateStopCondition for running experiments.

type ExperimentTarget

type ExperimentTarget struct {
	Parameters   map[string]string `json:"parameters"`
	ResourceType string            `json:"resourceType"`
	ResourceArns []string          `json:"resourceArns"`
}

ExperimentTarget holds resolved resource ARNs for a target group.

type ExperimentTargetAccountConfiguration

type ExperimentTargetAccountConfiguration struct {
	ExperimentID string `json:"experimentId"`
	AccountID    string `json:"accountId"`
	Description  string `json:"description"`
	RoleArn      string `json:"roleArn"`
}

ExperimentTargetAccountConfiguration is the in-memory representation of a FIS target account configuration associated with a running experiment.

type ExperimentTemplate

type ExperimentTemplate struct {
	CreationTime      time.Time                            `json:"creationTime"`
	LastUpdateTime    time.Time                            `json:"lastUpdateTime"`
	Tags              map[string]string                    `json:"tags"`
	Targets           map[string]ExperimentTemplateTarget  `json:"targets"`
	Actions           map[string]ExperimentTemplateAction  `json:"actions"`
	LogConfiguration  *ExperimentTemplateLogConfiguration  `json:"logConfiguration"`
	ExperimentOptions *ExperimentTemplateExperimentOptions `json:"experimentOptions"`
	ID                string                               `json:"id"`
	Arn               string                               `json:"arn"`
	Description       string                               `json:"description"`
	RoleArn           string                               `json:"roleArn"`
	StopConditions    []ExperimentTemplateStopCondition    `json:"stopConditions"`
}

ExperimentTemplate is the in-memory representation of a FIS experiment template.

type ExperimentTemplateAction

type ExperimentTemplateAction struct {
	Parameters  map[string]string `json:"parameters"`
	Targets     map[string]string `json:"targets"`
	ActionID    string            `json:"actionID"`
	Description string            `json:"description"`
	StartAfter  []string          `json:"startAfter"`
}

ExperimentTemplateAction describes a fault action within a template.

type ExperimentTemplateCloudWatchLogsConfiguration

type ExperimentTemplateCloudWatchLogsConfiguration struct {
	LogGroupArn string `json:"logGroupArn"`
}

ExperimentTemplateCloudWatchLogsConfiguration holds the CloudWatch log group ARN.

type ExperimentTemplateExperimentOptions

type ExperimentTemplateExperimentOptions struct {
	AccountTargeting          string `json:"accountTargeting"`
	EmptyTargetResolutionMode string `json:"emptyTargetResolutionMode"`
}

ExperimentTemplateExperimentOptions controls account and target resolution behaviour.

type ExperimentTemplateLogConfiguration

type ExperimentTemplateLogConfiguration struct {
	CloudWatchLogsConfiguration *ExperimentTemplateCloudWatchLogsConfiguration `json:"cloudWatchLogsConfiguration"`
	S3Configuration             *ExperimentTemplateS3Configuration             `json:"s3Configuration"`
	LogSchemaVersion            int                                            `json:"logSchemaVersion"`
}

ExperimentTemplateLogConfiguration specifies where experiment logs are sent.

type ExperimentTemplateS3Configuration

type ExperimentTemplateS3Configuration struct {
	BucketName string `json:"bucketName"`
	Prefix     string `json:"prefix"`
}

ExperimentTemplateS3Configuration holds the S3 bucket for experiment logs.

type ExperimentTemplateStopCondition

type ExperimentTemplateStopCondition struct {
	Source string `json:"source"`
	Value  string `json:"value"`
}

ExperimentTemplateStopCondition defines when an experiment should automatically stop.

type ExperimentTemplateTarget

type ExperimentTemplateTarget struct {
	ResourceTags  map[string]string                `json:"resourceTags"`
	Parameters    map[string]string                `json:"parameters"`
	ResourceType  string                           `json:"resourceType"`
	SelectionMode string                           `json:"selectionMode"`
	ResourceArns  []string                         `json:"resourceArns"`
	Filters       []ExperimentTemplateTargetFilter `json:"filters"`
}

ExperimentTemplateTarget defines how resources are selected for a fault action.

type ExperimentTemplateTargetFilter

type ExperimentTemplateTargetFilter struct {
	Path   string   `json:"path"`
	Values []string `json:"values"`
}

ExperimentTemplateTargetFilter narrows the set of matching resources.

type ExportedActionDTO

type ExportedActionDTO = experimentTemplateActionDTO

ExportedActionDTO is the exported version of experimentTemplateActionDTO for use by the dashboard package.

type ExportedCreateTemplateRequest

type ExportedCreateTemplateRequest = createExperimentTemplateRequest

ExportedCreateTemplateRequest is the exported version of createExperimentTemplateRequest for use by the dashboard package.

type ExportedStartExperimentRequest

type ExportedStartExperimentRequest = startExperimentRequest

ExportedStartExperimentRequest is the exported version of startExperimentRequest for use by the dashboard package.

type ExportedStopConditionDTO

type ExportedStopConditionDTO = experimentTemplateStopConditionDTO

ExportedStopConditionDTO is the exported version of experimentTemplateStopConditionDTO for use by the dashboard package.

type Handler

type Handler struct {
	Backend StorageBackend

	DefaultRegion string
	AccountID     string
	// contains filtered or unexported fields
}

Handler is the Echo HTTP handler for the FIS REST API.

func NewHandler

func NewHandler(backend StorageBackend) *Handler

NewHandler creates a new FIS handler.

func (*Handler) ChaosOperations

func (h *Handler) ChaosOperations() []string

ChaosOperations returns all operations that can be fault-injected.

func (*Handler) ChaosRegions

func (h *Handler) ChaosRegions() []string

ChaosRegions returns all regions this FIS instance handles.

func (*Handler) ChaosServiceName

func (h *Handler) ChaosServiceName() string

ChaosServiceName returns the lowercase AWS service name for fault rule matching.

func (*Handler) ExtractOperation

func (h *Handler) ExtractOperation(c *echo.Context) string

ExtractOperation extracts the FIS operation name from the request.

func (*Handler) ExtractResource

func (h *Handler) ExtractResource(c *echo.Context) string

ExtractResource extracts the resource ID from the URL path.

func (*Handler) GetSupportedOperations

func (h *Handler) GetSupportedOperations() []string

GetSupportedOperations returns the list of supported FIS operations.

func (*Handler) Handler

func (h *Handler) Handler() echo.HandlerFunc

Handler returns the Echo handler function for FIS requests.

func (*Handler) MatchPriority

func (h *Handler) MatchPriority() int

MatchPriority returns the routing priority for the FIS handler. FIS uses path-based routing and is inserted between PriorityPathVersioned (85) and PriorityFormRDS (84).

func (*Handler) Name

func (h *Handler) Name() string

Name returns the service name.

func (*Handler) Reset

func (h *Handler) Reset()

Reset implements service.Resettable by delegating to the backend.

func (*Handler) Restore

func (h *Handler) Restore(ctx context.Context, data []byte) error

Restore implements persistence.Persistable by delegating to the backend.

func (*Handler) RouteMatcher

func (h *Handler) RouteMatcher() service.Matcher

RouteMatcher returns a function that matches FIS REST API requests by path prefix.

func (*Handler) SetActionProviders

func (h *Handler) SetActionProviders(providers []service.FISActionProvider)

SetActionProviders registers external FIS action providers with the backend.

func (*Handler) SetFaultStore

func (h *Handler) SetFaultStore(store *chaos.FaultStore)

SetFaultStore injects the chaos FaultStore into the backend for inject-api-* actions.

func (*Handler) Shutdown

func (h *Handler) Shutdown(_ context.Context)

Shutdown cancels all running experiment goroutines to prevent resource leaks. It satisfies service.Shutdowner.

func (*Handler) Snapshot

func (h *Handler) Snapshot(ctx context.Context) []byte

Snapshot implements persistence.Persistable by delegating to the backend.

func (*Handler) StartWorker

func (h *Handler) StartWorker(ctx context.Context) error

StartWorker starts the background janitor if configured.

func (*Handler) WithJanitor

func (h *Handler) WithJanitor(
	interval, experimentTTL time.Duration,
	taskTimeout ...time.Duration,
) *Handler

WithJanitor attaches a background janitor to the handler. If the backend is not an *InMemoryBackend, this is a no-op. The optional taskTimeout bounds each sweep; 0 means no per-task timeout.

type InMemoryBackend

type InMemoryBackend struct {
	// contains filtered or unexported fields
}

InMemoryBackend is the in-memory implementation of StorageBackend.

func NewInMemoryBackend

func NewInMemoryBackend(accountID, region string) *InMemoryBackend

NewInMemoryBackend creates a new InMemoryBackend with a background service context.

func NewInMemoryBackendWithContext

func NewInMemoryBackendWithContext(svcCtx context.Context, accountID, region string) *InMemoryBackend

NewInMemoryBackendWithContext creates a new InMemoryBackend whose experiment goroutines are parented by svcCtx so they are cancelled on server shutdown. If svcCtx is nil, context.Background is used.

func (*InMemoryBackend) CreateExperimentTemplate

func (b *InMemoryBackend) CreateExperimentTemplate(
	input *createExperimentTemplateRequest,
	accountID, region string,
) (*ExperimentTemplate, error)

CreateExperimentTemplate creates a new experiment template.

func (*InMemoryBackend) CreateTargetAccountConfiguration

func (b *InMemoryBackend) CreateTargetAccountConfiguration(
	templateID, accountID, roleArn, description string,
) (*TargetAccountConfiguration, error)

CreateTargetAccountConfiguration creates or replaces a target account configuration for the given template.

func (*InMemoryBackend) DeleteExperimentTemplate

func (b *InMemoryBackend) DeleteExperimentTemplate(id string) error

DeleteExperimentTemplate deletes an experiment template by ID, including its target account configurations.

func (*InMemoryBackend) DeleteTargetAccountConfiguration

func (b *InMemoryBackend) DeleteTargetAccountConfiguration(
	templateID, accountID string,
) (*TargetAccountConfiguration, error)

DeleteTargetAccountConfiguration deletes a target account configuration.

func (*InMemoryBackend) GetAction

func (b *InMemoryBackend) GetAction(id string) (*ActionSummary, error)

GetAction returns a single action by ID.

func (*InMemoryBackend) GetExperiment

func (b *InMemoryBackend) GetExperiment(id string) (*Experiment, error)

GetExperiment retrieves an experiment by ID.

func (*InMemoryBackend) GetExperimentTargetAccountConfiguration

func (b *InMemoryBackend) GetExperimentTargetAccountConfiguration(
	experimentID, accountID string,
) (*ExperimentTargetAccountConfiguration, error)

GetExperimentTargetAccountConfiguration returns the target account configuration for a running experiment. It resolves the configuration from the experiment's source template.

func (*InMemoryBackend) GetExperimentTemplate

func (b *InMemoryBackend) GetExperimentTemplate(id string) (*ExperimentTemplate, error)

GetExperimentTemplate retrieves an experiment template by ID.

func (*InMemoryBackend) GetSafetyLever

func (b *InMemoryBackend) GetSafetyLever(id string) (*SafetyLever, error)

GetSafetyLever returns the current state of the account's safety lever. Accepts either the account ID or the conventional "default" alias.

func (*InMemoryBackend) GetTargetAccountConfiguration

func (b *InMemoryBackend) GetTargetAccountConfiguration(
	templateID, accountID string,
) (*TargetAccountConfiguration, error)

GetTargetAccountConfiguration returns a single target account configuration by template ID and account ID.

func (*InMemoryBackend) GetTargetResourceType

func (b *InMemoryBackend) GetTargetResourceType(resourceType string) (*TargetResourceTypeSummary, error)

GetTargetResourceType returns a single target resource type by resource type string.

func (*InMemoryBackend) ListActions

func (b *InMemoryBackend) ListActions() []ActionSummary

ListActions returns all available FIS actions: built-in + service-provided, sorted by ID. Built-in actions take precedence over provider-supplied actions with the same ID (dedup by ID).

func (*InMemoryBackend) ListExperimentResolvedTargets

func (b *InMemoryBackend) ListExperimentResolvedTargets(id string) ([]ExperimentResolvedTarget, error)

ListExperimentResolvedTargets returns the resolved resource ARN counts for each named target group in the given experiment.

func (*InMemoryBackend) ListExperimentTargetAccountConfigurations

func (b *InMemoryBackend) ListExperimentTargetAccountConfigurations(
	experimentID string,
) ([]*ExperimentTargetAccountConfiguration, error)

ListExperimentTargetAccountConfigurations lists all target account configurations for a running experiment, sorted by account ID. It resolves configurations from the experiment's source template.

func (*InMemoryBackend) ListExperimentTemplates

func (b *InMemoryBackend) ListExperimentTemplates() ([]*ExperimentTemplate, error)

ListExperimentTemplates returns all experiment templates sorted by ID.

func (*InMemoryBackend) ListExperiments

func (b *InMemoryBackend) ListExperiments() ([]*Experiment, error)

ListExperiments returns all experiments sorted by ID.

func (*InMemoryBackend) ListTagsForResource

func (b *InMemoryBackend) ListTagsForResource(resourceARN string) (map[string]string, error)

ListTagsForResource returns tags for a resource identified by its ARN.

func (*InMemoryBackend) ListTargetAccountConfigurations

func (b *InMemoryBackend) ListTargetAccountConfigurations(templateID string) ([]*TargetAccountConfiguration, error)

ListTargetAccountConfigurations returns all target account configurations for a template, sorted by account ID.

func (*InMemoryBackend) ListTargetResourceTypes

func (b *InMemoryBackend) ListTargetResourceTypes() []TargetResourceTypeSummary

ListTargetResourceTypes returns all known target resource types.

func (*InMemoryBackend) Reset

func (b *InMemoryBackend) Reset()

Reset clears all in-memory state, cancelling any running experiments. The safety lever is re-initialised to its default disengaged state.

func (*InMemoryBackend) Restore

func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error

Restore loads backend state from a JSON snapshot. It cancels any in-flight experiment goroutines before replacing state to prevent goroutine leaks when restored experiments have no cancel func.

func (*InMemoryBackend) SetActionProviders

func (b *InMemoryBackend) SetActionProviders(providers []service.FISActionProvider)

SetActionProviders registers external FIS action providers discovered from the registry.

func (*InMemoryBackend) SetFaultStore

func (b *InMemoryBackend) SetFaultStore(store *chaos.FaultStore)

SetFaultStore injects the chaos FaultStore.

func (*InMemoryBackend) Snapshot

func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte

Snapshot serialises the backend state to JSON.

func (*InMemoryBackend) StartExperiment

func (b *InMemoryBackend) StartExperiment(
	_ context.Context,
	input *startExperimentRequest,
	accountID, region string,
) (*Experiment, error)

StartExperiment creates and starts a new experiment from a template.

func (*InMemoryBackend) StopAllExperiments

func (b *InMemoryBackend) StopAllExperiments()

StopAllExperiments cancels every running experiment goroutine. Called during graceful shutdown to prevent goroutine leaks.

func (*InMemoryBackend) StopExperiment

func (b *InMemoryBackend) StopExperiment(id string) (*Experiment, error)

StopExperiment stops a running experiment.

func (*InMemoryBackend) TagResource

func (b *InMemoryBackend) TagResource(resourceARN string, tags map[string]string) error

TagResource adds or updates tags on a resource.

func (*InMemoryBackend) UntagResource

func (b *InMemoryBackend) UntagResource(resourceARN string, keys []string) error

UntagResource removes specific tags from a resource.

func (*InMemoryBackend) UpdateExperimentTemplate

func (b *InMemoryBackend) UpdateExperimentTemplate(
	id string,
	input *updateExperimentTemplateRequest,
) (*ExperimentTemplate, error)

UpdateExperimentTemplate updates an existing experiment template.

func (*InMemoryBackend) UpdateSafetyLeverState

func (b *InMemoryBackend) UpdateSafetyLeverState(
	id string,
	input *updateSafetyLeverStateRequest,
) (*SafetyLever, error)

UpdateSafetyLeverState updates the state of the account's safety lever. Accepts either the account ID or the conventional "default" alias. Setting status to "engaged" blocks new experiments from starting.

func (*InMemoryBackend) UpdateTargetAccountConfiguration

func (b *InMemoryBackend) UpdateTargetAccountConfiguration(
	templateID, accountID string,
	roleArn, description *string,
) (*TargetAccountConfiguration, error)

UpdateTargetAccountConfiguration updates an existing target account configuration. Only non-nil pointer fields are applied.

type Janitor

type Janitor struct {
	Backend       *InMemoryBackend
	Interval      time.Duration
	ExperimentTTL time.Duration
	TaskTimeout   time.Duration
}

Janitor is the FIS background worker that evicts completed experiments after a configurable TTL to prevent unbounded growth of in-memory state.

func NewJanitor

func NewJanitor(backend *InMemoryBackend, interval, experimentTTL time.Duration) *Janitor

NewJanitor creates a new FIS Janitor for the given backend. Zero values for interval or experimentTTL fall back to defaults.

func (*Janitor) Run

func (j *Janitor) Run(ctx context.Context)

Run runs the janitor loop until ctx is cancelled.

func (*Janitor) SweepOnce

func (j *Janitor) SweepOnce(ctx context.Context)

SweepOnce runs a single sweep pass. Exposed for testing.

type Provider

type Provider struct{}

Provider implements service.Provider for the FIS service.

func (*Provider) Init

Init initializes the FIS service backend and handler.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the provider name.

type SafetyLever

type SafetyLever struct {
	Tags  map[string]string `json:"tags"`
	State SafetyLeverState  `json:"state"`
	ID    string            `json:"id"`
	Arn   string            `json:"arn"`
}

SafetyLever is the model for the FIS account-level safety lever.

type SafetyLeverState

type SafetyLeverState struct {
	Reason string `json:"reason"`
	Status string `json:"status"` // "disengaged" | "engaged"
}

SafetyLeverState holds the status and optional human-readable reason.

type Settings

type Settings struct {
	JanitorInterval time.Duration `json:"janitor_interval" env:"FIS_JANITOR_INTERVAL" default:"1m"  help:"Janitor tick."`
	ExperimentTTL   time.Duration `json:"experiment_ttl"   env:"FIS_EXPERIMENT_TTL"   default:"24h" help:"Done-exp TTL."`
}

Settings holds service-level configuration for the FIS backend. Fields are picked up by the Kong CLI parser when this struct is embedded in the root CLI command.

type StorageBackend

type StorageBackend interface {
	// Template operations
	CreateExperimentTemplate(
		input *createExperimentTemplateRequest,
		accountID, region string,
	) (*ExperimentTemplate, error)
	GetExperimentTemplate(id string) (*ExperimentTemplate, error)
	UpdateExperimentTemplate(id string, input *updateExperimentTemplateRequest) (*ExperimentTemplate, error)
	DeleteExperimentTemplate(id string) error
	ListExperimentTemplates() ([]*ExperimentTemplate, error)

	// Experiment operations
	StartExperiment(ctx context.Context, input *startExperimentRequest, accountID, region string) (*Experiment, error)
	GetExperiment(id string) (*Experiment, error)
	StopExperiment(id string) (*Experiment, error)
	ListExperiments() ([]*Experiment, error)

	// Phase 3 — resolved targets
	ListExperimentResolvedTargets(id string) ([]ExperimentResolvedTarget, error)

	// Phase 3 — safety lever
	GetSafetyLever(id string) (*SafetyLever, error)
	UpdateSafetyLeverState(id string, input *updateSafetyLeverStateRequest) (*SafetyLever, error)

	// Action / target-resource-type discovery
	ListActions() []ActionSummary
	GetAction(id string) (*ActionSummary, error)
	ListTargetResourceTypes() []TargetResourceTypeSummary
	GetTargetResourceType(resourceType string) (*TargetResourceTypeSummary, error)

	// Tag operations
	ListTagsForResource(resourceARN string) (map[string]string, error)
	TagResource(resourceARN string, tags map[string]string) error
	UntagResource(resourceARN string, keys []string) error

	// Target account configuration operations (template-scoped)
	CreateTargetAccountConfiguration(
		templateID, accountID, roleArn, description string,
	) (*TargetAccountConfiguration, error)
	DeleteTargetAccountConfiguration(templateID, accountID string) (*TargetAccountConfiguration, error)
	GetTargetAccountConfiguration(templateID, accountID string) (*TargetAccountConfiguration, error)
	UpdateTargetAccountConfiguration(
		templateID, accountID string,
		roleArn, description *string,
	) (*TargetAccountConfiguration, error)
	ListTargetAccountConfigurations(templateID string) ([]*TargetAccountConfiguration, error)

	// Experiment target account configuration operations (experiment-scoped, read-only)
	GetExperimentTargetAccountConfiguration(
		experimentID, accountID string,
	) (*ExperimentTargetAccountConfiguration, error)
	ListExperimentTargetAccountConfigurations(experimentID string) ([]*ExperimentTargetAccountConfiguration, error)

	// SetFaultStore injects the chaos FaultStore used for inject-api-* actions.
	SetFaultStore(store *chaos.FaultStore)

	// SetActionProviders registers external service action providers.
	SetActionProviders(providers []service.FISActionProvider)
}

StorageBackend is the interface implemented by the FIS in-memory store.

type TargetAccountConfiguration

type TargetAccountConfiguration struct {
	ExperimentTemplateID string `json:"experimentTemplateId"`
	AccountID            string `json:"accountId"`
	Description          string `json:"description"`
	RoleArn              string `json:"roleArn"`
}

TargetAccountConfiguration is the in-memory representation of a FIS target account configuration associated with an experiment template.

type TargetResourceTypeParameter

type TargetResourceTypeParameter struct {
	Description string
	Required    bool
}

TargetResourceTypeParameter describes a parameter accepted when targeting a resource type.

type TargetResourceTypeSummary

type TargetResourceTypeSummary struct {
	Parameters   map[string]TargetResourceTypeParameter
	ResourceType string
	Description  string
}

TargetResourceTypeSummary is the response model for GetTargetResourceType / ListTargetResourceTypes.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL