Book Image

Hybrid Cloud for Developers

By : Manoj Hirway
Book Image

Hybrid Cloud for Developers

By: Manoj Hirway

Overview of this book

This book introduces you to the hybrid cloud platform, and focuses on the AWS public cloud and OpenStack private cloud platforms. It provides a deep dive into the AWS and OpenStack cloud platform services that are essential for developing hybrid cloud applications. You will learn to develop applications on AWS and OpenStack platforms with ease by leveraging various cloud services and taking advantage of PaaS. The book provides you with the ability to leverage the ?exibility of choosing a cloud platform for migrating your existing resources to the cloud, as well as developing hybrid cloud applications that can migrate virtual machine instances from AWS to OpenStack and vice versa. You will also be able to build and test cloud applications without worrying about the system that your development environment supports. The book also provides an in-depth understanding of the best practices that are followed across the industry for developing cloud applications, as well as for adapting the hybrid cloud platform. Lastly, it also sheds light on various troubleshooting techniques for OpenStack and AWS cloud platform services that are consumed by hybrid cloud applications. By the end of this book, you will have a deep understanding of the hybrid cloud platform and will be able to develop robust, efficient, modular, scalable, and ?exible cloud applications.
Table of Contents (16 chapters)
Title Page
Dedication
Packt Upsell
Contributors
Preface
Index

Developing Amazon SQS applications – Unix


The boto3 library provides classes for manipulating the SQS queues. We will start by creating the SQS queue using the boto3 library.

Creating an SQS queue

First, create an object of type sqs and then invoke the create_queue() function to create an SQS queue. The response object is a Python dictionary that can then be used to fetch the URL of the queue.

The following Python program creates a queue and fetches the URL of the newly created queue:

import boto3

# Create SQS client
sqs_object = boto3.client('sqs')

response = sqs_object.create_queue(
    QueueName='packtpub_queue',
)

queue_url = response['QueueUrl']


Once the queue is created, let's send a message to it.

Sending a message to the queue

Using the SQS object, invoke the send_message() function and pass the queue URL, delay time, message, and the message attributes to it. The message attributes hold the metadata related to the actual message.

The following code snippet sends a message to the queue...