Previous Lecture Complete and continue  

  User Data

Welcome to module three. In this module, we will be talking about Environment and Application Deployment Automation. So you learned how to create and launch instances, but what if you need to create thousands of them? That will become a little bit hard without automating all the manual steps. You don't want to SSH into each individual machine to get a password or to set up some package or an application.

One of the easiest way to automate your deployment and infrastructure is to use user data. Just to refresh your memory, it's on the third step in the EC2 launch wizard. Let's take a look at the screenshot. So step number three, that's where you configure the details of your EC2 instance. So you would click on "Advanced Details". And then you would see that big text box. So that's where you put your user data. A few things to know about the user data and how it works. First of all, user data, it's opaque data, meaning AWS platform would not validate, enforce or check it. It's basically up to the instance to interpret and execute whatever scripts, whatever commands you're putting there. Those commands are executed only at the launch of an instance. So if later you try to go back, update the user data, the platform will totally allow you to do that. But it would be very useless activity because that user data will run only on the instance launched.

The user data is limited to 16 kilobytes of raw data, not base64-encoded. And user data must be base64-encoded before you can submit it to the API. This applies to the HTTP RESTful protocol for the AWS. The AWS Command Line Interface and the EC2 web console, they would do the encoding for you. They're very user-friendly, developer-friendly, so we don't need to do that manual encoding. But, when you using SDK or you are working with the RESTful AWS API directly, in those cases, remember that you need base64-encode your user data. And one more side note, there are many, many other ways how you can automate your environment. User data is just one of the most straight-forward, the easiest to get started with. Go and check AWS Intermediate after this course for more ways how to automate infrastructure.

0 comments