Goaws - AWS (SQS/SNS) Clone for Development testing

GoAws

Build Status

You are always welcome to tweet me or buy me a coffee

Written in Go this is a clone of the AWS SQS/SNS systems. This system is designed to emulate SQS and SNS in a local environment so developers can test their interfaces without having to connect to the AWS Cloud and possibly incurring the expense, or even worse actually write to production topics/queues by mistake. If you see any problems or would like to see a new feature, please open an issue here in github. As well, I will logon to Gitter so we can discuss your deployment issues or the weather.

SNS/SQS Api status:

All SNS/SQS APIs have been implemented except:

  • The full capabilities for Get and Set QueueAttributes. At the moment you can only Get ALL the attributes.

Here is a list of the APIs:

  • ListQueues
  • CreateQueue
  • GetQueueAttributes (Always returns all attributes - unsupporterd arttributes are mocked)
  • GetQueueUrl
  • SendMessage
  • SendMessageBatch
  • ReceiveMessage
  • DeleteMessage
  • DeleteMessageBatch
  • PurgeQueue
  • Delete Queue
  • ChangeMessageVisibility
  • ChangeMessageVisibilityBatch
  • ListDeadLetterSourceQueues
  • ListQueueTags
  • RemovePermission
  • SetQueueAttributes (Only supported attributes are set - see Supported Queue Attributes)
  • TagQueue
  • UntagQueue

Supported Queue Attributes

  • VisibilityTimeout
  • ReceiveMessageWaitTimeSeconds
  • RedrivePolicy

Current SNS APIs implemented:

  • ListTopics
  • CreateTopic
  • Subscribe (raw)
  • ListSubscriptions
  • Publish
  • DeleteTopic
  • Subscribe
  • Unsubscribe
  • ListSubscriptionsByTopic
  • GetSubscriptionAttributes
  • SetSubscriptionAttributes (Only supported attributes are set - see Supported Subscription Attributes)

Supported Subscription Attributes

  • RawMessageDelivery
  • FilterPolicy (Only supported simplest "exact match" filter policy)

Yaml Configuration Implemented

  • Read config file
  • -config flag to read a specific configuration file (e.g.: -config=myconfig.yaml)
  • a command line argument to determine the environment to use in the config file (e.e.: Dev)
  • IN the config file you can create Queues, Topic and Subscription see the example config file in the conf directory

Debug logging can be turned on via a command line flag (e.g.: -debug)

Note: The system does not authenticate or presently use https

Installation

go get github.com/p4tin/goaws/...

Build and Run (Standalone)

Build
    cd to GoAws directory
    go build -o goaws app/cmd/goaws.go  (The goaws executable should be in the currect directory, move it somewhere in your $PATH)

Run
    ./goaws  (by default goaws listens on port 4100 but you can change it in the goaws.yaml file to another port of your choice)

Run (Docker Version)

Get it
    docker pull pafortin/goaws

run
    docker run -d --name goaws -p 4100:4100 pafortin/goaws

Testing your installation

You can test that your installation is working correctly in one of two ways:

  1. Usign the postman collection, use this link to import it. As well the Environment variable for the collection should be set as follows: URL = http://localhost:4100/.

  2. by using the AWS cli tools (download link) here are some samples, you can refer to the aws cli tools docs for further information.

{
    "QueueUrl": "http://localhost:4100/test1"
}
{
    "QueueUrls": [
        "http://localhost:4100/test1"
    ]
}
{
    "MD5OfMessageBody": "9d3f5eaac3b1b4dd509f39e71e25f954",
    "MD5OfMessageAttributes": "b095c6d16871105acb75d59332513337",
    "MessageId": "66a1b4f5-cecf-473e-92b6-810156d41bbe"
}
{
    "Messages": [
        {
            "Body": "this is a test of the GoAws Queue messaging",
            "MD5OfMessageAttributes": "b095c6d16871105acb75d59332513337",
            "ReceiptHandle": "66a1b4f5-cecf-473e-92b6-810156d41bbe#f1fc455c-698e-442e-9747-f415bee5b461",
            "MD5OfBody": "9d3f5eaac3b1b4dd509f39e71e25f954",
            "MessageId": "66a1b4f5-cecf-473e-92b6-810156d41bbe"
        }
    ]
}
No output
No output (No messages in Q)
No output
No output (There are no Queues left)
{
    "Topics": [
        {
            "TopicArn": "arn:aws:sns:local:000000000000:topic1"
        },
        {
            "TopicArn": "arn:aws:sns:local:000000000000:topic2"
        }
    ]
}
Owner
Comments
  • Upgrading from 1.0.3 to 1.1.1 results in http 301 error

    Upgrading from 1.0.3 to 1.1.1 results in http 301 error

    We've been using the latest docker image, which was 1.0.3 until 4 days ago. Our CI build started failing when the latest image changed.

    https://travis-ci.org/square/misk/builds/473409993

        com.amazonaws.services.sqs.model.AmazonSQSException: null (Service: AmazonSQS; Status Code: 301; Error Code: 301 Moved Permanently; Request ID: null)
            at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleErrorResponse(AmazonHttpClient.java:1588)
            at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeOneRequest(AmazonHttpClient.java:1258)
            at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1030)
            at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:742)
            at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:716)
            at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:699)
            at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$500(AmazonHttpClient.java:667)
            at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:649)
            at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:513)
            at com.amazonaws.services.sqs.AmazonSQSClient.doInvoke(AmazonSQSClient.java:1740)
            at com.amazonaws.services.sqs.AmazonSQSClient.invoke(AmazonSQSClient.java:1716)
            at com.amazonaws.services.sqs.AmazonSQSClient.executeSendMessage(AmazonSQSClient.java:1503)
            at com.amazonaws.services.sqs.AmazonSQSClient.sendMessage(AmazonSQSClient.java:1480)
            at misk.jobqueue.sqs.SqsJobQueue$enqueue$1.invoke(SqsJobQueue.kt:31)
    

    Any ideas what might have broken this? Going to start digging into what changed in the latest release.

  • Cannot retreive MessageAttributes from Message

    Cannot retreive MessageAttributes from Message

    I'm working with a very small code to publish and receive events. I'm adding MessageAttributes in the publisher side but I'm not receiving anything on the consumer side.

    I'm working with python3.7 and boto3 and the same code works perfectly with the real AWS SNS/SQS.

    I don't know if it's necessary to add code since it's pretty basic and simple: boto3.client('sns', **aws_settings).publish(arn, message, MessageAttributes={'foo': 'bar'})

    Any thoughts?

  • removed sqs. from hostname

    removed sqs. from hostname

    With the current implementation, the url (assuming host in the config is goaws) will return sqs.goaws. If the user is running goaws in docker and leveraging container name for networking the current implantation won't work.

  • Cannot start Docker container on Linux

    Cannot start Docker container on Linux

    I'm trying to run the goaws container (version: latest) on an EC2 instance like this:

    docker run --rm -it -p 4100:4100 --name sqs -v $PWD/goaws.yml:/goaws.yml pafortin/goaws -config /goaws.yml
    

    And I get the following error message:

    standard_init_linux.go:185: exec user process caused "exec format error"
    
  • Incompatible with Node js aws-sdk

    Incompatible with Node js aws-sdk

    Hi! This is less of an issue with goaws and more of an issue with the Node.js aws-sdk. I am able to setup goaws correctly and pass all of the tests from the aws cli, however when using the local SNS ARN, I am receiving the following error:

    Invalid parameter: TopicArn Reason: A local ARN must begin with arn:null, not arn:aws:sns:local:000000000000:topic1

    My code is simple

    AWS.config.update({
        region: 'us-west-1'
    });
    var sns = new AWS.SNS();
    var params = {
        Message: 'some text'
        TopicArn: 'arn:aws:sns:local:000000000000:topic1
    }; 
    sns.publish(params)
    

    I am wondering if anyone has run into this issue before?!

  • As a GoAWS Docker user, I would like to pass AWS related information as parameter so I can use GoAWS together with other local AWS services, such as Local DynamoDB

    As a GoAWS Docker user, I would like to pass AWS related information as parameter so I can use GoAWS together with other local AWS services, such as Local DynamoDB

    I'm currently using a local DynamoDB Docker which supports the parameters below and as many of us do use SNS/SQS within other AWS services, would be nice to have these options so we could use GoAWS with other AWS local services.

    -e AWS_ACCESS_KEY_ID=key -e AWS_SECRET_ACCESS_KEY=secret aws --region us-east-1 dynamodb --endpoint http://localhost:8000/

  • Implement SNS message publish over http

    Implement SNS message publish over http

    https://github.com/p4tin/goaws/blob/master/gosns/gosns.go#L276

    Currently messages only published to SQS queues. Would be a lot more useful if there would be an ability to post messages to http endpoint.

  • QueueUrl >> make configurable

    QueueUrl >> make configurable

    I'm integrating the docker image into a docker-compose environment. I'm having trouble as SQS queues coming back from getqueueurl are all pointing to localhost, which is not correct in this environment and won't work as obviously my application is running on a different container.

  • Persisting data

    Persisting data

    Please excuse me if this has been discussed before, but I could not find anything related. Are there any plans to make data persistent when running the docker version?

    Maybe a -snapshot path/to/file.json param, this can be used to specify queue messages must be serialized to disk when the container is stopped, and it can be used for initialization when it is started?

  • Resolving deadlock issue with `WaitTimeSeconds` parameter

    Resolving deadlock issue with `WaitTimeSeconds` parameter

    The function numberOfHiddenMessageInQueue also tries to acquire a lock with app.SyncQueues.Lock(), thus using the WaitTimeSeconds immediately causes deadlock as it tries to acquire the lock twice. This attempts to resolve this issue.

  • FIFO Support

    FIFO Support

    This is backward compatible PR to support FIFO queues. If queue name has .fifo suffix it will be treated as FIFO.

    • receive a message from the same groupId will lock it and won't allow other consumers to receive it
    • visibility timeout and removing message will unlock group
  • Bump github.com/aws/aws-sdk-go from 1.12.39 to 1.33.0

    Bump github.com/aws/aws-sdk-go from 1.12.39 to 1.33.0

    Bumps github.com/aws/aws-sdk-go from 1.12.39 to 1.33.0.

    Changelog

    Sourced from github.com/aws/aws-sdk-go's changelog.

    Release v1.33.0 (2020-07-01)

    Service Client Updates

    • service/appsync: Updates service API and documentation
    • service/chime: Updates service API and documentation
      • This release supports third party emergency call routing configuration for Amazon Chime Voice Connectors.
    • service/codebuild: Updates service API and documentation
      • Support build status config in project source
    • service/imagebuilder: Updates service API and documentation
    • service/rds: Updates service API
      • This release adds the exceptions KMSKeyNotAccessibleFault and InvalidDBClusterStateFault to the Amazon RDS ModifyDBInstance API.
    • service/securityhub: Updates service API and documentation

    SDK Features

    • service/s3/s3crypto: Introduces EncryptionClientV2 and DecryptionClientV2 encryption and decryption clients which support a new key wrapping algorithm kms+context. (#3403)
      • DecryptionClientV2 maintains the ability to decrypt objects encrypted using the EncryptionClient.
      • Please see s3crypto documentation for migration details.

    Release v1.32.13 (2020-06-30)

    Service Client Updates

    • service/codeguru-reviewer: Updates service API and documentation
    • service/comprehendmedical: Updates service API
    • service/ec2: Updates service API and documentation
      • Added support for tag-on-create for CreateVpc, CreateEgressOnlyInternetGateway, CreateSecurityGroup, CreateSubnet, CreateNetworkInterface, CreateNetworkAcl, CreateDhcpOptions and CreateInternetGateway. You can now specify tags when creating any of these resources. For more information about tagging, see AWS Tagging Strategies.
    • service/ecr: Updates service API and documentation
      • Add a new parameter (ImageDigest) and a new exception (ImageDigestDoesNotMatchException) to PutImage API to support pushing image by digest.
    • service/rds: Updates service documentation
      • Documentation updates for rds

    Release v1.32.12 (2020-06-29)

    Service Client Updates

    • service/autoscaling: Updates service documentation and examples
      • Documentation updates for Amazon EC2 Auto Scaling.
    • service/codeguruprofiler: Updates service API, documentation, and paginators
    • service/codestar-connections: Updates service API, documentation, and paginators
    • service/ec2: Updates service API, documentation, and paginators
      • Virtual Private Cloud (VPC) customers can now create and manage their own Prefix Lists to simplify VPC configurations.

    Release v1.32.11 (2020-06-26)

    Service Client Updates

    • service/cloudformation: Updates service API and documentation
      • ListStackInstances and DescribeStackInstance now return a new StackInstanceStatus object that contains DetailedStatus values: a disambiguation of the more generic Status value. ListStackInstances output can now be filtered on DetailedStatus using the new Filters parameter.
    • service/cognito-idp: Updates service API

    ... (truncated)

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

  • fatal error: concurrent map read and map write

    fatal error: concurrent map read and map write

    We use goaws v0.3.1 within a testing framework that creates hundreds of topics and sqs subscriptions to replicate messaging infrastructure we use in production. Today I saw a failure of this setup with the error:

    fatal error: concurrent map read and map write
    

    Full output below - topic and queue names redacted goaws-panic.log

  • Update permissible SNS endpoint call response codes

    Update permissible SNS endpoint call response codes

    https://docs.aws.amazon.com/sns/latest/dg/SendMessageToHttp.prepare.html

    When an SNS subscription calls its endpoint, Amazon recognizes responses in the range of 200-499 as successful Notification deliveries. Responses outside of that range will trigger the Subscription's retry policy.

    This PR updates the callEndpoint method to allow this range instead of just response codes divisible by 200.

  • fix incorrect data type value of message attribute.

    fix incorrect data type value of message attribute.

    When I published sns message with message attribute, DataType sould be String but StringValue is returned.

    $ aws --endpoint-url http://127.0.0.1:4100 sns publish --message test --topic-arn arn:aws:sns:us-east-1:100010001000:local-topic1 --message-attributes '{"test":{"DataType": "String", "StringValue": "test!"}}'
    
    $ aws --endpoint-url http://127.0.0.1:4100 sqs receive-message --queue-url http://us-east-1.goaws.com:4100/100010001000/local-queue3
    {
        "Messages": [
            {
                "MessageId": "fb8a8253-36c6-4a4d-96be-e005f41240a5",
                "ReceiptHandle": "fb8a8253-36c6-4a4d-96be-e005f41240a5#1cce6f07-2ffa-4709-97bb-f8dff7584e52",
                "MD5OfBody": "99a983d00399afc3712ae7d82d13ca86",
                "Body": "{\"Type\":\"Notification\",\"Token\":\"\",\"MessageId\":\"b6cab133-ed2e-44e1-82fd-137e77aeaa7e\",\"TopicArn\":\"arn:aws:sns:us-east-1:100010001000:local-topic1\",\"Subject\":\"\",\"Message\":\"test\",\"Timestamp\":\"2022-02-25T06:02:21Z\",\"SignatureVersion\":\"1\",\"Signature\":\"HCOsu0ZkzgcXIbXdbTRpRY66JqP7haOe5QQjJ8xWROAPkRf7Hul8XlC5knwoAfaeEJ5jfR2rHalGiZm9zP9c50eq/zc2Sp9r0GcJBw/L+oKKmkEQ5p+guXG0nHMIFQPoUHwxQVnVfQV0T+mg+t3Q5k7FprHjgL2aI6QV57DSyRO1cpl9JwaR2INTDVoeRzs0xH6DWj8x6G4lZ5omyd/qUM1WEolDjOr+26wBwmkmoxVwGL1CQmdpHFTsp/tSrr/nn0DBp+zEHf19HGdal0ee9979XibwCzxzR2zUaEmonYctvkWdgzc//JroWkaFwvdrz64pIAfA7X3deNP2iCU9mA==\",\"SigningCertURL\":\"http://goaws.com:4100/SimpleNotificationService/b6cab133-ed2e-44e1-82fd-137e77aeaa7e.pem\",\"UnsubscribeURL\":\"http://goaws.com:4100/?Action=Unsubscribe\\u0026SubscriptionArn=arn:aws:sns:us-east-1:100010001000:local-topic1:489ddf06-1d3e-4e08-b3a3-be1dfc61e86f\",\"SubscribeURL\":\"\",\"MessageAttributes\":{\"test\":{\"Type\":\"StringValue\",\"Value\":\"test!\"}}}",
                "Attributes": {
                    "SenderId": "100010001000",
                    "ApproximateReceiveCount": "1",
                    "SentTimestamp": "1645769010434",
                    "ApproximateFirstReceiveTimestamp": "1645769007313"
                }
            }
        ]
    }
    
  • app/gosqs: increment number of receives for a message

    app/gosqs: increment number of receives for a message

    When returning an SQS message, increment the 'NumberOfReceives' so it always contains the number of times a message has been received but not yet deleted.

    From the AWS SQS docs:

    ApproximateReceiveCount – Returns the number of times a message has been received across all queues but not deleted.
    
Client-server-golang-sqs - Client Server with SQS and golang

Client Server with SQS and golang Multi-threaded client-server demo with Go What

Feb 14, 2022
Use AWS SQS as a clipboard to copy and paste across different systems and platforms

sqs_clipboard Use AWS SQS as a clipboard to copy and paste across different systems and platforms. Clipboard contents are encrypted in transit and at

Oct 16, 2022
Reddit-clone-go - Reddit clone with golang

Generate GraphQL Schema go get github.com/99designs/gqlgen/[email protected] go run gi

Dec 28, 2022
Foundational systems for gitops-style AWS development workflows

aws-basics Foundational systems for gitops-style AWS development workflows. Prerequisites GitHub and AWS accounts Terraform Golang Bootstrapping Setup

Oct 28, 2021
Simple no frills AWS S3 Golang Library using REST with V4 Signing (without AWS Go SDK)

simples3 : Simple no frills AWS S3 Library using REST with V4 Signing Overview SimpleS3 is a golang library for uploading and deleting objects on S3 b

Nov 4, 2022
Integrate AWS EKS Anywhere cluster with AWS Services
 Integrate AWS EKS Anywhere cluster with AWS Services

This article provides step-by-step instruction on integrating AWS EKS Anywhere with AWS Services so the applications running on customer data center can securely connect with these services.

Mar 6, 2022
AWS credential_process utility to assume AWS IAM Roles with Yubikey Touch and Authenticator App TOPT MFA to provide temporary session credentials; With encrypted caching and support for automatic credential refresh.
AWS credential_process utility to assume AWS IAM Roles with Yubikey Touch and Authenticator App TOPT MFA to provide temporary session credentials; With encrypted caching and support for automatic credential refresh.

AWS credential_process utility to assume AWS IAM Roles with Yubikey Touch and Authenticator App TOPT MFA to provide temporary session credentials; With encrypted caching and support for automatic credential refresh.

Dec 20, 2022
A package for access aws service using AWS SDK for Golang

goaws ?? A package for access aws service using AWS SDK for Golang Advantage with goaws package Example for get user list IAM with AWS SDK for Golang

Nov 25, 2021
Simple CRUD API written in Go, built using AWS SAM tool and using the AWS' infrastructure.
Simple CRUD API written in Go, built using AWS SAM tool and using the AWS' infrastructure.

tutor-pet API Simple CRUD API written in Go, built using AWS SAM tool and using the AWS' infrastructure. Macro architecture: Code architecture: Pre-Re

Aug 17, 2022
Aws-parameter-bulk - Export AWS SSM Parameter Store values in bulk to .env files

aws-parameter-bulk Utility to read parameters from AWS Systems Manager (SSM) Par

Oct 18, 2022
Feb 7, 2022
Aws-cognito-demo-go - Source code for AWS Cognito in Go

AWS Cognito Demo in Go Source code for YouTube series, AWS Cognito in Go - https

Dec 10, 2022
Una prueba técnica: Servicio Golang REST API local, sobre Docker, gRPC, AWS Serverless y sobre Kubernetes en AWS EC2

Una prueba técnica: Servicio Golang REST API local, sobre Docker, gRPC, AWS Serverless y sobre Kubernetes en AWS EC2

May 7, 2022
Aws-cdk-go-examples - Example projects using the AWS CDK by Golang

aws-cdk-go-examples Example projects using the AWS CDK by Golang Useful commands

Nov 24, 2022
twitter clone front-end for Internet Engineering course - fall 99 built by go+echo

twitter backend build twitter-like back-end for internet engeering course - fall 99 with go+echo+gorm team mates Roozbeh Sharifnasab + Parsa Fadaee +

Nov 9, 2022
My Simple Instagram-Clone API task submission, conducted by Appointy for internship shortlisting.

go-pointy Go-Pointy is a simple Instagram API Clone, made using GoLang. I had tried my best to not be lazy and finish the tasks, as a beginner to the

Jul 25, 2022
Instagram clone as Appointy task
Instagram clone as Appointy task

Instagram Backend Clone Task for Appointy Internship 2021 Explore the docs » View Demo · Report Bug · Request Feature Table of Contents About the Proj

Oct 11, 2021
A REST API microservices-based Twitter Clone server.

Simple API Twitter Clone A REST API microservices-based project to fetch, edit, post, and delete tweets. API documentation The API documentation is bu

May 13, 2022
A SDK development package developed in go language and connected to dechain

Platform introduction Dechain go SDK is a SDK development package developed in go language and connected to dechain. This SDK can be provided to go cl

Dec 14, 2021