Skip to content
CBT Nuggets
DemoBook a Demo

Create and Deploy Code in the Cloud9 IDE

This skill, led by Knox Hutchinson, focuses on using AWS Cloud9 as a web-based IDE for developing and deploying AWS solutions. It covers setting up Cloud9 environments, managing users and roles, and creating and deploying Lambda functions with API Gateway integration. The skill also delves into using SAM templates for serverless application deployment and emphasizes best practices in DevOps and cloud development.

Full skill from AWS Certified Developer - Associate. Preview the training IT teams trust.

Updated

1h 1m

Skill 2 of 35 in AWS Certified Developer - Associate

What you'll learn

  • Describe the Cloud9 IDE features, including the built-in terminal, preinstalled AWS CLI and SAM CLI, and shareable environment links
  • Configure IAM groups, users, and roles that give developers baseline access to create a Cloud9 environment
  • Adjust IAM permissions so a Cloud9 user can deploy Lambda, API Gateway, CloudFormation, and S3 resources
  • Explain how CloudFormation uses a YAML template and S3 to deploy a Lambda function behind an API Gateway
  • Create, validate, and deploy a SAM template from the Cloud9 terminal using sam deploy --guided
  • Test a deployed Lambda function through the API Gateway console Test button with a POST request body

Free 61-minute video lesson with a full transcript and knowledge checks. No account needed to watch.

Overview

Join Knox Hutchinson as he demonstrates how to use Cloud9 as a method to develop and deploy AWS solutions.

Recommended Experience

  • 1 to 2 years of devops or cloud experience

Related Job Functions

  • Cloud Engineer
  • Solutions Architect
  • DevOps Engineer

Knox brings a wealth of data analysis and visualization experience to CBT Nuggets. Knox started off as a CBT Nuggets learner, became a mentor in our Learner Community, and is now a trainer. Having benefited from the CBT Nuggets Learning Experience firsthand, Knox creates training that connects with learners.

Introducing Development in the Cloud9 IDE

Let's explore AWS's native, web-based IDE.

Understand Cloud9 Features

Let's see why someone might choose to work with the Cloud9 IDE.

Knowledge Check

What is needed to open your Cloud9 IDE? (Choose two)

Select all that apply.

Prep Users and Roles

Let's get our users and roles straightened out for working with Cloud9.

Knowledge Check

Which role has the rights to create an environment for the current user only?

Create a Cloud9 Environment

Let's bring a Cloud9 Environment to life.

Knowledge Check

You can only deploy Cloud9 EC2 instances with a max of 16GB of RAM. True or false?

Adjust User Permissions

We now need to circle back and make sure our users have all the rights they need to work with SAM templates.

Knowledge Check

Which of the following is NOT a resource that a user would need access to in a SAM deployment?

Create and Deploy a SAM Template

Let's now look at how to scaffold and deploy a full SAM solution.

Knowledge Check

Which command will deploy your application with prompted parameters?

Test, Debug, and Fix Any Issues

Let's now explore how we can use our Lambda function!

Knowledge Check

The default proxy configuration on API Gateways will alter the payload provided to the backend lambda function. True or false?

Conclusion

I hope this has been informative for you and I would like to thank you for consuming.

View Transcript

Introducing Development in the Cloud9 IDE

0:06Welcome to the content on using the Cloud9 IDE baked straight in to AWS console. What is this all about? Well, what's the benefit of the cloud in the first place. Really think about it here, stretch your mind. It's the fact that the cloud is always on and always reliable, and you can get to it anywhere in the world, as long as you have a web browser. It's not necessarily the case with our IDEs that we like to use and prefer. I prefer VS Code personally. Some people who work with Python use PyCharm and so on and so on and so on. The idea here is that what if we just had our IDE in a web browser and wherever we could get to a web browser we could then get to our code.

0:44All of our code, the sessions that we're working on, all of our privileges, all of it is attached to that exact session that we can work with. So in this set of videos, we are going to explore the capabilities and features of the Cloud9 IDE. Even rolling up our sleeves and seeing it in action with the basic Lambda SAM deployment. Get ready because this is going to be a lot of fun. Let's go.

Understand Cloud9 Features

0:00[AUDIO LOGO] So what do you need to know about Cloud9 before you use it? That's what we're going to explore in this video. This is the built-in IDE that comes with the AWS console. You can do all of your development work with all of the necessary requirements like the AWS CLI, the SAM CLI. All of that is baked in to the IDE by default. At the end of the day, it makes working with AWS resources a heck of a lot easier.

0:32So in this video, we're going to explore some of the features and capabilities of Cloud9. Let's go. So Cloud9, what's it all about? Seems cool, but we need to dig a little deeper and we need to understand what it is that Cloud9 really brings to the table. I'm going to drag my browser here onto the screen because pretty much everything we're doing here in this particular set of videos can be done entirely browser-based. What I'm going to search for is AWS developer. Just search for AWS developer. And if we scroll down just a hair-- I'm looking for AWS Developer Center.

1:04I know, certified developer is, well, why we're here, but we're going to jump to the AWS US Developer Center. And this is going to be your happy place. So if you are serious about becoming an AWS developer and you don't know where to start with one of their products, I'm going to tell you right here is where you want to start looking through one of their products. They have a lot of cool events, SDK information. And if we scroll down a hair, you'll find more about their tools and resources or you can discover what is possible.

1:37What I'd encourage you to do for this set of videos is under the More Resources, you'll actually see the exhaustive list of tools right there. Give Tools a click, it fires up all of your developer tools. You can pick your programming language of choice right here. And the big thing that we see is we've got getting started guides, how to build applications, and-- oop, there it is. That's why we're here. Build on AWS with an IDE. IDEs are awesome. I mean, I've been working with them for years and years and years.

2:09VS code is now my preferred IDE, especially with all the modern extensions that are built into it. But for newcomers who are getting started with AWS, it makes a lot of sense to use the IDE that is baked straight into your web browser. All you have to do is log in and-- well, if you have enough permissions-- launch the IDE. That will then have the entire state in session of all of the things that you want to build. It'll have all of that in one spot.

2:41And it can even work with Git repositories. So you'll imagine here-- you're going to see it in just a second. But you'll imagine here kind of a file browser, a directory browser here, a terminal down at the bottom, and then the actual code view at the top or the actual files that you're editing. So it's not unlike any other IDE that you've ever worked with, except it's not locally on your computer. This is being hosted on a virtual machine in the cloud. And the state that you're currently working with-- like if I'm working on code and then I close my browser and walk away, and take a lunch break for two hours.

3:21When I come back and go back to that website where the actual IDE is, pops right back up where I was. Now it still makes a whole lot of sense to use Git repositories. That way we could persist our code changes after we've want to actually check in some code. And nine times out of 10, that's going to be a major part of your CI/CD and your DevOps pipeline anyways, right? So that's why having Git baked into this is already a big deal. But it also has the AWS CLI.

3:54It has the SAM CLI. And it has popular SDKs that you want to work with. It even has Docker installed on it. I'll tell you right now, one of the more popular things that I've seen this IDE used for is to build containers. And then ship those containers directly from the IDE to the service that they're targeting. So that may be the Elastic Container services or it might be something like a Lambda function that runs as a container. The point is, is all of this now has integration in mind here.

4:28I think that's the biggest thing. So when I launch as user A right here, my user A, if they already have permissions to interact with things like Lambda functions or with API gateways, when I type commands down here in the terminal to ship code to those areas, it'll automatically be able to use user A's credentials baked directly into the token that the browser is holding. see, it's a huge win because now there's less friction for getting started.

4:59Look, just being totally honest here, you're like getting started with AWS, it's not the easiest thing on the planet. So any tools that can help you get up to speed quicker are very much welcome. And having dependencies, having command line, having containerisms, having all of that handled for you is a huge win. Now there are some factors that you probably want to know about Cloud9 before you get started. It does support a huge number of programming languages, but not every single runtime is on the latest and greatest.

5:34For instance, as of the time of this recording, Python is now on version 3.11. However, Cloud9 and even many of the different resources in AWS do not natively support Python version 3.11. You can get around it by running containers, of course, but still that's neither here nor there. So you'll want to double check, first of all, if you are developing in JavaScript and you need to use node or NPM packages, you want to check the versioning items that you run into there. Same with, really, any programming language like Python, like I just highlighted just now.

6:10The other things that I want you to know about are that this runs on top of an EC2 instance. The actual IDE itself runs on top of an EC2 instance. Whenever you want to test things out, whenever you want to, say, test the code out by running it, it can deploy an EC2 instance alongside it, ship the code to that EC2 instance, test it out, and then return the results back. And then tear down this EC2 instance when it's done. That is something that can be done.

6:41It makes sense if you're in a very large enterprise, like a huge business where they have a lot of policies in place, it makes sense that you may have your sysadmin deploy these instances in advance. That way whenever your user needs to connect to this EC2 instance and this EC2 instance needs to connect into that EC2 instance, all you have to do is provide it with SSH info to do that. You'll see when we actually get to the deployment of Cloud9 itself, there are two options for how you as a user connect in the first place.

7:15And we're going to choose SSH to handle that. But just know that you do have the option to pre-provision these resources and then provide SSH information for how they will all speak together. Speaking of that sysadmin, there is one particularly interesting thing that you should be aware about. And that's the as of the time of this recording, Cloud9 is not automatically maintained by AWS. What am I talking about there? Well, there's a couple different operating systems that you get to pick from to run on your EC2 instance.

7:49When I say they're not automatically maintained, I'm saying that AWS is not going to handle the patching of those operating systems or the runtime environments that run on top of that. That'll be on you to handle it. But if you already are in an environment where sysadmins are deploying the EC2 instances for you, that just becomes part of their lifecycle, their upgrade cycle at that point. So not the end of the world, but something that you do need to be aware of. Especially if you do find out about security items or patches that need to take place, there you go.

8:22Now I can't stress this enough, this really is a full IDE. Outside of the fact that you can do things like you're seeing here with no split screen editors on the screen, you can configure runtime environments and de-buggers. You can integrate different tools for serverless environments. If we keep scrolling down, you'll see all sorts of things here, like the built-in terminal. And I think this was one of the cooler options that I've seen. When you create your Cloud9 environment, you can actually share a link to that environment, your own personal environment, to other people in your organization.

8:59And that will enable collaborative chat and code editing right there on the screen. Beyond that, like I said, CICD can be baked into it. Pretty cool. And Get is baked into it, so we do see things like File Revision History and-- of course, everybody's favorite-- Themes. Got to have those themes, right? So you see, there's a lot of things that Cloud9 can do. And in the next few videos, we're going to walk through the basics of getting your environment ready for Cloud9. And then actually standing it up and publishing some code with it.

9:29I hope this has been informative for you, and I'd like to thank you for viewing.

Prep Users and Roles

0:00[AUDIO LOGO] Now like most things, in AWS, it's not as easy as just click on the resource and it's deployed. We have to have users, permissions, roles, groups, all of that squared away up front before we get going. So in this video, we're going to introduce and kind of reinforce the concept of how the best practices of creating groups, users, and roles should work. This isn't going to be the exhaustive list of all of the roles that we need.

0:31You're going to see that in an upcoming video where we have to circle back and add some additional roles into the mix. So without further ado, let's start by standing up a test group, user, and some permissions to get them at least in the door to working with CloudNine. Let's go. All right, it is time to have some fun. I am going to get signed into the console as my root user. Let me see here. Oh, I'm already signed in as my user. Just to be safe, I'm going to sign out, make absolutely sure I'm signed in as my root user. Sometimes this happens.

1:03So I'm going to sign in as my root user. Thank you LastPass and multifactor authentication for keeping me nice and safe. I'll go ahead and sign in. Let me get that MFA code and we'll circle back to it when I'm-- All right, so now we are getting signed in. Now, like everything else that's in the AWS environment, you can deploy users or resources all day long but none of those things have roles, or access, or privileges by default. So what I'm thinking here is I may have a group of devs and those group of devs are going to be working in CloudNine.

1:39In particular, they're going to be working with and deploying Sam models. In this case, Sam models could mean a few things but really, what I'm focused in on is deploying a Lambda function and an API gateway. The API gateway serves as basically on the edge. Here's the internet out here. There is the internet, that's going to be the cloud. The API gateway sits right here kind of on the edge of it and it serves as the first point of defense, if you will.

2:09It's going to process the payload that comes in as well as read the headers, handle authentication if that's something that we need to do, and then it sends it to the backend which is where the Lambda function lives. In fact, you know what I probably should do, I should probably just write this as a Lambda. So there we go. Then the Lambda function runs its function. It returns a response back to the API gateway who processes the response and sends it out that way. This is what the serverless application model is all about.

2:42But in order to do all of these things, a user needs the privileges to deploy their own CloudNine environment they need the privileges to work with Lambda in API gateways, they even need privileges to work with CloudFormation and S3. If you don't have any of these things stood up already, if this is the first resource you've ever deployed in AWS, there's a whole lot of privileges that need to get taken care of first. So right now, we're starting off on the very, very basics where we're just going to get the devs access to CloudNine so that they can create their cloud nine IDE environment and poke around.

3:25Then, they won't be able to do much at this point, except for you start poking around maybe clone a repository, start editing some code, but they can't ship it. That's why in an upcoming video, we will circle back and then add the additional roles and privileges via the policies that they need for Lambda, API gateways, CloudFormation, and S3, OK? All right, so there. Now we've got that objective under our head. I'm going to jump to my IAM section. I've already got it pinned right here, recently visited. You can, of course search for IAM, right here.

3:56It's the first thing that comes up or if you really want to, can open up services, scroll all the way to the bottom where you see security, identity, and compliance, and then jump into IAM right there. You can also hit this little star right there on the spot if you haven't done this yet and now it's like a little bookmark right there on the screen. Pretty cool, right? So I'm going to jump into IAM and let's go, there it goes. It spins up. Now, what am I going to do? First things first, the best practices here are to create a group. I am going to create a group called devs, very straightforward name, right?

4:29Let's go devs, like so. I'm not going to add any users into this group right now, see how that's optional, but I am going to give it the CloudNine policies. I'm going to search for CloudNine right here. And what do they need? They need CloudNine user. Now what is this all about? One of these different roles all about? First of all, CloudNine user is someone who is allowed to create their own IDE CloudNine environment. A CloudNine administrator is someone who can see all CloudNine IDE environments, tear them up, delete them down, add permissions, and so on.

5:06The environment member is someone who is allowed to open an already existing IDE but they can't create their own. The SME instance profile right here is for if they specifically want to connect in to the CloudNine environment using the SME AWS service. So instead of connecting through SSH, we're actually allowing AWS to handle these secure connection on the back end and then present the console to us through the browser.

5:39Now, that's still going to be the same exact experience you're going to get either way. It's just oftentimes it's often thought that a AWS makes it a little bit more secure when you use SSM. Not entirely mandatory unless you have a company policy that says so. In my demo case, I'm going to keep this as frictionless as possible. And use the cloud nine user to create the group. So my group is going to be named devs and the CloudNine, AWS CloudNine user is the policy that I'm attaching at this point. Boop, devs, done.

6:10Now I need to create the user account. So I'm going to create a new user account here we'll call this Knox dev, something really simple, and they do need console access that way they can actually browse to the CloudNine console if they need to go through the AWS console to do that. I'll let it auto-generate a password for me and I'm going to turn off this prompt to create a new password at the next sign in. That way, I can just use this auto-generated password. It's a lab environment.

6:40I can be a little willy nilly, if you will, but you, in an environment where you've got the company credit card on file be a little more careful with that. Let's go next and here we go. So what group does that member need to be a part of? Right there, they're going to join the devs group like so. I'm going to click Next and review and create. So let's do it. Create user, Yay, there we go. So what do I need? I need the sign in URL, I need the username, and I need the password. There's the password.

7:11So I'm going to copy all of these things to a text file real quick. Here we go, copy the username, Oh, I lost my-- come back here. Come back here. There we go. Yeah, better. OK, copy the username and then copy this password right there and great. Awesome. So let's just make sure that the user could actually access the CloudNine console. So what I'm going to do is I'm going to sign out right there. I'm going to grab the sign in URL for this new user named Knox dev, paste it, Enter, and we will get in the-- I know the name is NOx dev so I'm just going to copy the password, type Knox dev and paste it right there and click Sign In.

7:58So with that sign in done, I don't need LastPass to remember this sample account. Now, what I can do is I can search for CloudNine and as long is I can browse to this right here, that's a really good sign. Let's see, no errors, no warnings. Yeah, that looks great. So if I choose Create Environment, does it give me any gap? Nope this is great. So in the next video, we can move to the very next step where we create the environment and explore what all we can do. I hope this has been informative for you and I'd like to thank you for viewing.

Create a Cloud9 Environment

0:00[AUDIO LOGO] So now that our user has been created and they have access to get to Cloud9, what comes next? They then need to actually build a Cloud9 environment. Cloud9, at the end of the day, really just runs on an EC2 instance. So in this video, we're actually going to deploy the cloud nine environment for that specific user. Let's get started. All right. So this is where we're picking up where we left off on the last video.

0:33You see effectively what are we really doing? We're spinning up a new EC2 instance. And a cool thing about this is we do get to pick the size of the EC2 instance. If you're like me, sometimes-- sometimes, I'm not going to say all the time, I'm not-- I would never ever admit to this out in the wild. But sometimes my Docker containers get a little big. OK? It happens to the best of us, right? We're working with a large node project or something like that.

1:03And all of those dependencies. We've all been in dependency hell before. Next thing we know, our container may be a couple of gigs or two or three gigs. It might be a big container. And what we find out pretty quickly is the one gig, one vCPU instance here that is free tier, that's nice. It's free. It might be just a little too small for really big projects. But for really basic projects and exploring what all Cloud9 can do, well, that's a great way to actually get going.

1:38What I'm going to do right now is I am going to go full screen like this, that way we get rid of that menu bar. And we can see this a little better. So what I'm going to call this? I'm going to call this knoxdev-env. That's going to be the name of my environment. I don't have to give it a description. This is going to be a newly provisioned EC2 instance. And for my basic use case right now, I'm just going to leave this in micro. You can click additional instance types. And you can see we can get pretty big instances if we need to like 384 gigs of RAM and 96 CPUs.

2:13What is that all about? Probably someone who's doing like machine learning and modeling on it or something like that. But nonetheless, you can get pretty big. Not every single EC2 instance type is supported. You're seeing T, C, and M. But that's still a pretty good list that you get to pick from. So I'm leaving this. Right now I'm going to go back to T2 micro because it's the free tier. And for my little example, that's all I need. For the OS, that is what platform is right here. We see I've got Amazon Linux 2 or Ubuntu 1804.

2:45Amazon Linux 2 is extremely lightweight. You still get a shell that you can interact with. It is basically like working with any other virtual machine that you're SSHed into. Now this is a good one, timeout. What does this all about? This is cost saving. If I disappear for 30 minutes, it basically takes a state save of the current environment that I'm in, and then sleeps the virtual machine effectively. It's almost like closing the lid on your laptop. And then you pick it you open the laptop back up, it takes a half a second to warm up.

3:18And then picks up exactly where you left off. That's basically what this is. So your timeout is after 30 minutes it goes into a hibernation state where you can awaken it very simply by just navigating back to it. Now the connection thing here. In my case, I'm going to choose SSH. Why? Because we did not assign the privileges for our current user. The current user who is working on building this environment. It tells you right here these IAM resources will be created.

3:51It's trying to create roles in this case. Specifically, these are the roles for the SSM, roles that exist right here. And because the user doesn't have the ability to create these roles, if I were to try and use AWS Systems Manager, it would file. So in this case, I'm going to choose SSH, and this will now succeed on the creation deployment. So give it a create, and there she goes. No errors. And it's underway. Now you see right here?

4:21This right here, this open button is how you actually get to the environment. That's what you want to look for. So give that a click, and you'll see it's going to take just a minute to spin up here. So let it spin and then come back to it when it's done. It takes about a minute to pass. And this is where we land. So what you're looking at here is the layout of the actual IDE. You have, first of all, notice the far left side, you've got three things that you can navigate to. This one is the File Explorer.

4:54This is what you're looking at right here on the screen. We're looking at a hidden folder right here called C9. This is where we actually configure our debug environment and our build environment. We'll be able to create our own folders with our own file structures down here and deploy our code whenever we want. Beyond that, I could use Git right there on the spot if that's what I wanted to do. I could absolutely hit Git clone and then clone my remote repository in and work with Git directly in the shell.

5:24Next up, speaking of Git, there it is. That's the next one on the list. If we give it a click, if I were actually working with any repositories, you would be able to see things like the branch that we're currently working on. Any files that haven't been staged. Anything that needs to be committed. The ability to push or pull repositories. This is all going to be contained right here. It's an exhaustive tool for working with source control. And lastly is at AWS Services right here. So when we look at AWS Services, it tells me we have a connection.

5:55And we even see the data center that we're currently running this in. The US East Ohio data center. If I expand this, we see all of the services that we could potentially interact with directly in the IDE. So if I expand Lambda here for a second, oh-oh, yeah. You might be and not be able to see because the font is really small. So it's failed to load resources. What's that all about? Well, our user still doesn't have permissions to see these kinds of resources. They can't see things like S3 buckets or Lambda.

6:26That's what we have to go back and give them permissions to interact with these resources if they're going to be developing on it. Now that being said, what else can we do while we're here? Well, it's worth pointing out that down here at the bottom, this is your terminal, you can resize this as needed. You can say aws --version to see what the version of your AWS CLI is currently working with. You can do sam --version to see what the SAM AWS CLI is currently working with. You can do git --version, there's your Git version.

6:58And docker --version. Let's see. Yep, there it is. We see Docker. See, all of these things were baked into this from default. You also have this welcome screen right here where it gives you some documentation, security best practices. You can even change the theme of the editor that you want to work with. So dark, gray, or light, it's all right there. As well as the keyboard mode, if you want to change that keyboard mode for whatever reason if you're masochistic and you want to use them.

7:29I joke. I joke. But nano is better. I said it. I said it. Got it of my chest. Look, it also shows you can get started with creating a file, uploading files from your local computer into the IDE environment, or cloning a repository from GitHub. Also take note that these are tabs across the top. Much like any other IDE, I can close this and I can click the plus button to ask me, what are all the things that you want to open? Would highly recommend checking out open preferences because there are a lot of things that you can do configuring your actual instance like your-- what runtimes and what programming languages you actually want to support.

8:08So you can go to look and see like Python support and see the Python 3 is enabled. So if I were to say python3 hyphen, is it lowercase V or uppercase V? Let's find out. Oh, there's a lot of stuff going on here. Doesn't like that. There we go. Let's see. There that's better. I just did python3 --version. We see that by default, it is running Python 3.7.16. So this is-- I'm not going to say a little old, but it's a little old. I mean, we're on Python 3.11 right now.

8:40And Python 3.10 introduced some really cool features like the match statements. So that's one of those things, anyways. I digress. This is-- oh, oh, other here. Here's your debug terminal over here on the left hand side-- or on the right hand side, excuse me. You also have a filter. So if you're looking for specific files or specific text within a file. And then right above that, you actually have the chat box where you can collaborate on what is going on in your IDE environment. So we explored some pretty cool things here in this video.

9:12This IDE does a lot of cool stuff. But still could be better, right? Because we still need to get access to these other items so that we can work on Lambda functions and such. One final thing that I'll point out is do explore what all you can do within these menus. Things like code formatting can be defined here. And as well as showing you the hotkeys to automatically format the code. You can do-- let's see. Where did it go? I just saw it. It was really cool. Oh, right here our view, you can find even more themes right here below.

9:44So if you want to explore some different color themes for your IDE, you can do that. You can also adjust things like font size, where it shows you the hotkeys for adjusting font size. Really, really good stuff that all exists right here in these menus at the top. So there, with all that being said, we've now launched into the IDE, explored it a little bit, and we're ready to get started. We're ready to start hacking. So that's what we're going to do in the next video. We got to make sure we've got the permissions set up so that we can start actually working on building and deploying our code.

10:15I hope this has been informative for you, and I'd like to thank you for viewing.

Adjust User Permissions

0:00[AUDIO LOGO] What you find out pretty quickly is it's cool that user can get their foot in the door and they actually have the IDE where they can develop code and ship code and check it in to Git repositories. But if they actually need to push deployments out there into the world, like deploying a Lambda function or an API gateway, they'll find out pretty quickly that the default user group that we've given them isn't sufficient.

0:30So in this video, we're going to circle back to those roles and permissions and give our user additional roles that can allow them to deploy a SAM template. The SAM template is going to be a Lambda resource and an API gateway to serve as a proxy that sits in front of it. Let's go. So in the previous video, we got launched into the IDE, and we were really excited to start deploying Lambda functions. But it tells you right here, failed to load resources, because it can't even look anything.

1:01If I were to try and create a Lambda SAM application by right clicking on Lambda and clicking on it, it would just blow up on me because this user doesn't have any of the permissions they need to do those things. So here's what I'm going to do. I'm going to go ahead and get logged out, sign back in as my administrator role. Let's go ahead and get signed all the way out here. Log back in. I'm going to choose sign in using my root user email. We'll go back to my last pass, go ahead next, sign in, multifactor, and we're getting signed right back in.

1:36So what I need to do is I need to jump back into my IAM environment right here, and then we're going to go back to my user group and alter the permissions that my devs actually get here. So I'm going to jump into my devs and I'm going to jump over to the permissions. We need to add some additional policies right here, including a custom inline policy that we're going to create on the fly. So I'm going to choose attach policies. And the first thing I'm going to do is make sure these guys can do whatever they want with Lambda. So I'm going to search for Lambda and I'm going to look for the full Lambda role.

2:10It's right down here towards the bottom. AWS Lambda full access. I'm going to add that permission right now there. Now they've got it. And now also what I need to do is make sure that they can deploy and execute API gateway tasks. So let's just search for API. They might have not like gate. OK hang on, hang on. Where would you go? Oh duh, I'm looking at the existing roles, not the permissions or the policies that I'm trying to attach. So let's go and search for add policy and search for API one more time.

2:44And then we'll see Amazon API gateway administrator. I'm going to check that right there. And I'm also going to be looking for Amazon API gateway invoke full access. That is what I want to add into these right here. So I am going to add these permissions into the mix. Now they have the API gateway items that they need. But there's still a lot more that they need to interact with S3. They need to create an S3 storage account. Why?

3:15Because we're going to be shipping code to a Lambda environment. And the way that works is we first ship code to S3 where Lambda then picks it up. Who's doing all this shipping? Anyways CloudFormation. You can think of CloudFormation as a YAML defined template that deploys groups of cloud resources. To me, the thing that I am most familiar with in this world with that is like Docker compose. If you're coming from the Azure world, this is also like ARM templates.

3:48So CloudFormation is a YAML template that says and defines how groups of resources are supposed to be deployed at the same time and interact with each other. We also define things like roles and permissions that all get created at the same time. So this user is going to need all sorts of stuff at the end of the day, or the devs are going to need all sorts of stuff. So I'm going to create an inline policy, and we're just going to paste in some JSON. Now where can you go to get this JSON? I'll show you.

4:19It's github.com/dataknox/awssamples. Brings it up right here. Now you'll see we are currently working on the DVA-CO2 exam. And here's the Cloud9 folder. This will grow over time, there will be more folders and more code samples here as the course progresses. This is just one of the first things I'm recording. And right here you see policy.json. This is what we want to paste in to get all of this to work. So do raw, there we got the raw text.

4:51I'll Command-A to highlight everything, Command-C to copy. Jump back to the console. Delete all this out. Paste all this in. And I scroll down, I see no errors. So I'm going to choose review policy. We're going to go ahead and give this a name like DevCloud9. How about SAM? Like that. DevCloud9SAM. That'll be the name of the policy that I'm creating here, because that's what I'm trying to do. I'm trying to give my devs who are working in Cloud9 the permissions to do what they need to do with SAM resources.

5:23So at this point, my permissions should be good to go. What I'm going to do is I'm now going to log back out, sign back in as my IAM user. So let's do sign in to the console. I'm going to choose an IAM user. And I need to bring up my text document. One more time. There we go. Where did you go? Come on. Hang on. Oh, there it is right there. So this was the user ID. So let's go ahead and save the account ID is right there.

5:54Next. Flip back. I'll just grab the password since the username is knoxdev. That's simple enough. Knoxdev. Paste in the password and sign in. So now we're looking good. Let's jump back into Cloud9. You'll see how it's just going to pick up exactly where I left off. That's the big thing that I was stressing before, right? Give it a click. Let's see. And bring it back up exactly where I left off. See. Remember the last thing I did was Python 3 version? Yeah.

6:24Exactly. Right? Now I can jump into AWS over here, expand US East Ohio. And if I expand Lambda, there's no more error. Now it just says no functions found. Much better. Great. So now my user has the permissions that they need to interact with Lambda and API gateways. They now have what they need to use CloudFormation to deploy a stack, which is effectively the group of resources that were deployed together.

6:56That would include deploying an S3 storage account. So we've got everything that we need to actually build an actual function that's going to serve as an API. And that's what we're going to do in the next video. I hope this has been informative for you, and I'd like to thank you for viewing.

Create and Deploy a SAM Template

0:00[AUDIO LOGO] Now with those permissions in place, our user can move forward with actually creating a lambda project. And that's what we're going to do in this video. We are actually going to create a lambda project from scratch. I've got some custom code that we're going to use. It's still pretty hello world at the end of the day. But still we're going to actually get this built and then deployed out there into the real world. In the next video, we'll test it out. So without further ado, let's jump back into Cloud9, build a lambda project, deploy it out there into the real world, then we'll check it out.

0:37Let's go. All right. So now we're ready to see this in action. I know I'm pretty excited about this. What I'm going to do is I'm going to let Cloud9 do a lot of the heavy lifting for me. I want to create a python based function. And just to kind of tell you what I'm trying to do, I just want to make a post with a payload in the body of my API request. This is going to be a post request. And in that, I'm going to say I want to get some Star Wars data.

1:08I might define the type of data that I want to get as something like a planet data. And then I might say that the detail that I'm trying to get is maybe tatooine, a important and well-known planet in the Star Wars universe. So this is how the payload is going to look that I'm posting in to the actual lambda function. And I want the lambda function to reply back with something that says I was able to parse your request you said tatooine.

1:41That's effectively what I'm trying to do here. So to bring all of this to life, like I said, I'm going to let Cloud9 do a lot of the heavy lifting. So I'm going to say create a lambda SAM application. So we'll give that a click by right clicking on it and then we say what is your environment that you want to run with? I'm going to say Python 3.9. Notice that is the latest image that we can get. This is not python 310 or 311. So you can't use things like the match statement. You're going to have to use if or elif or whatever the case is. So Python 3.9 is fine.

2:12I'm OK with the Intel 64-bit. Even though I am, you know you've probably may have noticed that I'm on a MacOS, I am using the ARM architecture. But that's fine. Now what are we trying to do? We're trying to do a hello world basic SAM application. So that's what I'm going to click right here to give it an application template. And I'm just going to let it run in this folder. The root of my folder is going to create my entire project right there in the root of my folder. So I'll give that a click. And it says enter a name for your new application.

2:43And I'm going to call this sw.app for Star Wars app. I'll press enter right there. And it's underway. If I now click back into the folder explorer here, it says, oh, AWS toolkit compiled SAM application sw.app and added the launch configurations to launch.json. So that means the actual debugging information is there now. You can open launch.json to explore it right here. And you see that's how it's kind of got the entire development environment set up.

3:14Now over here on the folder explorer, you see the sw.app folder right there. If I expand it, look at this. It actually initialized a full project. First thing that you want to take a look at is template.yml. You'll have to double click on this to bring up template.yml. Now what am I looking at here? This is the template that is going to deploy all of your resources. First is your API gateway, and the lambda function that is down here.

3:47We see how it's actually going to be handling things like permissions. This is the permission that is assigned to the API gateway. And I think this is one of the more important things that you're going to see. Right here under properties, we're establishing an endpoint that the API will hit, as well as what is the type of methods that it will accept. So if I wanted this to access the root endpoint, I can put the forward slash here, and I'm going to change my method to be post. So I'll Command-S. Make sure you save these things as you go along.

4:21This is the only change I need to make for a basic ARM-- or excuse me, a basic SAM template right now. Now I also see I've got ReadMe docs and the Py initialization. Within the actual folders themselves, we actually see the hello world folder. This is where the application itself lives. We see I've got app.py. If I double click that, this is where the lambda code lives. Now if this is your first time seeing lambda, at minimum, you have to have at least one function called lambda_handler.

4:54It takes the event itself which contains things like the body of the requests that came in, as well as headers of the requests, and so on, as well as a context as to where this is being run. Now I'm going to replace almost all of this code with my Star Wars code. So let's go ahead and do that. I'm going to go back to that GitHub repository, github.com/datanox. So let's go to github.com/datanox. And then we'll just go straight into AWS samples.

5:26Jumping into the Cloud9 folder. And we see app.py39, that's for version-- Python version 3.9. So that's what I want. I'm going to choose raw right here, grab the entire payload, Command-C, jump back to the development environment, highlight everything, Command-V, and Command-S to save. So you can see what it's doing right here. The payload, recall, is going to have two keys-- type and detail.

5:58So as the payload comes in, it's going to be known as an event. And from there, we could parse that event as a dictionary. Type is the first key, and then details are right here. So if we're saying the body of tatooine-- as detailed tatooine, set the response body to be hello tatooine reply with a status code of 200 and a json payload of the actual body itself. Just like that. That's what we're doing right here. Not particularly complicated.

6:28If you are building your own code and you had your own requirements that are necessary, you can specify those requirements in requirements.text. That's, of course, for python libraries. If you are working with say node, you would want to look for package.json, and edit that section as needed. So this is the actual code itself. Now that I've got all of this stood up, what comes next? Well, the way this is going to work, what we need to do is we actually need to build this entire project as a container.

7:01So what I'm going to do in the terminal is I'm going to move into the sw.app folder. The commands that I'm going to run right here, they have to be run in the same path as the template.yml file, because that's what the YAML file really depends on. So being in the route of my project in the same folder if I type ls here you see I'm in the same folder as template.yml. Now what I can say is sam build, and then specify use container.

7:32You're going to use a container to build this. So I'm going to press Enter. Boop, there it goes. And now it's actually downloading the image itself before it performs the build. You'll also see new folders get created where the actual build folder, the build artifacts are going to be kept. So I'm going to let this run. We're going to circle back to it once the container has been successfully built. All right. So now that gets done, it's done building. That's nice. And we see that right down here, the font again is really small and I can't zoom right here.

8:05I've been trying to zoom in and it won't let me zoom. But it does say you have some commands that you can run next. We can validate the actual SAM template itself. Make sure that looks good. We can invoke a function locally, basically spinning up that new EC2 instance behind the scenes, shipping the code and invoking it. But really what we're here to do is deploy. To deploy this, we have to say sam deploy with the option of guided. So I'm going to type sam deploy --guided.

8:35But before I press enter, I'm going to scroll up and I'm going to bring this terminal up quite a bit because there's a lot that goes on whenever we actually do this. So I'm going to press enter, and we're going to take a look at what it's doing. So what's the name of the application that we're going to be deploying? I'm going to call this Star Wars App, S-W-A-P-P and press Enter. Then what's the region? I'm OK with leaving this in the east or the us-east-2. So I'll just press enter to accept that as the default. The next thing is confirm changes before you deploy. Lowercase Y. Then it says do you want to allow the SAM CLI IAM role creation.

9:10I have to. We're going to press Enter. Disable rollback. I'm just going to say yes to all of these things. So there we go. The helloworld function may not have authorization defined. Basically, it's say we looked at your code, we looked at the API template and we didn't see how auth would be handled. So this is going to be open. Are you OK with that? I'm going to say yes. Do you want to save arguments to a configuration file? I'm going to say yes. And then I'm not going to overwrite the configuration file name, nor am I going to overwrite the configuration environment.

9:43So I press enter and there she goes. OK. So the first time I ran that, you may have noticed that, that it actually threw an error at me where it said it was unable to-- it said there was a put object iteration, which means it was trying to update something that was already existing. Basically, I had some old stuff sitting in my AWS environment and that blew up the build. It blew up one more time because it actually needs S3 full access to create and upload and edit S3 buckets.

10:14So now that that's been granted to the devs group here, we're going to jump back into Cloud9. I knew I forgot something. It was going to be that one S3 full access permission. So with that being said, now I can jump back into that user and get this deployed. So sign back in with that user, jumping back into the Cloud9 environment, I'm going to open the IDE. And it should pick up immediately where I left off. So there we go. No, I'm not going to try using Vim mode. It's just not-- it's just not for me. All right. We're going to go up. We're going to build using the container one more time just to make sure I've got a fresh build.

10:47I'm going to hit up a couple of times. Do the deployment guide. We'll call this Star Wars App in the east-us. Yes to all of the things. There we go. Y, Y, Y, lowercase Y, uppercase Y, and leave those as the default. Yes. But one last thing. Whenever you are trying to update a stack, if the current state of the stack is in rollback complete, it will not let you progress. So I need to reset that one more time. So jumping back into CloudFormation, I see the rollback complete status.

11:20That means I have to delete this guy right here. We'll delete it. Delete stack. And give it a refresh. Make sure it deletes successfully. Sometimes it doesn't delete successfully because the S3 bucket had already been created, in which case, , you have to go into S3 and delete the bucket that exists right there. So you have to delete all of the items in the bucket, then empty the bucket. And that's how you get rid of your bucket. So now that I've deleted that stack, it's not in the rollback complete status anymore. Now I can go forward, deploy the stack, which will then have the permissions to actually create the S3 bucket, which will then be able to proceed with deploying the lambda and the API gateway.

12:02See, I told you these permissions were a real thing. They're really a [garbled] when it comes to working with the SAM CLI. OK, so here we go. Getting signed back in. There we go. There's the password sign in. I'm going to jump straight into Cloud9. Right here at the top, I've got it pinned. I'm going to open the IDE one more time. There we go. See, it's nice and snappy. How quick it could actually get the IDE environment brought back up. So here we go. Press enter a couple of times. We're going to build one more time, deploy, change the name to Star Wars App.

12:39Everything else is going to be the same that we've already done. Here we go. Not U, Y. There we go. Y, Y, enter, enter. There we go. So now it's recreating the required resources. This time, it should succeed, and we'll come back to it when it's done. All right. Much better. So now it actually creates what's called a change set. It tells you overall what the proceeding operations are going to be. We're going to be creating some new resources, creating some new roles, creating the API gateway, creating the lambda function.

13:12So I'm going to say yes. We're OK to proceed with the actual deployment itself after validating what is happening in the change set. I have type Y, press enter, and there it goes. We actually see the creation of the roles and everything like that happening in real-time. So it's just going to be streaming in every half second or so as things get created. So you can see it's actually going through the process of creating the lambda function, creating the API gateway, creating the permissions, all of that is now happening.

13:43And we should see the success status message come up here any moment now. Aha, there it is. Successfully created and updated the stack swap in the east-us. How do I know for sure? I'm going to go back to my console, let's go into Services, and let's first take a look at API gateway. We should now see an API gateway resource. Come on, get rid of that. There we go. There we go. There's the swap API gateway. That's great. I should also be able to go into lambda and see the lambda resource.

14:16So bring up the lambda function. And there's the swap hello world function. All right. Do they work? That's what we're going to find out in the next video. I hope this has been informative for you, and I'd like to thank you for viewing.

Test, Debug, and Fix Any Issues

0:00[AUDIO LOGO] In the previous video, we built and deployed a SAM project. This is the Lambda function with an API gateway standing in front of it. Does it work? You're going to find out pretty quickly there's a little bit more tweaking we need to do to make this really work, at least in the scenario that I have in mind. So without further ado, let's test out our Lambda function and our API gateway and make some adjustments where need. Let's go.

0:30All right. We might have a little bit of tidying up to do, but we're going to find out pretty quickly here. I'm going to jump into my actual Lambda function itself. This is where we can see how the Lambda function is designed to work overall. We can hit it via the API gateway, which then runs the function, gets the response, and returns it back to the API gateway. If I wanted to go to the Lambda function directly, I could go into the configuration and can configure a URL-- in fact, I can show you, here's the configuration right here.

1:03Function URL by default there isn't one because our trigger is actually based on the API gateway hitting the query. We can also review the actual code that is used to make this run so this is where the code actually looks. Now, with the test itself, we need to configure a test event to actually test this thing out. So we're going to be creating a new event. I'll call this mytester, something really simple. I'll leave this event sharing to be private, template doesn't really matter. And the actual payload itself that we're posting in, remember I need a type and a detail.

1:39So I'll delete this. Type this right here to open up a brackets. We'll say the type is going to be planet, and the next bit of payload is going to be the detail is going to be tatooine. Like so. There we go. So if I do Format JSON, make it look nice and pretty. Everything here looks good, so I'm going to save this test item and then click the Test button. Aha, success.

2:10Do you see it right there? There's the response. Status code of hello, the body came back as hello tatooine. We see how long it took to run, 1.24 milliseconds, was built for 2 milliseconds, memory size was 128 megs, max memory actually used was 36 megs. Yeah. So this is great. This actually worked. The function actually works the way we want it to. Now, does it work if I'm coming in from the outbound, the internet coming into the API gateway?

2:42Let's find out. If I jump to the services and jump over to the API gateway, this one might give us a little more trouble. We're going to find out. You're going to see why. If I jump into the Star Wars app that I have here. I see it registers my POST request. That's what we deployed. The POST request is at the root and I can test this right here. You see this Test button? If I give that a click, all I have to do is provide request body one more time. Just like before, we had type and the type was planet.

3:15Then I can say the detail was tatooine like so. Spell tatooine correctly, though, right? OK. There we go. So this should be what I need to test it out. Now, watch what happens. When I click Test right here, what are all these details that are coming back? What is this? Method complete with 502. Specifically, it says the Lambda execution failed because-- it's kind of messy to see right here because it's all kind of messed up, it failed with status 200, which is the actual success message, but due to customer function error type.

3:54If you scroll up right here, it's blowing up on the line if event type equals planet. Why is it blowing up right there? I'll show you why. Because right here when I go back, you see this Lambda proxy? So the method comes in, the POST message comes in and it's got that payload. When the API gateway is set to serve as a true proxy to the Lambda function, it alters the payload.

4:25It actually changes the keys themselves and puts my-- remember I had type and I had detail, it puts that inside of a key named body. And then there's other metadata about the actual event that goes in along with it. So my code is trying to parse directly to that key when it had to go through body first. So what I can do to fix this is I can just turn off the proxy.

4:55So if I go to Integration Request, I can say right here you see Use Lambda Proxy Integration right there, just turn that off. Boop, uncheck it. And say, OK, and then say, OK. There we go. Now, it's not quite done yet because there's still one other thing that has to happen. When the Lambda function runs, it returns a status code of 200 with the payload itself. So what we have to do is we have to go into this method response and tell it when you get a status code of 200, here's how you reply back to the client.

5:35It's really misleading because you see HTTP Status 200 right here and you're thinking, well, it's already handling status code of 200. Give it a click, though, and you see it actually has no mapping. So right here it's asking, OK, when the response is coming inbound right here, what response code do you want to work with? I'll say if the inbound response is 200, I'll click the little check mark right here, then you can tell it when you expand this down here's what your response header should be, here's what your response body should be.

6:07But you can leave this alone right now. You don't actually have to edit anything because as long as it knows how to handle an inbound status of 200, then it'll just past the body, the response body, straight through back to the calling client. So I'll go to Test right here, I'll type in the body. One more time that was a type of planet and a detail of tatooine, like so.

6:40Scroll down to the bottom. Hit Test. And look at this. Now, we have successfully completed 200 the whole way through. We see the inbound body that came in and we see the response payloads coming back right there. So now the API gateway is successfully handling my Lambda function and we have now deployed a full SAM experienced from a Cloud Shell that is cloud nine.

7:12I hope this has been informative for you, and I'd like to thank you for viewing.

Frequently asked questions

What does the Create and Deploy Code in the Cloud9 IDE lesson cover?

The lesson walks a team member through the Cloud9 IDE in the AWS console, from preparing IAM users, groups, and roles to creating a Cloud9 environment and adjusting permissions. It then builds a basic Lambda project, deploys it as a SAM template with an API Gateway in front of it, and tests, debugs, and fixes any issues.

How long does the Cloud9 IDE lesson take?

The lesson runs 1 hour and 1 minute. It is one part of the AWS Certified Developer – Associate (DVA-C02) course, which IT Directors and Team Leads should plan at roughly 34 hours per learner, plus review time.

What IAM permissions do developers need to deploy a SAM template from Cloud9?

The lesson starts with a basic group and user that can open Cloud9, clone repositories, and edit code but not ship it. It then adds the policies needed for Lambda, API Gateway, CloudFormation, and S3, since code is first shipped to S3, where Lambda picks it up, and CloudFormation deploys the grouped resources.

Which tools come built into the Cloud9 IDE?

According to the lesson, Cloud9 includes the AWS CLI and SAM CLI by default, along with a built-in terminal, configurable runtime environments and debuggers, and integrations for serverless tools. Team members can also share a link to their environment with others in the organization and collaborate through a built-in chat box.

How is a SAM application deployed and tested in this lesson?

The learner deploys with sam deploy --guided after seeing options to validate the template and invoke the function locally. The deployed POST endpoint is then tested from the API Gateway console with a sample request body to confirm traffic coming in from the internet reaches the Lambda function.

How does this lesson fit the AWS Certified Developer – Associate (DVA-C02) course?

It gives developers hands-on practice with the serverless deployment pattern the course emphasizes: Lambda, API Gateway, SAM templates, and IAM roles and policies. Training Managers can assign it within the serverless section so team members build deployment fluency alongside DVA-C02 exam preparation.

What's next?

Ready to keep going?

For your team

Bring this training to your team

See how CBT Nuggets helps IT teams close skills gaps, hit compliance targets, and prove training ROI.

Book a Demo
Just need AWS Certified Developer - Associate?

Learning on your own? Browse individual plans ($49/month, billed annually) →

Not ready to buy?
with no purchase required. Already have an account?
Book a Demo