SQS + Lambda를 활용한 문자 메시지 및 이메일, Voice call 호출을 간단하게 구현하는 serverless 템플릿

Overview

AWS SQS With Lambda

notification 서버 구축을 위한 Poc

TODO

  1. serverless를 통해 sqs 관련 리소스(람다, sqs) 배포 가능한 템플릿 작성 및 배포
  2. poc차원에서 간단한 rest api 호출을 통한 sqs fifo 큐에 메시지 넣기
  3. sqs는 대기열 큐에 있는 메시지를 람다로 전송
  4. 람다는 다음과 같은 람다를 작성
    1. 문자 메시지 전송 람다
    2. 이메일 전송 람다
    3. 소셜 계정 서비스 람다
    4. 전화 보이스콜 람다

설계 고려 사항

  • 여러 람다가 추가될 수 있음을 고려
  • 콘텐츠 기반 중복 제거를 통해(fifo 큐 및 message group id 혹은 duplicated message id 등 ) 중복된 메시지를 람다에 전달하지 않도록 강제
    • 위 기능은 5분의 인터벌 동안 동일한 메시지가 들어오면 모두 제거합니다.

아키텍쳐

Servelress 템플릿

service: sqs-poc

provider:
  name: aws
  runtime: python3.7
  stage: dev
  iamRoleStatements:
    - Effect: "Allow"
      Action:
        - "logs:*"
        - "sqs:*"
        - "lambda:*"
        - "sns:*"
      Resource: "*"
  environment:
    QUEUE_URL: !Ref PocQueue
    QUEUE_NAME: { Fn::GetAtt: [PocQueue, QueueName] }

functions:
  producer:
    handler: producer.handler
    events:
      - http:
          method: post
          path: send
  consumer:
    handler: consumer.handler
    events:
      - sqs:
          arn: { Fn::GetAtt: [PocQueue, Arn] }

resources:
  Resources:
    PocQueue:
      Type: "AWS::SQS::Queue"
      Properties:
        QueueName: "PocQueue.fifo"
        FifoQueue: "true"
        ContentBasedDeduplication: "true"
  Outputs:
    pocQueueArn:
      Value: { Fn::GetAtt: [PocQueue, Arn] }
      Export:
        Name: pocQueueArn
    pocQueueName:
      Value: { Fn::GetAtt: [PocQueue, QueueName] }
      Export:
        Name: pocQueueName
    pocQueueUrl:
      Value: !Ref PocQueue
      Export:
        Name: PocQueueUrl

테스트 방법

git clone https://github.com/kimsehwan96/aws-sqs-with-serverless.git

cd aws-sqs-with-serverless notifications.py 파일의 다음 내용 수정

import boto3
import json
from notification_base import BaseNotification


class SMS(BaseNotification):
    def __init__(self, message):
        super().__init__()
        self.message = message
        print('this is sending message :', self.message)
        self.client = boto3.client('sns', region_name='ap-northeast-1')

    def send(self):
        res = self.client.publish(
            PhoneNumber="+8201042707227",
            Message=str(self.message)
        )
        return json.dumps(res)

PhoneNumber 부분을 자신의 전화번호로 수정

sls deploy --stage dev --region ap-northeast-2

위 명령어를 통해 배포

이후 생성된 API Gateway 엔드포인트로 Post 메서드를 이용, Body에 Rawmessage로 문자열을 입력하고 전송하면 문자메시지 전달 받음. 중복된 컨텐츠는 전달 받지 않음

Owner
김세환
🐛
김세환
PRAW, an acronym for "Python Reddit API Wrapper", is a python package that allows for simple access to Reddit's API.

PRAW: The Python Reddit API Wrapper PRAW, an acronym for "Python Reddit API Wrapper", is a Python package that allows for simple access to Reddit's AP

Python Reddit API Wrapper Development 3k Dec 29, 2022
Updated version of A discord token/password grabber thats grabs all of their tokens, passwords, credit card + alot more

Updated version of A discord token/password grabber thats grabs all of their tokens, passwords, credit card + alot more

Rdimo 556 Aug 05, 2022
A Python wrapper for the Yelp API v2

python-yelp-v2 A Python wrapper for the Yelp API v2. The structure for this was inspired by the python-twitter library, and some internal methods are

Matthew Conlen 12 Oct 24, 2017
Shiny Wechat Pay SDK for Python

WeChat third-party Python SDK master: Read the Documentation Features Common public platforms passively respond and actively call APIs WeChat Pay API

Obrisk 18 Sep 05, 2022
A wrapper for aqquiring Choice Coin directly through a Python Terminal. Leverages the TinyMan Python-SDK.

CHOICE_TinyMan_Wrapper A wrapper that allows users to acquire Choice Coin directly through their Terminal using ALGO and various Algorand Standard Ass

Choice Coin 16 Sep 24, 2022
Telegram Reporter

[Telegram Reporter v.3 ] 🇮🇷 AliCybeRR 🇮🇷 [ AliCybeRR.Reporter feature ] Login Your Telegram account 👽 support Termux ❕ No Limits ⚡ Secure 🔐 Free

AliCybeRR 1 Jun 08, 2022
Yes, it's true :revolving_hearts: This repository has 301 stars.

Yes, it's true! Inspired by a similar repository from @RealPeha, but implemented using a webhook on AWS Lambda and API Gateway, so it's serv

510 Dec 28, 2022
DeFi wallet on Chia Network.

DeFi wallet on Chia Network.

GobyWallet 21 Aug 12, 2022
Userbot untuk memutar video dan lagu di vcg/os

Userbot untuk memutar video dan lagu di vcg/os

FJ_GAMING 2 Nov 13, 2021
A Tool to scrape URLs for a given domain from wayback machine, Commoncrawl and OTX Alienvault

Mr_URL Mr.URL fetches known URLs for a given domain from Wayback Machine, Commoncrawl and OTX Alienvault. It also finds old versions of any given URL

Stinger 9 Sep 05, 2022
A course on getting started with the Twitter API v2 for academic research

Getting started with the Twitter API v2 for academic research Welcome to this '101 course' on getting started with academic research using the Twitter

@TwitterDev 426 Jan 04, 2023
Template to create a telegram bot in python

Template for Telegram Bot Template to create a telegram bot in python. How to Run Set your telegram bot token as environment variable TELEGRAM_BOT_TOK

Ali Hejazizo 12 Aug 14, 2022
A discord bot that utilizes Google's Rest API for Calendar, Drive, and Sheets

Bott This is a discord bot that utilizes Google's Rest API for Calendar, Drive, and Sheets. The bot first takes the sheet from the schedule manager in

1 Dec 04, 2021
Deleting someone else's Instagram account, repeat until the target account is blocked.

Program Features 📌 Instagram report V4. 📌 Coded with the latest version of Python. 📌 Has automatic scheduling. 📌 Full account report. 📌 Report a

hack4lx 16 Oct 25, 2022
Diablo II Resurrected helper

Diablo II Resurrected 快捷施法辅助 功能: + 创建守护进程,注册全局热键 alt+/ 启用和关闭功能 (todo: 播放声音提示) + 按 x 强制移动 + 按 1 ~ 0 快捷施法到鼠标区域 使用 编辑配置 settings.py 技能信息做如下定义: SKILLS:

Wan 2 Nov 06, 2022
This is a cryptocurrency trading bot that analyses Reddit sentiment and places trades on Binance based on reddit post and comment sentiment. If you like this project please consider donating via brave. Thanks.

This is a cryptocurrency trading bot that analyses Reddit sentiment and places trades on Binance based on reddit post and comment sentiment. The bot f

Andrei 157 Dec 15, 2022
Some Discord bot block bad words, with this simple hacking tool you will be able to bypass blacklisted words

DISCORD-BAD-WORD-BYPASS-2022 DISCORD BLACKLISTED WORDS HACKING/BYPASS (EDUCATIONAL PURPOSES ONLY) bypass discord blacklisted words. Description Some D

6 Nov 20, 2022
A powerful application to automatically deploy GitHub Release.

A powerful application to automatically deploy GitHub Release.

Fentaniao 43 Sep 17, 2022
🛰️ Scripts démontrant l'utilisation de l'imagerie RADARSAT-1 à partir d'un seau AWS | 🛰️ Scripts demonstrating the use of RADARSAT-1 imagery from an AWS bucket

🛰️ Scripts démontrant l'utilisation de l'imagerie RADARSAT-1 à partir d'un seau AWS | 🛰️ Scripts demonstrating the use of RADARSAT-1 imagery from an AWS bucket

Agence spatiale canadienne - Canadian Space Agency 4 May 18, 2022
A Python wrapper for the QQ Channel API

A Python wrapper for the QQ Channel API

Fox_white 55 Dec 07, 2022