Skip to content

saka2jp/aws-fanout-pattern

Repository files navigation

aws-fanout-pattern

Description

aws-fanout-pattern is a sample implementation of a Fanout Pattern of a cloud design pattern

sequence

Production

prerequisites

You have to prepare credentials with proper policies.

And,

  • install aws-cli
  • install aws-sam-cli. Docker is also required. Follow the instruction here.
  • install direnv
  • install saw
    • you can watch CloudWatch logs on your terminal
  • set environment variables to .envrc.sample and remove .sample.
    • WEBHOOK_URL Incoming Webhook URL of Slack. You can get URL at this page.
    • CHANNEL where the Lambda③'ll post message in Slack
    • USER_NAME by whom the message is posted in Slack
    • ICON message sender's icon like :piggy:
    • FILE_BUCKET S3 bucket where you upload your file. It's S3 in sequence and hould be unique globally.
    • STACK_BUCKET is S3 bucket name for artifacts of SAM and should be unique globally.

deploy

$ dep ensure                       # to resolve dependency
$ aws s3 mb "s3://${STACK_BUCKET}" # for artifacts of SAM
$ make deploy

Now, you can check a behavior of this architecture by uploading file to S3.

$ saw groups
/aws/lambda/stack-s3-sns-sqs-lambda-slack-go-sa-WriteExtLambda-XXXXXXXXXXXX
/aws/lambda/stack-s3-sns-sqs-lambda-slack-WriteFileNameLambda-XXXXXXXXXXXX
/aws/lambda/stack-s3-sns-sqs-lambda-slack-go-sa-NotifierLambda-XXXXXXXXXXXX

$ saw watch /aws/lambda/stack-s3-sns-sqs-lambda-slack-go-sa-WriteExtLambda-XXXXXXXXXXXX &
$ saw watch /aws/lambda/stack-s3-sns-sqs-lambda-slack-WriteFileNameLambda-XXXXXXXXXXXX &
$ saw watch /aws/lambda/stack-s3-sns-sqs-lambda-slack-go-sa-NotifierLambda-XXXXXXXXXXXX &

# open another window
$ aws s3 cp ./README.md "s3://${FILE_BUCKET}"

delete

In this architecture, Lambdas execute long polling to SQS and it's billable. So you should delete your stack by executing the command below after trying deploy.

$ make delete

Articles (Japanese)

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks