Documentation
¶
Overview ¶
Package localstack provides LocalStack integration for offline AWS testing
Index ¶
- Constants
- Variables
- func GetEndpoint() string
- func GetServiceStatus(ctx context.Context) (map[string]string, error)
- func HasEFSSupport() bool
- func IsHealthy(ctx context.Context) bool
- func IsLocalStackEnabled() bool
- func NewAWSConfig(ctx context.Context) (aws.Config, error)
- func NewAWSConfigWithProfile(ctx context.Context, profile, region string) (aws.Config, error)
- func ResetLocalStack(ctx context.Context) error
- func VerifyRequiredServices(ctx context.Context) error
- func WaitForReady(ctx context.Context, timeout time.Duration) error
- type Config
Constants ¶
const ( // LocalStackEndpoint is the default LocalStack gateway endpoint LocalStackEndpoint = "http://localhost:4566" // LocalStackRegion is the default region for LocalStack testing LocalStackRegion = "us-west-2" // LocalStackAccessKey is the dummy access key for LocalStack LocalStackAccessKey = "test" // LocalStackSecretKey is the dummy secret key for LocalStack LocalStackSecretKey = "test" // EnvVarEnabled is the environment variable to enable LocalStack mode EnvVarEnabled = "PRISM_USE_LOCALSTACK" // EnvVarEndpoint allows overriding the LocalStack endpoint EnvVarEndpoint = "LOCALSTACK_ENDPOINT" // ConfigFilePath is the path to LocalStack resource configuration ConfigFilePath = "/tmp/prism-localstack-config.json" )
LocalStack configuration constants
Variables ¶
var RequiredServices = []string{
"ec2",
"s3",
"ssm",
"iam",
"sts",
}
RequiredServices lists the AWS services that Prism requires in LocalStack Community. EFS is intentionally excluded: it requires LocalStack Pro (paid). Use HasEFSSupport() to determine whether EFS tests should run.
Functions ¶
func GetEndpoint ¶
func GetEndpoint() string
GetEndpoint returns the LocalStack endpoint to use Checks LOCALSTACK_ENDPOINT environment variable, falls back to default
func GetServiceStatus ¶
GetServiceStatus returns the status of LocalStack services Returns a map of service names to their status ("available", "starting", "error", etc.)
func HasEFSSupport ¶ added in v0.7.7
func HasEFSSupport() bool
HasEFSSupport returns true if EFS is available in the current environment. Real AWS always supports EFS. LocalStack Community does not include EFS; set LOCALSTACK_EFS_SUPPORT=true to enable when using LocalStack Pro.
func IsLocalStackEnabled ¶
func IsLocalStackEnabled() bool
IsLocalStackEnabled returns true if LocalStack mode is enabled via environment variable
func NewAWSConfig ¶
NewAWSConfig creates an AWS configuration for LocalStack This configures the AWS SDK to use LocalStack endpoints and credentials
func NewAWSConfigWithProfile ¶
NewAWSConfigWithProfile creates an AWS configuration with custom profile/region support This is used by the Manager when profile options are provided
func ResetLocalStack ¶
ResetLocalStack resets LocalStack state (requires LocalStack Pro for full reset) This is a best-effort operation for the free version
func VerifyRequiredServices ¶
VerifyRequiredServices checks that all required services are available in LocalStack
Types ¶
type Config ¶
type Config struct {
VPCID string `json:"vpc_id"`
InternetGatewayID string `json:"internet_gateway_id"`
SubnetIDs []string `json:"subnet_ids"`
SecurityGroupID string `json:"security_group_id"`
AMIIDs map[string]string `json:"ami_ids"`
KeyPair string `json:"key_pair"`
EFSFileSystemID string `json:"efs_file_system_id,omitempty"`
EFSMountTargetIDs []string `json:"efs_mount_target_ids,omitempty"`
}
Config holds LocalStack-specific resource configuration This is generated by the initialization scripts when LocalStack starts
func LoadConfig ¶
LoadConfig loads LocalStack resource configuration from the config file This file is created by the initialization scripts and contains VPC IDs, AMI IDs, etc.
func (*Config) GetAMI ¶
GetAMI returns the LocalStack AMI ID for a given OS distribution and architecture Example: GetAMI("ubuntu-22.04-x86_64") returns the mock Ubuntu 22.04 x86_64 AMI
func (*Config) GetDefaultSubnetID ¶
GetDefaultSubnetID returns the first available subnet ID This is useful for tests that don't care about specific subnet selection