aws

package module
v0.32.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package aws provides initialized AWS service clients (S3, SQS, DynamoDB), wired into the host as a module that reads the aws config section.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Module added in v0.19.0

func Module(services ...Service) host.Module

Module installs an AWS client as a managed service. The host loads its config (via the client's Configurable implementation) and initializes the requested service clients during the init phase:

host.MustNew().
    WithModule(aws.Module(aws.S3, aws.SQS)).
    MustRun()

Reach the client from a Setup hook or handler with aws.Of(app).

func NamedModule added in v0.19.0

func NamedModule(name string, services ...Service) host.Module

NamedModule installs an AWS client under name, so several clients can coexist (retrieved with aws.Of(app, name)). Because Module already uses a variadic service list, naming gets its own constructor.

Types

type AWS

type AWS struct {
	DefaultConfig       awssdk.Config
	DefaultS3BucketName *string
	DefaultSQSQueueURL  *string
	Logger              *slog.Logger

	S3Client       *s3.Client
	SQSClient      *sqs.Client
	DynamoDBClient *dynamodb.Client
	// contains filtered or unexported fields
}

func Lookup added in v0.23.0

func Lookup(app *host.App, name ...string) (*AWS, bool)

Lookup returns the AWS client installed under the optional name and whether one was installed. Use it where absence is an expected, recoverable condition; prefer Of when the client must exist.

func NewAWS added in v0.4.0

func NewAWS(logger *slog.Logger, services ...Service) *AWS

NewAWS returns an AWS client ready to participate in the host service lifecycle. services lists which SDK clients (S3, SQS, DynamoDB) to initialize on Init.

func Of added in v0.19.0

func Of(app *host.App, name ...string) *AWS

Of returns the AWS client installed by Module/NamedModule under the optional name, panicking if none was installed.

func (*AWS) Init added in v0.4.0

func (a *AWS) Init() error

Init implements core.Initer, building the AWS SDK config from the loaded credentials and region, then initializing the requested service clients.

func (*AWS) ReadConfig added in v0.11.0

func (a *AWS) ReadConfig(l configx.Reader) error

ReadConfig implements configx.Configurable, reading the aws section into the AWS client's own config field.

func (*AWS) S3DownloadFile

func (a *AWS) S3DownloadFile(ctx context.Context, req *S3DownloadFileRequest) error

func (*AWS) S3DownloadFiles

func (a *AWS) S3DownloadFiles(ctx context.Context, reqs []S3DownloadFileRequest, maxWorkers int) error

func (*AWS) S3UploadFile

func (a *AWS) S3UploadFile(ctx context.Context, req *S3UploadFileRequest) error

func (*AWS) SQSSendMessage

func (a *AWS) SQSSendMessage(ctx context.Context, message any) error

type Config

type Config struct {
	AccessKey           string  `mapstructure:"accessKey"`
	SecretKey           string  `mapstructure:"secretKey"`
	Region              string  `mapstructure:"region"`
	EndpointURL         *string `mapstructure:"endpointURL"`
	S3BucketName        *string `mapstructure:"s3BucketName"`
	SQSQueueURL         *string `mapstructure:"sqsQueueURL"`
	DynamoDBEndpointURL *string `mapstructure:"dynamoDBEndpointURL"`
}

Config is MicroJet's AWS configuration, read from the aws section of the application config (with APP_AWS_* environment overrides). It lives in the aws module rather than in core so the core module stays vendor-neutral.

type S3DownloadFileRequest

type S3DownloadFileRequest struct {
	BucketName    string
	ObjectKey     string
	LocalFilePath string
}

type S3UploadFileRequest

type S3UploadFileRequest struct {
	BucketName    string
	ObjectKey     string
	ContentType   string
	Headers       map[string]string
	LocalFilePath string
}

type Service added in v0.6.0

type Service string
const (
	S3       Service = "aws-s3"
	SQS      Service = "aws-sqs"
	DynamoDB Service = "aws-dynamodb"
)

Directories

Path Synopsis
Package dynamo provides a generic, tag-driven DynamoDB table accessor.
Package dynamo provides a generic, tag-driven DynamoDB table accessor.

Jump to

Keyboard shortcuts

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