statebackend

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotConfigured = errors.New("统一 Terraform 状态中心尚未配置")
	ErrInvalidConfig = errors.New("invalid Terraform state backend configuration")
)

Functions

This section is empty.

Types

type Input

type Input struct {
	Enabled         bool   `json:"enabled"`
	Bucket          string `json:"bucket"`
	Region          string `json:"region"`
	KeyPrefix       string `json:"key_prefix"`
	KMSKeyID        string `json:"kms_key_id"`
	AccessKeyID     string `json:"access_key_id"`
	SecretAccessKey string `json:"secret_access_key"`
	SessionToken    string `json:"session_token"`
}

type PublicInfo

type PublicInfo struct {
	Configured      bool      `json:"configured"`
	Enabled         bool      `json:"enabled"`
	Bucket          string    `json:"bucket,omitempty"`
	Region          string    `json:"region,omitempty"`
	KeyPrefix       string    `json:"key_prefix,omitempty"`
	KMSKeyID        string    `json:"kms_key_id,omitempty"`
	MaskedAccessKey string    `json:"masked_access_key,omitempty"`
	AccountID       string    `json:"account_id,omitempty"`
	PrincipalARN    string    `json:"principal_arn,omitempty"`
	UpdatedBy       string    `json:"updated_by,omitempty"`
	VerifiedAt      time.Time `json:"verified_at,omitempty"`
	UpdatedAt       time.Time `json:"updated_at,omitempty"`
}

type Runtime

type Runtime struct {
	Bucket, Region, KeyPrefix, KMSKeyID        string
	AccountID                                  string
	AccessKeyID, SecretAccessKey, SessionToken string
}

Runtime is intentionally never serialized or returned by the HTTP API.

type Service

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

func New

func New(config *appconfig.Config, store Store) (*Service, error)

func (*Service) Info

func (s *Service) Info(ctx context.Context) (PublicInfo, error)

func (*Service) Runtime

func (s *Service) Runtime(ctx context.Context) (Runtime, error)

func (*Service) SaveAndVerify

func (s *Service) SaveAndVerify(ctx context.Context, updatedBy string, input Input) (PublicInfo, error)

func (*Service) StateOutputs

func (s *Service) StateOutputs(ctx context.Context, project, target, stage string) (map[string]any, error)

StateOutputs reads the root module outputs directly from the centralized S3 state. Runtime Terraform backend files are deliberately removed after a job, so status and resource discovery must not depend on a local backend cache surviving the deployment process.

type Store

type Store interface {
	GetTerraformStateBackend(context.Context) (StoredConfig, error)
	SaveTerraformStateBackend(context.Context, StoredConfig) error
}

type StoredConfig

type StoredConfig struct {
	Enabled               bool
	Bucket                string
	Region                string
	KeyPrefix             string
	KMSKeyID              string
	AccessKeyID           string
	SecretAccessKeyCipher string
	SessionTokenCipher    string
	AccountID             string
	PrincipalARN          string
	PrincipalUserID       string
	UpdatedBy             string
	VerifiedAt, UpdatedAt time.Time
}

Jump to

Keyboard shortcuts

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