Hi. My name is Noah Gift. Today I'm going to talk to you about AWS CDK with Python. We're going to build a project that will deploy something in just a few minutes using the AWS Cloud9 environment and infrastructure as code. Let's go ahead and get started. Here we're inside of AWS Cloud9, a perfect environment for working with CDK. First step, what I'm going to do is I'm going to run this official documentation command just to make sure that I've got the right version of CDK. Good. That's the latest version. Next up, I'm going to look at this initialization structure inside of a official AWS Workshop. I'll go through here and copy this. I'll put this inside. This goes through and it makes this workshop directory, and notice now I'm inside of it. The next thing I'll do is I'll create a sample app, so go through here, run this command. Now, I've got this sample app. I can scroll up here and make sure that I do what it tells me to do. First step here, I create the virtual environment and I've sourced it. The next thing I'm going to do is make sure that I install what's inside this requirements file. Let's take a look real quick what's inside of here. This is all of the Python code that lets me use CDK. These are critical first steps. Once I've got this going, now I'm ready to actually go through and run other commands when they installation finishes. If I go through here and I type in, for example, "cdk ls", this should make me confident that CDK is working. It looks like it is working. It's thinking about the stacks. There we go. Perfect. Next up, now I'm going to go back to this documentation here, and I'm going to go to the Hello CDK and go to Hello Lambda. It asked me to create a directory called lambda inside of the CDK Workshop and then create this file inside. Let's go ahead and copy this. Go inside of here. Let's make a directory called lambda, and then I'll touch lambda. Let's see the name it wants us to do is hello.py. That looks great, hello.py. If I go inside of here, I can just paste this in. Very simple lambda. Lambda functions are Python functions in the case of the Python language except that event, very straightforward and they're run inside of AWS. Next step, what I can do is install the Lambda construct library. How do we do this? This is an interesting question. Well, one way to do it, would be to take this constructs code here and let's go over to our project and go into the section that actually has all of our infrastructure built in. Where would that be? We would just need to look inside for that particular stack and in this case we have it right here, cdk workshop and stack. Let's go and double-click this, and let's copy the whole thing, delete it and replace it. This is going to deploy our code here from CDK. Now, that I've got that inside the stack, I can scroll down here and go to CDK Diff. This will show me what is the local versus remote version. Since we've never deployed anything, there should be a pretty big diff. Let's go ahead and run this diff. We can see that it's going to go through and look at AWS, look at we've got locally and see if there's changes. In fact, there is, because we know that it's going to need to deploy this change to AWS. Now, that I've got that running, I just type in "cdk deploy" Let's go here next, to cdk deploy and we can actually push this into AWS. This will take just a second. We want to deploy the changes? Yes, we do. In this case, we can see, please run cdk bootstrap inside. We've got a problem. These are pretty common things that happen inside of CDK deployment. Let's go ahead and do that. Let's type in cdk bootstrap. This will make sure that the bootstrapping is created so that we can do the changes on AWS. One nice thing about doing this in the Cloud9 environment is it really is ideally suited for working with CDK because it gives you such great feedback and you know that it has the role level privileges in order to make these changes. Now, we go. We see this is actually making changes and I can watch this and make sure that it deploys, but I'm going to go back to the documentation here and double-check that everything is working. The final step here is to go to AWS Lambda console and make this change. While this thing is going here, I'm going to also open up a console to lambda and we go through here, we should see a last-modified filter, and this will populate once we've got this thing complete. I can just wait for this thing to go. Looks like it's deployed. It took about 77 seconds. Not too bad, considering how much work it's doing. If we go back to this Lambda console, there we go, 20 seconds ago we created it. Let's go to this console. We know that it's very straightforward to test this out because it's a very simple lambda function. I'm going to click on "Test". I'm going to go through here and say hello and then for here, let's just make something simple. We just say like events and then say, hi. There we go. Let's go ahead and format the JSON, create the event, go through a test and it says we have a stack trace here. It wasn't looking for a payload like that. It's actually looking for something else and so we could go through and test that out. Let's go ahead and configure another test event. In fact, we can just go to look at the documentation and see what they want us to send. You could go through and configure a more complex test event. But the main idea here is that in fact, if we look at our code here, we can see it looks like it's looking for the word path inside the event and so we could just put that word path inside. Let's go ahead and do that. Let's just say path. Path is hello and let's go ahead and save this format. Save, test it. There we go. Now, we got rid of the stack trace. Pretty straightforward to go through and use a CDK system to deploy your changes, and then later you can actually update the changes by looking at the diff and then deploying them again.