Day # 3 : AWS: Setup SNS/IoT/Lambda

Posted by Pranav

Step 1 : Create a SNS Topic

Step 2 : Create a subscription : Add the phone number you want to send an SMS

Today3.png

Step 3 : Create a Lambda Function with the following code

 

from __future__ import print_function
import boto3
import json
sns_arn = "arn:aws:sns:us-east-1:XYXYXYXYXXYX:Amma"


def pranav(event,context):
     sns_client = boto3.client('sns')
     output = event['clickType'] 
     if output == "SINGLE" :
          message_to_send = "I took the bus and starting"
     elif bag == "DOUBLE":
          message_to_send = "Ignore my message"
     elif bag == "LONG" :
           message_to_send = " I Might be a bit Late"
     rsp = sns_client.publish(
     TargetArn=sns_arn,
     Message=message_to_send)


 

How to set up a Welcome Message on Unix

Update the file following File on Ubuntu /etc/motd with the message that is needed.

  • vi /etc/motd file and add a message of your choice.

 

To get some Good Banners, use

http://patorjk.com/software/taag/#p=display&f=Varsity&t=Nag

___ ___ ___
/__/\ / /\ / /\
\ \:\ / /::\ / /:/_
\ \:\ / /:/\:\ / /:/ /\
_____\__\:\ / /:/~/::\ / /:/_/::\
/__/::::::::\ /__/:/ /:/\:\ /__/:/__\/\:\
\ \:\~~\~~\/ \ \:\/:/__\/ \ \:\ /~~/:/
\ \:\ ~~~ \ \::/ \ \:\ /:/
\ \:\ \ \:\ \ \:\/:/
\ \:\ \ \:\ \ \::/
\__\/ \__\/ \__\/

How to set up ‘virtualenv’ for python development

Whey virtualenv ?

When you do a pip install {whatever} everything by default is installed /Library/Python/2.7/site-packages/. This is a special directory that Python knows about, Anything that’s installed in “site-packages" can be imported by your programs. This is also owned by root, and every time you want to install a package you will have to do sudo, like ‘sudo pip install requests’

How to setup/install virtualenv on mac,

sudo pip install virtualenv

How do i create a virtualenv and start working,

  • cd
  • virtualenv nag
  • source nag/bin/activate