A Go library for faking AWS over the network
Check out the example
Integration testing of applications that use AWS can be difficult. A test suite that interacts with a live AWS account will provide good test coverage, but may be slow and expensive.
An alternative is to create a test double or "fake" of the AWS APIs that your application uses. The fake boots an HTTP server that stands in for the real AWS endpoints, recording requests and providing arbitrary responses.
This package provides a generic HTTP handler that can form the front-end of a test double (mock, fake or stub) for an AWS API.
- Build a "backend" that implements the subset of the AWS API used by your code.
Each API call should be implemented as a backend method with a signature like
func (b *MyBackend) SomeAction(input *service.SomeActionInput) (*service.SomeActionOutput, error)
- During test setup, initialize an HTTP test server that wraps your backend
myBackend := &MyBackend{ ... }
fakeServer := httptest.NewServer(awsfaker.New(myBackend))
- In your tests, configure the client that you are testing to use your fake server instead of the real AWS
app := myapp.App{ AWSOverride: fakeServer.URL }
app.Run()
The method signatures expected on the backends match the patterns of aws-sdk-go. For example, a complete implementation of AWS CloudFormation would match the CloudFormationAPI interface
But your backend need only implement those methods used by your code under test.
-
ec2query:
ec2
-
query:
autoscaling
,cloudformation
,cloudsearch
,cloudwatch
,elasticache
,elasticbeanstalk
,elb
,iam
,rds
,redshift
,ses
,simpledb
,sns
,sqs
,sts
-
jsonrpc:
cloudhsm
,cloudtrail
,cloudwatchlogs
,codecommit
,codedeploy
,codepipeline
,cognitoidentity
,configservice
,datapipeline
,devicefarm
,directconnect
,directoryservice
,dynamodb
,dynamodbstreams
,ecs
,emr
,firehose
,inspector
,kinesis
,kms
,machinelearning
,marketplacecommerceanalytics
,opsworks
,route53domains
,ssm
,storagegateway
,support
,swf
,waf
,workspaces
-
restjson:
apigateway
,cloudsearchdomain
,cognitosync
,efs
,elasticsearchservice
,elastictranscoder
,glacier
,iot
,iotdataplane
,lambda
,mobileanalytics
-
restxml:
cloudfront
,route53
,s3