AWS® For Developers For Dummies®
Published by: John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030-5774, www.wiley.com
Copyright © 2017 by John Wiley & Sons, Inc., Hoboken, New Jersey
Media and software compilation copyright © 2017 by John Wiley & Sons, Inc. All rights reserved.
Published simultaneously in Canada
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without the prior written permission of the Publisher. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online at http://www.wiley.com/go/permissions
.
Trademarks: Wiley, For Dummies, the Dummies Man logo, Dummies.com, Making Everything Easier, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and may not be used without written permission. AWS is a registered trademark of Amazon Technologies, Inc. All other trademarks are the property of their respective owners. John Wiley & Sons, Inc. is not associated with any product or vendor mentioned in this book.
LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND THE AUTHOR MAKE NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS WORK AND SPECIFICALLY DISCLAIM ALL WARRANTIES, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE. NO WARRANTY MAY BE CREATED OR EXTENDED BY SALES OR PROMOTIONAL MATERIALS. THE ADVICE AND STRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE FOR EVERY SITUATION. THIS WORK IS SOLD WITH THE UNDERSTANDING THAT THE PUBLISHER IS NOT ENGAGED IN RENDERING LEGAL, ACCOUNTING, OR OTHER PROFESSIONAL SERVICES. IF PROFESSIONAL ASSISTANCE IS REQUIRED, THE SERVICES OF A COMPETENT PROFESSIONAL PERSON SHOULD BE SOUGHT. NEITHER THE PUBLISHER NOR THE AUTHOR SHALL BE LIABLE FOR DAMAGES ARISING HEREFROM. THE FACT THAT AN ORGANIZATION OR WEBSITE IS REFERRED TO IN THIS WORK AS A CITATION AND/OR A POTENTIAL SOURCE OF FURTHER INFORMATION DOES NOT MEAN THAT THE AUTHOR OR THE PUBLISHER ENDORSES THE INFORMATION THE ORGANIZATION OR WEBSITE MAY PROVIDE OR RECOMMENDATIONS IT MAY MAKE. FURTHER, READERS SHOULD BE AWARE THAT INTERNET WEBSITES LISTED IN THIS WORK MAY HAVE CHANGED OR DISAPPEARED BETWEEN WHEN THIS WORK WAS WRITTEN AND WHEN IT IS READ.
For general information on our other products and services, please contact our Customer Care Department within the U.S. at 877-762-2974, outside the U.S. at 317-572-3993, or fax 317-572-4002. For technical support, please visit https://hub.wiley.com/community/support/dummies
.
Wiley publishes in a variety of print and electronic formats and by print-on-demand. Some material included with standard print versions of this book may not be included in e-books or in print-on-demand. If this book refers to media such as a CD or DVD that is not included in the version you purchased, you may download this material at http://booksupport.wiley.com
. For more information about Wiley products, visit www.wiley.com
.
Library of Congress Control Number: 2017946597
ISBN: 978-1-119-37184-7
ISBN 978-1-119-37189-2 (ebk); ISBN ePDF 978-1-119-37186-1 (ebk)
With the availability of cloud-based resources, developers today have an unprecedented opportunity to create amazing applications that previously weren’t possible. Amazon Web Services (AWS) enables developers to interact with the entire world, even when their application supports the smallest of organizations. The access to services in the cloud is amazing enough, but the access to data and other resources is now at mind-boggling levels. Unfortunately, many developers are indeed overawed by the sheer size and scope of cloud-based development, which is why you need AWS For Developers For Dummies.
This book is about making things simple. You don’t have to try to understand the entire cloud or even just AWS in a single sitting; instead, AWS For Developers For Dummies breaks down all the concepts into smaller chunks. If you want to create imaginative applications, this books helps you do so without spending frustrating hours learning the arcane AWS API beforehand. Life is short. With this book, you can create an application in just a few hours and become productive more quickly, freeing you from the drudgery of learning quite a lot to do only a little.
The purpose of AWS For Developers For Dummies is to help you get up and running quickly. You build a test environment and install tools that let you experiment with many of the major services without a lot of effort. The focus of this book is to get you started doing something by using just a few of the services. One of the hardest parts of working with AWS is that so many services are available (more than 100 of them) that a developer might go nuts just trying to figure out where to begin. This book relieves you of that problem.
Most of the book examples focus on three kinds of AWS interaction: through the console, through the Command Line Interface (CLI), and programmatically. In most cases, these are the three ways developers begin working with AWS. The console lets you see how AWS works from an administrative level. Using CLI helps you understand the AWS functionality at a deeper level, plus you can use it to create scripts. Finally, this book uses Python Notebooks to make experimentation very easy. You don’t have to write complete applications to see something happen; just a few lines of code will do. So, in contrast to other programming projects, in which you spent hours writing code just to see the project die because of the smallest typo, this book helps you attain something significant without much typing at all.
To help you absorb the concepts, this book uses the following conventions:
monofont
. If you’re reading a digital version of this book on a device connected to the Internet, you can click the live link to visit a website, like this: http://www.dummies.com
.You might have a hard time believing that I’ve assumed anything about you — after all, I haven’t even met you yet! Although most assumptions are indeed foolish, I made certain assumptions to provide a starting point for the book.
The first assumption is that you’re familiar with the platform you want to use, because the book doesn’t offer any guidance in this regard. This book doesn’t discuss any platform-specific issues. You really do need to know how to install applications, use applications, and generally work with your chosen platform before you begin working with this book.
You also need to be familiar with your browser and understand how to interact with browser-based applications. Sprinkled throughout are numerous references to online material that can enhance your learning experience. In addition, most of the tasks you perform with AWS require that you work in your browser.
This book is largely platform independent. However, none of the procedures are tested using small mobile devices, such as a smartphone (and some are almost guaranteed not to work on a small device). Differences in appearance do emerge when using a smaller device; a control that appears as a button on a larger device may appear as a link or other control on a smaller device. You need access to the sort of setup that a developer will use to create and configure online applications, which means a larger tablet, notebook, or, better yet, a full desktop system. The various people who worked on this book used desktop systems running the Windows, Linux, and Mac OS X platforms and using a number of common browsers.
Because this is a book about application development, you also need to have some understanding of the development process. Knowledge of Python would be nice, but it’s not absolutely necessary because of the way the examples work. You may still need to spend some time with a Python tutorial to understand everything that the examples provide. In addition, you need to know how to work at the command prompt or terminal window. Many of the examples require that you manually type commands rather than work with a GUI. In fact, a few of the examples simply won’t work with a GUI because the options are unavailable. (These examples are clearly marked in the book.)
As you read this book, you encounter icons in the margins that indicate material of special interest (or not, as the case may be!). Here’s what the icons mean:
This book isn’t the end of your AWS learning experience — it’s really just the beginning. I provide online content to make this book more flexible and better able to meet your needs. That way, as I receive email from you, I can address questions and tell you how updates to AWS or its associated add-ons affect book content. In fact, you gain access to these cool additions:
www.dummies.com
and search for AWS For Developers For Dummies Cheat Sheet. On the page that appears, scroll down the page until your cursor turns the AWS For Developers For Dummies Cheat Sheet link blue; then click it. The cheat sheet contains really neat information such as figuring out which service you want to use.Updates: Sometimes changes happen. For example, I might not have seen an upcoming change when I looked into my crystal ball during the writing of this book. In the past, this possibility simply meant that the book became outdated and less useful, but you can now find updates to the book at www.dummies.com
.
In addition to these updates, check out the blog posts with answers to reader questions and demonstrations of useful book-related techniques at http://blog.johnmuellerbooks.com/
.
www.dummies.com
and search AWS For Developers For Dummies. Scroll down to the graphic of the book cover and click it. Click the More About This Book box that appears and then the Download tab to find the files.It’s time to start your AWS adventure! If you’re completely new to AWS, you should start with Chapter 1 and progress through the book at a pace that allows you to absorb as much of the material as possible. Chapter 2 is especially important because it helps you understand what Amazon means by free-tier services. You should also read Chapter 3, even if you have experience with AWS, because it provides information about the services discussed in the book.
Readers who have some exposure to AWS must still work through the latter half of Chapter 2 because it shows how to obtain your developer key. After that, you can move directly to Chapter 4. You can always go back to earlier chapters as necessary when you have questions. However, you do need to understand how each technique works before moving to the next one. Every technique and procedure has important lessons for you, and you can miss vital content if you start skipping too much information.
Part 1
IN THIS PART …
Get started with Amazon Web Services (AWS).
Create a good AWS development environment.
Obtain your developer key.
Understand the AWS free tier.
Consider the security issues.
Chapter 1
IN THIS CHAPTER
Exploring the AWS cloud
Considering Infrastructure as a Service (IaaS)
Defining when, why, and how to use AWS
Ensuring you have a supported platform
There was a time when business development meant creating software for a single machine or for a workgroup. The client-server architecture, with its emphasis on both local and centralized servers, came next. Developers eventually started creating applications for the Internet as well, enabling people to do things like work from home without losing contact with the organization’s database. Browser-based applications actually appear on most desktops today, and you might spend much of your nondevelopment time using one.
As development has moved onward and outward, the tools, techniques, and processes for development have changed as well. Today you deal with the cloud, where the server that holds your application doesn’t even reside on the premises. In many respects, everyone is a remote user today. Of course, organizations have a huge investment in existing hardware and software, so you’re actually more likely to find yourself working in a hybrid environment with one foot on local resources and the other on someone else’s turf. Amazon Web Services (AWS) provides you with a complete development environment, but for many developers, the changes that using AWS require are significant and awkward. This chapter helps you better understand what to expect from AWS and to feel just a little less awkward about the coming changes.
You may also find yourself drowning in a sea of new abbreviations and acronyms. Of course, you can act like you know what all these terms mean, but they’re actually important terms, and knowing what they mean gives you an edge over everyone else. This chapter also helps you understand terms like Infrastructure as a Service (IaaS) and discover just what this new term means to you as a developer. If you already work on the Internet, you could possibly skip this part of the chapter, but if you’ve spent your career working with desktop applications or a local intranet, you definitely want to find out more.
Developers often find that the most frustrating part of creating an application is having the right tool. Development is more than knowing the right procedures and the right function calls — it’s a matter of knowing the most efficient manner in which to use them and determining when the tools already in use won’t do the job. This chapter closes with some essential information about the platforms that AWS supports. Reading this material will help you avoid some serious trouble later because you can avoid the most serious platform issues at the outset.
As a developer, you need to meet end-user demands with the least amount of effort and in the quickest time. Amazon Web Services (AWS) is a huge array of services that affects consumers, small to medium-sized businesses (SMB), and enterprises. Using AWS, you can do everything from creating applications for remote access to organization data to creating a full-fledged IT department in the cloud. The installed base is immense. You can find case studies of companies like Adobe and Netflix that use AWS at https://aws.amazon.com/solutions/case-studies/
. (The page also includes a link to create an account, a topic discussed in Chapter 2.) AWS use isn’t just for private companies, either — even the government makes use of its services.
The technologies that make all these services possible are simple in conception. Think of a pair of tin cans attached to each other by a string. Amazon holds one tin can and you hold the other. By talking into one tin can, you can hear what is said at the other end. The implementation, however, relies on details that make communication harder than you might initially think. The following sections give you an overview on how the AWS cloud works.
Service-driven application architectures, sometimes known as Service-Oriented Architectures (SOA), come in many forms. No matter how you view them, service-driven application architectures are extensions of the client-server technologies that you may still use when creating localized applications, in that a client makes a request that a server fulfills by performing an action or sending a response.
The request/response implementation details have changed significantly over the years, however, making modern applications far more reliable, flexible, and less reliant on a specific network configuration. The request and response process can involve multiple levels of granularity, with the term microservice applied to the smallest request and response pairs. Developers often refer to an application that relies on a service-driven application architecture as a composite application because it exists as multiple pieces glued together to form a whole. Service-driven application architectures follow many specific patterns, but in general, they use the following sequence to perform communication tasks:
Send the request using a protocol, such as Simple Object Access Protocol (SOAP), or an architecture, such as REpresentational State Transfer (REST).
No matter what programming language you use, you need to know how to communicate with web services using your programming language of choice. The “Considering the AWS-Supported Platforms” section of this chapter helps you make a good decision about a language choice. You can discover how SOAP works at http://www.w3schools.com/xml/xml:soap.asp
and how REST works at http://www.tutorialspoint.com/restful/
. Knowledge of both is required when working with AWS as a developer.
Even though many of the processes you perform with AWS require using an app (so that you have a user interface rather than code to work with), the underlying process is the same. The code provided in the app makes requests and then waits for a response. In some cases, the app must determine the success or failure of an action on the server. Rather than reinvent the wheel, a smart developer will use as many of these apps as possible to perform general configuration tasks. Using the AWS apps places the burden of updating the code on Amazon so that you can focus on custom tasks related to your organization.
In creating apps to help manage underlying services, AWS also defines workflows. A workflow is an organized method of accomplishing tasks. For example, when you want to save a file to AWS using S3, you must first create a bucket to hold the file. Only after you create a bucket can you save a file to AWS. In addition, you can’t retrieve a file from the bucket until you first save a file there, which makes sense because you can’t grab a file out of thin air. In short, a workflow defines a procedure for working with software, and the concept has been around for a long time. (The first workflows appeared in the mid-1970s with simple office automation prototypes at Xerox Parc and the University of Pennsylvania’s Wharton School of Business.)
Workflows can consist of additional workflows. In addition, workflows manage the interaction between users and underlying services. A process is the aggregation of services managed by workflows into a cohesive whole. The workflows may perform generic tasks, but processes tend to be specific and help users accomplish particular goals. A process-driven workflow is proactive and attempts to circumvent potential problems by
A function is the reactive use of services managed by workflows to address specific problems in real time. Even though it would be nice if process-driven workflows worked all the time, the reality is that even with 99.999 percent reliability, the process will fail at some point, and a function-driven workflow must be in place to address that failure. Although process-driven workflows focus on flexible completion of tasks, function-driven workflows focus on procedurally attenuating the effect of a failure. In short, function-driven workflows address needs. The AWS services and workflows also deal with this issue through the user interface, such as by manually restoring a backup to mitigate a system failure.
https://aws.amazon.com/lambda/
), to perform tasks without resorting to hard codingEven though this book frequently refers to virtual environments and services that you can’t physically see, these elements all exist as part of a real computer environment that Amazon hosts on your behalf. You need to understand how these elements work to some extent because they have a physical presence and impact on your personal or business needs. Three technologies enable anyone to create a virtual computer center using AWS:
The following sections provide an extended discussion of these three technologies and help you understand how they interact with each other. The point of these sections is that each element performs a different task, yet you need all three to create a complete solution.
The simplest way to view IaaS is as a means of providing access to virtualized computer resources over an Internet connection. IaaS acts as one of three methods of sharing resources over the Internet, alongside SaaS and PaaS. AWS supports IaaS by providing access to virtualized hardware, software, servers, storage, and other infrastructure components. In short, you can use IaaS to replace every physical element in your computing setup except those required to establish and maintain Internet connectivity and those required to provide nonvirtualized services (such as printing). The advantages of IaaS are many, but here are the ones that most people consider essential:
Keep in mind that there is no free lunch. AWS and other IaaS providers are interested in making a profit. They do so by investing in huge quantities of hardware, software, and management personnel to oversee it all. The benefits of scale help create profit, and many businesses simply can’t create the setups they require for less money. However, you must consider the definite disadvantages of IaaS as well:
SaaS is all about cloud-based applications. Products like online email and office suites are examples of cloud-based applications. A client typically accesses the application using a local application, such as a browser. The browser runs on local hardware, but the application runs on the host hardware. What a client sees is the application running in the browser as if it is working locally. In most cases, the application runs within a browser without any alteration to the local system. However, some applications do require the addition of plug-ins.
The difference between IaaS and SaaS is the level of service. When working with IaaS, a client typically requires detailed support that spans entire solutions. A SaaS solution may include only the application. However, it can also include the following:
PaaS is more of a development solution than a production environment solution. A development team typically uses PaaS to create custom solutions or modify existing solutions. The development staff has full control over the application and can perform all development-related tasks, such as debugging and testing. As with the SaaS solution, the host normally maintains control over
In this case, however, the development staff can access the middleware to enhance application development without reinventing the wheel. Writing application code to make the application cloud-ready isn’t necessary because the middleware already contains these features. The development team gains access to cloud-based application features that include the following: