Skip to content

This repository shows how to use server side encryption for AWS SQS + Lambda function using Erlang (with erlcloud)

License

Notifications You must be signed in to change notification settings

thiagoesteves/aws_sse_sqs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

AWS solution

This code is going to show how to implement and test the following AWS items:

  • How to use/configure server side encryption for AWS SQS;
  • How to produce and consume messages for AWS SQS using erlcloud
  • How to use Lambda Function to consume messages, including enable/diable on the fly;
  • How to create and delete aws stack using cloudformation files/templates.

Getting started

You need to clone the repository and download rebar/rebar3 (if it's not already available in your path).

git clone https://github.com/thiagoesteves/aws_sse_sqs.git
cd aws_sse_sqs

To compile and run

make

Security Credentials

you can provide them via erlcloud application environment variables at message.hrl file

%% AWS Credential definitions
-define(AWS_ACCESS_KEY_ID,     "XXXXXXXX").
-define(AWS_SECRET_ACCESS_KEY, "XXXXXXXX").
-define(AWS_REGION,            "XXXXXXXX").

CloudFormation file

you can find the template for the this project inside the folder aws. If you want to create/delete the stack by command line you can use the following commands:

1> message:create_stack().
ok
2> message:delete_stack().
ok

Project description

Proposed Exercise

The image above shows the example solution, where the AWS SQS is receiving the messages and encrypting it. Once the message is received, it can be redirect to the lambda function or to the Erlang code that is periodically checking the SQS Queue. The user can change the message destination using the following function:

1> message:config_lambda(true). % Enable lambda function destination (Default)

In order to send messages, you can use this API:

1> message:send("Hello World!").

To check that the message is being processed by lambda function, the user can have a look in the CloudWatch log: Proposed Exercise

The lambda function can be disabled and the message will be handled by the Erlang code:

1> message:config_lambda(false).

You must wait until the configuration is done, you can use the same command the check:

1> message:config_lambda(false).
{ok,already_disabled}

Now, you can send a message and check:

1> message:send("Hello World!").
ok
2> XXXXXXXXXXXXXXX debug: Message: "Hello World!"

About

This repository shows how to use server side encryption for AWS SQS + Lambda function using Erlang (with erlcloud)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published