Cloud Resume Challenge: Some things I learned
Tags: programming, webdev, python, typescript
Published: 2023-02-16 21:24:58

I just completed v1 of my cloud resume challenge. It's available at [erikresume.com](https://erikresume.com). I say v1 because there are some things that could be improved, and I may do some add-ons to the project as well.

But what is the cloud resume challenge?

The cloud resume challenge is project brief developed by Forrest Brazeal, which aims to prepare you for a job in the cloud. It requires using a variety of clouding services and stitching them together into one cohesive working website.

My resume website has a straightforward HTML rendering of my resume, as well as a visits number at the bottom of the page. That visits number hides a lot of complexity, as I will allude to below.

I went into the project a few days ago feeling pretty confident: I had started on the project before, and I felt strong in my Python programming knowledge. But there were some things that tripped me up. Here's a brief description of some of those things, as well as what I learned.

First, CORS, or Cross-Origin Resource Sharing. I ran into this when I tried to let my website - `erikresume.com` - call an API - at something like `abcdef8.execute-api.us-east-2.amazonaws.com/prod/visits` - to get and increment the count of visits to the website. At first the API response was blocked by the same-origin policy, so I had to add particular headers to the API response to signal that it should be allowed through, even though it came from a different origin.

Second, I gained a much clearer understanding of how S3, CloudFront, and Route 53 fit together to serve a web page. Very briefly, S3 hold the content, CloudFront manages global distribution, and Route 53 matches your domain name (in my case erikresume.com) to the CloudFront distribution.

Third, I learned how API Gateway and Lambda functions fit together to expose a web URL - something like abcdef8.execute-api.us-east-2.amazonaws.com/prod/visits - and connect it to a Lambda function that executes coode you define. You can see [on GitHub](https://github.com/ekand/cloud-resume-backend/blob/v1.0.0/lambda/post_visit_counts_handler.py) the code for my Lambda Function.

Finally, I got more comfortable with Cloud Development Kit (CDK). I had seen this previously in a job, but here I got more practice with it. CDK is available in a number of languages, but I chose TypeScript, because that's the native language of the project.

With CDK you get to write your infractructure-as-code in a fully expressive programming language, and you get smart completions and other help in your IDE. I find it much more useable than YAML templates.

Here's an example of my code that defines an S3 bucket to hold the front end material of the website.

```TypeScript
    const assetsBucket = new s3.Bucket(this, "CloudResumeFrontendBucket", {
      websiteIndexDocument: "index.html",
      publicReadAccess: true,
    });
```
You can also see this code in context [on GitHub](https://github.com/ekand/cloud-resume-frontend/blob/ec2c7095c6f107737b28ef2f2b1ff0ff72016f6c/lib/cloud-resume-frontend-stack.ts#L15-L18).

Since `assetsBucket` is a `const`, we can access it later in the TypeScript code, for example to link the bucket to a CloudFront distribution. I found this way of doing things much more natural than clicking around in the AWS management console.

One other thing I learned was how to use AWS Organization Formation to set up multiple account. I also set up a pipeline using the AWS services CodeCommit and CodePipeline, so that all I need to do to add additional AWS accounts is add some lines of code to the configuration and push the code to CodeCommit. I can also disable accounts in this manner.

In conclusion, I learned a lot through this challenge. I hope you enjoyed reading about it. Maybe you'll even consider trying the challenge yourself. Feel free to reach out in the comments if you have questions or suggestions.