Step 0: get the CLI for AWS, setup credentials. See here: https://boto3.readthedocs.io/en/latest/guide/quickstart.html
In [4]:
import boto3
Message queues for communicating between stuff, incluiding lambdas and anything else.
Step 0: Make a message queue e.g.: aws sqs create-queue --queue-name MyQueue --attributes file://create-queue.json or see https://docs.aws.amazon.com/cli/latest/reference/sqs/create-queue.html
Endgame: https://cloudonaut.io/integrate-sqs-and-lambda-serverless-architecture-for-asynchronous-workloads/
In [5]:
#{"QueueUrl": "https://eu-west-1.queue.amazonaws.com/901610709743/boto_tut_sqs"}
sqs = boto3.client('sqs') #make the client
queue_url = 'https://eu-west-1.queue.amazonaws.com/901610709743/boto_tut_sqs' #use a url for the queue
In [7]:
# Send a message to an SQS queue
response = sqs.send_message(
QueueUrl=queue_url,
DelaySeconds=10,
MessageAttributes={'Title': {'DataType': 'String',
'StringValue': 'Solanum tuberosum'
}
},
MessageBody=('Thats the non-vulgar name of potatoes, you barbarian.')
)
In [ ]:
print(response['MessageId'])