A Go module providing common AWS service utilities and convenience functions for building AWS-backed web APIs.
This module provides both high-level convenience functions and low-level utilities for working with AWS services used commonly in Go based Web APIs or at least the ones I make/have made.
go get github.com/94DanielBrown/awsappawsapp/
├── awsapp.go # High-level convenience functions
├── pkg/
│ ├── awsconfig/ # Shared AWS configuration
│ ├── dynamo/ # Low-level DynamoDB operations
│ └── s3/ # Low-level S3 operations
The root package provides opinionated, high-level functions that handle common initialization patterns:
import (
"context"
"github.com/94DanielBrown/awsapp"
)
func main() {
ctx := context.Background()
// Initialize a DynamoDB table (creates if doesn't exist)
client, message, err := awsapp.InitDynamo(ctx, "my-table")
if err != nil {
log.Fatal(err)
}
fmt.Println(message) // "table my-table created successfully"
}For more control, you can use the individual packages directly:
import (
"context"
"github.com/94DanielBrown/awsapp/pkg/dynamo"
"github.com/94DanielBrown/awsapp/pkg/awsconfig"
)
func main() {
ctx := context.Background()
// Connect to DynamoDB
client, err := dynamo.Connect()
if err != nil {
log.Fatal(err)
}
// Check if table exists
exists, err := dynamo.Exists(ctx, client, "my-table")
if err != nil {
log.Fatal(err)
}
// Create table with custom configuration
if !exists {
err = dynamo.Create(ctx, client, "my-table")
// Handle error...
}
}InitDynamo(ctx, tableName)- Initialize DynamoDB table (creates if doesn't exist)- Handles connection, existence check, and creation
- Includes 5-minute timeout for creation
- Returns client, status message, and error
Connect()- Create DynamoDB client using AWS credentials from environmentExists(ctx, client, tableName)- Check if a table existsCreate(ctx, client, tableName)- Create a new table- Additional CRUD operations (see package documentation)
- S3-specific operations (see package documentation)
- Shared AWS configuration utilities
- Credential management
- Region configuration
The module uses AWS credentials from environment variables. Ensure you have set:
export AWS_REGION=us-east-1
export AWS_ACCESS_KEY_ID=your-access-key
export AWS_SECRET_ACCESS_KEY=your-secret-keyOr use AWS IAM roles if running on EC2/ECS/Lambda.
Daniel Brown