Auto-generated Go interfaces for every AWS SDK v2 service client. 413+ services. Updated weekly.
The AWS SDK for Go v2 ships concrete struct clients with no interfaces, making it painful to mock AWS services in unit tests. This is a long-standing community request with 100+ upvotes that AWS has not addressed.
// Your production code is tightly coupled to the concrete client
type S3Manager struct {
client *s3.Client // ← concrete type, can't substitute in tests
}
// Testing requires either:
// 1. Hitting real AWS (slow, expensive, flaky)
// 2. Wrapping every method yourself (tedious boilerplate)
// 3. Using something like localstack (heavy setup)import (
s3iface "github.com/nmccready/aws-sdk-go-v2-ifaces/service/s3/s3_iface"
)
// Your production code accepts the interface
type S3Manager struct {
client s3iface.IClient // ← interface, easily mockable
}
// The real s3.Client already satisfies this interface — zero changes needed
func NewS3Manager(client s3iface.IClient) *S3Manager {
return &S3Manager{client: client}
}# Import only the services you need
go get github.com/nmccready/aws-sdk-go-v2-ifaces/service/s3
go get github.com/nmccready/aws-sdk-go-v2-ifaces/service/dynamodb
go get github.com/nmccready/aws-sdk-go-v2-ifaces/service/sqsEach service provides a pre-generated testify/mock mock:
package mypackage_test
import (
"context"
"testing"
"github.com/aws/aws-sdk-go-v2/service/s3"
"github.com/nmccready/aws-sdk-go-v2-ifaces/service/s3/mocks"
"github.com/stretchr/testify/assert"
)
func TestUpload(t *testing.T) {
mockClient := &mocks.IClient{}
ctx := context.TODO()
// Set up expectations
input := &s3.PutObjectInput{Bucket: aws.String("my-bucket"), Key: aws.String("test.txt")}
output := &s3.PutObjectOutput{}
mockClient.On("PutObject", ctx, input).Return(output, nil)
// Use the mock in your code
manager := NewS3Manager(mockClient)
err := manager.Upload(ctx, "my-bucket", "test.txt", data)
assert.NoError(t, err)
mockClient.AssertExpectations(t)
}For each of the 413+ AWS services, this package generates:
| Path | Description |
|---|---|
service/<svc>/<svc>_iface/iface.go |
IClient interface matching every method on the SDK client |
service/<svc>/mocks/IClient.go |
Ready-to-use testify/mock implementation |
All 413+ services are supported — click to expand the full list
accessanalyzer · account · acm · acmpca · amplify · apigateway · apigatewayv2 · appconfig · appsync · athena · autoscaling · backup · batch · bedrock · bedrockruntime · cloudformation · cloudfront · cloudtrail · cloudwatch · cloudwatchlogs · codebuild · codedeploy · codepipeline · cognitoidentityprovider · comprehend · configservice · connect · costexplorer · databasemigrationservice · datazone · directconnect · dlm · docdb · dynamodb · dynamodbstreams · ebs · ec2 · ecr · ecrpublic · ecs · efs · eks · elasticache · elasticbeanstalk · elasticloadbalancingv2 · emr · emrserverless · eventbridge · firehose · fsx · glacier · glue · grafana · guardduty · health · iam · imagebuilder · inspector2 · iot · kafka · kinesis · kms · lakeformation · lambda · lightsail · location · mediaconvert · memorydb · mq · neptune · networkfirewall · opensearch · organizations · personalize · pi · pinpoint · polly · quicksight · ram · rds · redshift · rekognition · resiliencehub · resourcegroups · route53 · route53domains · route53resolver · s3 · s3control · sagemaker · secretsmanager · securityhub · ses · sesv2 · sfn · shield · sns · sqs · ssm · sso · ssoadmin · storagegateway · sts · support · textract · timestreaminfluxdb · transcribe · transfer · translate · wafv2 · wellarchitected · workspaces · xray ... and 300+ more
A weekly GitHub Actions workflow automatically:
- Clones the latest
aws-sdk-go-v2source - Regenerates all interfaces and mocks
- Opens a PR if anything changed
This means interfaces stay in sync with the latest SDK releases — no manual maintenance needed.
You absolutely can. But with 413 services and methods like S3 having 90+ operations, writing and maintaining interfaces by hand is a lot of boilerplate. This package auto-generates all of it.
Yes. The IClient interface is generated directly from the SDK client's method signatures. *s3.Client (and every other service client) satisfies its corresponding IClient interface with zero adapter code.
It's been requested since 2021 and has 100+ upvotes, but the AWS SDK team has not implemented it. This package fills that gap.
Interfaces are extracted from the SDK source via shell scripts, then mockery generates the testify/mock implementations.
Contributions are welcome! This project uses:
- Node.js for orchestration scripts
- Go 1.24+ for the generated code
- mockery for mock generation
# Install dependencies
npm install
# Regenerate all interfaces and mocks from latest SDK
npm run sync
# Run tests
npm testThe generation pipeline:
npm run syncclonesaws-sdk-go-v2to./tmp/- Scripts extract client method signatures for each service
- Interfaces are written to
service/<svc>/<svc>_iface/iface.go - Mockery generates mocks to
service/<svc>/mocks/IClient.go
If you find this project useful, consider sponsoring @nmccready to support ongoing maintenance and development. ❤️
See LICENSE for details.