<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: JP Scriven</title>
    <description>The latest articles on DEV Community by JP Scriven (@cfjps).</description>
    <link>https://dev.to/cfjps</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F567832%2Fdfe62599-b09a-4208-8b52-9120d8936346.png</url>
      <title>DEV Community: JP Scriven</title>
      <link>https://dev.to/cfjps</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/cfjps"/>
    <language>en</language>
    <item>
      <title>Test your AWS Lambda function locally</title>
      <dc:creator>JP Scriven</dc:creator>
      <pubDate>Mon, 23 Aug 2021 09:16:36 +0000</pubDate>
      <link>https://dev.to/cfjps/test-your-aws-lambda-function-locally-206l</link>
      <guid>https://dev.to/cfjps/test-your-aws-lambda-function-locally-206l</guid>
      <description>&lt;h2&gt;
  
  
  Using AWS SAM to run your Lambda function locally
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What is AWS SAM?&lt;/strong&gt;&lt;br&gt;
SAM stands for Serverless Application Model and it is a framework that is used for developing and deploying serverless applications. The idea is that you can create a very simple SAM YAML file which would then generate more complex CloudFormation templates.&lt;br&gt;
All the configuration is done in YAML and it supports anything from CloudFormation like Parameters, Resources, Mapping, Outputs, etc...&lt;/p&gt;

&lt;p&gt;SAM gives you the ability to help you run Lambda, API Gateway, DynamoDB locally. Where you can then test your serverless solution before deploying to AWS.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Differences between SAM and CloudFormation:&lt;/strong&gt;&lt;br&gt;
You must include the Transform Header within your template and it indicates it is a SAM template.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Transform: 'AWS::Serverless-2016-10-31'&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Then you have the following types for resources:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;AWS::Serverless::Function&lt;/li&gt;
&lt;li&gt;AWS::Serverless::Api&lt;/li&gt;
&lt;li&gt;AWS::Serverless::SimpleTable&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Important commands to know:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;sam build: Fetches dependencies and creates local deployment artifacts&lt;/li&gt;
&lt;li&gt;sam package: Package and upload to Amazon S3 and generates a CloudFormation template&lt;/li&gt;
&lt;li&gt;sam deploy: Deploy to CloudFormation&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Simple HelloWorld SAM template to get you started:
&lt;/h2&gt;

&lt;p&gt;First create a folder for your application and then you can use VS Code or any editor of your choice to open that folder.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Next we will run the &lt;strong&gt;sam init&lt;/strong&gt; command, which will initialize a new serverless application with a SAM template.
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2FDRYGrGx.png" alt="sam init command"&gt;
&lt;/li&gt;
&lt;li&gt;We will select option 1 - AWS Quick Start Templates to get us started quickly with a template.&lt;/li&gt;
&lt;li&gt;Then it will ask us which package type we want and for this example we will select option 1, which will zip the artifact and upload to Amazon S3.
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2FKp1kKpr.png" alt="Select the runtime"&gt;
&lt;/li&gt;
&lt;li&gt;Now we need to select a runtime that we want to use for our serverless function. It supports a wide range of runtimes so you can select any version that you are comfortable with. I will select option 2 here and go with python 3.8.
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2Fo2363wd.png" alt="Quick start template AWS SAM"&gt;
&lt;/li&gt;
&lt;li&gt;Choose a Project name or leave blank to accept the default of sam-app.&lt;/li&gt;
&lt;li&gt;Next you will be provided with a list of different templates, we want just the basic Hello World example so we will go with option 1 again.
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2FIcjxFhe.png" alt="Generating the application"&gt;
&lt;/li&gt;
&lt;li&gt;As you can see now it is busy generating the application for us and creating the folder and file structure with the template that we need to get going.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Folder structure:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2F8Jh5h4w.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2F8Jh5h4w.jpg" alt="SAM template folder structure"&gt;&lt;/a&gt;&lt;br&gt;
After it is done generating all the files your folder structure should look similar to this.&lt;br&gt;
Our focus will be on the &lt;strong&gt;hello_world&lt;/strong&gt; folder, which is where our Lambda function code is stored and then the &lt;strong&gt;template.yaml&lt;/strong&gt; file, which is our AWS SAM template.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The template.yaml file:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2F9xqslTR.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2F9xqslTR.png" alt="template.yaml SAM file"&gt;&lt;/a&gt;&lt;br&gt;
As we can see at the top the &lt;strong&gt;Transform:  AWS::Serverless-2016-10-31&lt;/strong&gt; is included, which has to be included within the SAM template.&lt;br&gt;
Next under &lt;strong&gt;Resources&lt;/strong&gt; we can see that we have a Lambda function and it's type is AWS::Serverless::Function, which you include with your Lambda function in a SAM template.&lt;/p&gt;

&lt;p&gt;Under properties next to CodeUri, we need to specify where our lambda files will be, which in this case is under the folder &lt;strong&gt;hello_world&lt;/strong&gt;. The handler will be the file name where the handler function is located &lt;strong&gt;(app.py)&lt;/strong&gt; and our handler name &lt;strong&gt;(lambda_handler)&lt;/strong&gt;, which is why it is added as &lt;strong&gt;app.lambda_handler&lt;/strong&gt;. The runtime is what we selected during the initializing stage so depending on what you choose this might be different for you.&lt;br&gt;
With this Hello World example the also included an event attached to our function, which is an API and it is a get method.&lt;/p&gt;

&lt;h2&gt;
  
  
  Run this template locally for testing
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;IMPORTANT: To be able to test this template locally you will need to install Docker first as it will use Docker to run your function locally&lt;/strong&gt; &lt;a href="https://www.docker.com/products/docker-desktop" rel="noopener noreferrer"&gt;Download Docker here&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ol&gt;
&lt;li&gt;Now we can run &lt;strong&gt;sam build&lt;/strong&gt; which will  fetch the dependencies and create local deployment artifacts.&lt;/li&gt;
&lt;li&gt;Next we want to invoke our function, so we need to run the following command &lt;strong&gt;sam local invoke&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;It will mount our build function to a container and this is where Docker will be used. You don't have to know Docker to be able to use your function locally, you just need to have it installed and running, SAM does the rest for us.&lt;/li&gt;
&lt;li&gt;You will receive an output with the following if the function was invoke successfully.
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2Fx2SRcmn.png" alt="sam local invoke"&gt;
Shows you the same status you will receive as when you run your function from the AWS console. From here you can view details as the Duration, the billed duration, Max memory used etc. With the response from our Lambda function.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Conclusion:
&lt;/h2&gt;

&lt;p&gt;This is a quick way to get up and running with AWS SAM so you can test out, edit and deploy functions from your local machine. You can add code to your function and test the changes and play around with some other features of SAM. This quick short template once deployed to AWS will generate a more complex CloudFormation template and then deploy the stack to your AWS account.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>python</category>
      <category>serverless</category>
      <category>awscommunity</category>
    </item>
    <item>
      <title>What is the Lambda Execution context and why use it?</title>
      <dc:creator>JP Scriven</dc:creator>
      <pubDate>Sat, 14 Aug 2021 10:22:30 +0000</pubDate>
      <link>https://dev.to/cfjps/what-is-the-lambda-execution-context-and-why-use-it-3i0b</link>
      <guid>https://dev.to/cfjps/what-is-the-lambda-execution-context-and-why-use-it-3i0b</guid>
      <description>&lt;h2&gt;
  
  
  What is the AWS Lambda Execution Context?
&lt;/h2&gt;

&lt;p&gt;When your Lambda function gets called, Lambda will then invoke your function in an execution environment, which is an isolated runtime environment. The execution context is a temporary runtime environment that initializes any external dependencies of your lambda code. As your lambda function can be invoke numerous times and scale the execution context is maintained for some time in anticipation of another Lambda function invocation. When that happens it can "reuse" the context to execution time which will save time on your function. The execution context includes a &lt;strong&gt;/tmp&lt;/strong&gt; directory, that provides &lt;strong&gt;512mb&lt;/strong&gt; of temporary storage for your functions.&lt;/p&gt;

&lt;h2&gt;
  
  
  What can it be used for?
&lt;/h2&gt;

&lt;p&gt;There are a number of things the execution context can be used for but some great use cases for example is database connection, HTTP clients, SDK clients, etc...&lt;br&gt;
Best practice to not put any connections for example inside your handler, because that will mean that every time your function gets invoked, it will create a new database connection, which will cause problems in the future. You want to be able to create that database connection outside of your handler and then just use that connection within the handler of your Lambda function.&lt;/p&gt;

&lt;h2&gt;
  
  
  Do not initialize your Database connections like this:
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2Fq7oeguW.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2Fq7oeguW.png" alt="Bad initializing lambda function handler"&gt;&lt;/a&gt;&lt;br&gt;
This will cause a new connection to your DB every time your function gets invoked.&lt;/p&gt;

&lt;h2&gt;
  
  
  Rather create your function as follows:
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2F202KUo2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2F202KUo2.png" alt="Best practice database connection in your function"&gt;&lt;/a&gt;&lt;br&gt;
This is best practice and your Lambda function can now reuse the database connection in your handler, without the need to recreating the database connection if your function gets invoked multiple times in a short period.&lt;/p&gt;

&lt;h2&gt;
  
  
  /tmp space:
&lt;/h2&gt;

&lt;p&gt;When you need to work with a big file inside of your Lambda function, you can use the /tmp space &lt;strong&gt;to temporarily save&lt;/strong&gt; the file to use, if it's not bigger than 512MB. When the execution context is frozen, the directory content remains, which is helpful for multiple invocations. If you need more permanent objects that will not temporarily be used, then rather use something like AWS S3 for persistence of the object.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>serverless</category>
      <category>cloudskills</category>
      <category>lambda</category>
    </item>
    <item>
      <title>Why to use CloudFormation, while learning AWS</title>
      <dc:creator>JP Scriven</dc:creator>
      <pubDate>Tue, 03 Aug 2021 08:47:59 +0000</pubDate>
      <link>https://dev.to/cfjps/why-to-use-cloudformation-while-learning-aws-29oe</link>
      <guid>https://dev.to/cfjps/why-to-use-cloudformation-while-learning-aws-29oe</guid>
      <description>&lt;p&gt;&lt;strong&gt;What is CloudFormation?&lt;/strong&gt;&lt;br&gt;
CloudFormation is a IaaC(Infrastructure as Code), which lets you create, update and destroy AWS resources on the fly. Instead of having to build up server racks on-premises and then install network cables, routers, switches, firewalls, etc... You create a template and define your resources and configuration you need to deploy for your application and/or infrastructure. &lt;br&gt;
For Example you can do the following with a CloudFormation Template:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create a Security Group&lt;/li&gt;
&lt;li&gt;Then, create 2 EC2 instances which will use this security group&lt;/li&gt;
&lt;li&gt;Create 2 Elastic IP's that these EC2 will use&lt;/li&gt;
&lt;li&gt;Create a bucket in AWS S3&lt;/li&gt;
&lt;li&gt;As well as create a load balancer (ex. Application Load Balancer) in front of these machines&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;CloudFormation will then know exactly in which order to create these resources and create then in the right order for you and with the configuration that you specified in the template.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why use CloudFormation when starting out with AWS?&lt;/strong&gt;&lt;br&gt;
When you start out using and exploring AWS, you will mostly use the console, which is really great and a nice way to get familiar with the 100's of AWS services they provide. That is where you should start as well to get a feel for the service, how the configuration works, and how it is setup. Once you done this and comfortable with the console, you will realize that using the console is not a very efficient way to create/update and destroy resources. That is where CloudFormation comes in, specially when you are testing out your application at the start and don't want to pay for resources you are not using anymore. CloudFormation will help you create all the resources you need/define in code and does the rest, while you wait for your resources to be created on the fly. Now you can test you application and when you are done, you can delete your entire stack and all the resources in the template will be destroyed, saving you $$$ on resources not being used anymore. Then the next day you can create the resources again for further testing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Now for an example:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--p1DvpARa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/hC0ucXu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--p1DvpARa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/hC0ucXu.png" alt="CloudFormation Template"&gt;&lt;/a&gt;&lt;br&gt;
CloudFormation can be written in YAML and JSON, but as you can see YAML is easier to use and read on CloudFormation templates especially on more advanced templates. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We start with the Resources section, this is required for the template and also where you will declare all your resources to be created.&lt;/li&gt;
&lt;li&gt;Now you can declare a name for the resource to be created, which is up to you. Ex. MyInstance for the EC2 and MyEIP for your Elastic IP, SSHSecurityGroup for the Security group 1.&lt;/li&gt;
&lt;li&gt;Now we can specify what resource we actually want to create by specifying the Type. Here you can find a whole list of resources you can use: &lt;a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html"&gt;AWS Resources Type&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Next, we create properties specific to the resource we want to create, you can also read in the documentation as to which property fields are available to which resource.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Uploading your CloudFormation template&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Log into your AWS console. And then search for CloudFormation in the top search bar. &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pyP6knEP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://imgur.com/fNPQFUF.png" alt="CloudFormation search"&gt;
&lt;/li&gt;
&lt;li&gt;From here we can click on Create stack. &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Vc9P-ylI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://imgur.com/tOaP7Cz.png" alt="Create a Stack"&gt;
&lt;/li&gt;
&lt;li&gt;From here select the following: Upload a template file and choose your YAML CloudFormation template file that you want to upload. &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_G6owVwV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://imgur.com/Hk1vTJm.png" alt="Upload a template"&gt;
&lt;/li&gt;
&lt;li&gt;Click on Next. You will be asked to provide a Stack name, you can make that anything you want. And then click next and leave everything as default for simplicity. And then your resources will be created.&lt;/li&gt;
&lt;li&gt;After everything ran successful you should see a screen similar to this one: &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JRZeFHg5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://imgur.com/Pl9yfHp.png" alt="Stack complete successful"&gt;
&lt;/li&gt;
&lt;li&gt;When you are done testing/using the resources, you can click on Delete, which will then remove all the resources the stack just created in the right order.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
As you can see with this simple YAML template file we were able to create and destroy the resources easily and we are also to reuse this template multiple times, we can use it within other accounts. This was just a basic high-level overview of CloudFormation and you can do some pretty amazing things with it once you master all the basics it has to offer. You will never want to manually create resources yourself again after using CloudFormation!&lt;/p&gt;

</description>
      <category>aws</category>
      <category>automation</category>
      <category>cloud</category>
      <category>devops</category>
    </item>
    <item>
      <title>#ACloudGuru ElastiCache Challenge</title>
      <dc:creator>JP Scriven</dc:creator>
      <pubDate>Sun, 01 Aug 2021 08:56:21 +0000</pubDate>
      <link>https://dev.to/cfjps/acloudguru-elasticache-challenge-1f11</link>
      <guid>https://dev.to/cfjps/acloudguru-elasticache-challenge-1f11</guid>
      <description>&lt;h2&gt;
  
  
  ACloudGuru ElastiCache Challenge
&lt;/h2&gt;

&lt;p&gt;I decided to take this challenge when I saw that they released it, because I am planning on writing my AWS Developer Associate Certification soon and wanted some practical projects to work on while preparing for the exam. I recently build my NextJS portfolio website which I am hosting as a static website on AWS S3 and then using CloudFront as my distribution and HTTPS provider pointing to my Static website. Then by using AWS Lambda and DynamoDB, I created a function to increment my page visits every time the website gets viewed. I wanted more exposure to CloudFormation templates and decided to do this challenges in CloudFormation templates instead of the AWS console or CLI.&lt;/p&gt;

&lt;h2&gt;
  
  
  CloudFormation Template
&lt;/h2&gt;

&lt;p&gt;I started with the parameters, to have some flexibility and to focus on referencing them in the template. I decided for testing purposes to use my EC2 keypair and the master database username as parameters. I wanted to keep the master database password a bit secure, so I used SSM secure string to keep my master password. There are many ways one can approach this. In this challenge I wanted to test and see how I could reference a parameter coming from somewhere else in AWS instead of CloudFormation.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WhYWDPVU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/PaYaCNz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WhYWDPVU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/PaYaCNz.png" alt="CloudFormation Params"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next I started working on the Security Groups, I allowed HTTP and the flask port to my EC2 server to be able to browse to my app from my local computer. Then with the RDS and ElastiCache security groups I referenced the SG of my EC2 server, so that only my EC2 server can communicate to those services.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--SVjIlHsT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/UYGGZ4U.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SVjIlHsT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/UYGGZ4U.png" alt="Security Groups"&gt;&lt;/a&gt;The next part creates a RDS PostgreSQL database which will be in the free tier if you keep the setup as is. Then for the master password I decided to use SSM SecureString to store my Database password, encryption will be handled by AWS KMS, but I wanted to test out as well how to incorporate the SSM store within my template, as there are a few ways you can configure this for secure password storage. For the MasterUsername we the intrinsic function !Ref which returns the value of our RDSDatabaseUsername parameter.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--F4CfXrGH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://imgur.com/EQsPUYL.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--F4CfXrGH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://imgur.com/EQsPUYL.png" alt="Database creation"&gt;&lt;/a&gt;&lt;br&gt;
The next part we will have a look at our EC2 configuration. It is also setup to be within the free tier in AWS. We also use the intrinsic function !Ref to get our KeyName value and also our Security Group for the EC2. In the user data section we use a bootstrap script which will only run once when our EC2 gets created, this is to setup the EC2 the way we need it to run without going in after and setup everything manually. You can basically setup anything on the UserData section to config your EC2 the way you need it to be.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Npgk4CCB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/hetN6pX.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Npgk4CCB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/hetN6pX.png" alt="EC2 Setup"&gt;&lt;/a&gt;&lt;br&gt;
Here we will create our Redis ElastiCache which we will use in our Flask app to use to cache our results. This will also be within the free tier of AWS.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8vVXwX-n--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/aTlCCMw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8vVXwX-n--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/aTlCCMw.png" alt="ElastiCahce create"&gt;&lt;/a&gt;&lt;br&gt;
The next section we just output our Public DNS name of our EC2 and then as well our URL of our RDS PostgreSQL database that we can use.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8g7ICOsb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/QDfFyb8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8g7ICOsb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/QDfFyb8.png" alt="Outputs"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Flask Application
&lt;/h2&gt;

&lt;p&gt;Now that our service on AWS is up and configured, we can edit our Flask app so that we check if the results are cached in our ElastiCache and if it is it will return the cached result, which will return a response quickly and if it doesn't exist in the cache then we query the RDS server and will return a slower response.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---89c2HN8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/7DcROu0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---89c2HN8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/7DcROu0.png" alt="Python Flask App"&gt;&lt;/a&gt;&lt;br&gt;
Here we visit our web app for the first time which would have no results in the ElastiCache and would need to query our RDS database and will return a slower response.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--L2SNRkRp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://imgur.com/HAnN6MW.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--L2SNRkRp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://imgur.com/HAnN6MW.png" alt="Response Slow"&gt;&lt;/a&gt;&lt;br&gt;
Now that result will be saved in our cache, which means if we refresh our page again the next few times we will have a very quick response time and quick page load.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--65lsWFmn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/et6lNwc.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--65lsWFmn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/et6lNwc.jpg" alt="Fast response 1"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--u6JrsJez--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://imgur.com/Zsmf6Op.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--u6JrsJez--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://imgur.com/Zsmf6Op.jpg" alt="Fast response 2"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--40sUkoJI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://imgur.com/UmoIHIM.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--40sUkoJI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://imgur.com/UmoIHIM.jpg" alt="Fast response 3"&gt;&lt;/a&gt;&lt;br&gt;
As you can see our next 3 page loads, loaded much faster than our first time when we loaded the page. The cache TTL is configured to last 20sec(for development purposes), after that it will query our database again and save the new results to cache. &lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;I learned a great deal on this challenge and also read a great deal of the AWS whitepapers and resources for research into CloudFormation and ElastiCache especially. These challenges by ACloudGuru has been a great help in challenging myself to build and use AWS. The resume challenge and then this one was fun in helping me prepare for the AWS Developer Associate exam and looking forward to seeing them bring out more AWS challenges going forward.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>cloud</category>
      <category>python</category>
      <category>elasticache</category>
    </item>
    <item>
      <title>Setup AWS S3 Buckets to Host Your Django Static Files</title>
      <dc:creator>JP Scriven</dc:creator>
      <pubDate>Thu, 18 Mar 2021 05:34:49 +0000</pubDate>
      <link>https://dev.to/cfjps/setup-aws-s3-buckets-to-host-your-django-static-files-5d8e</link>
      <guid>https://dev.to/cfjps/setup-aws-s3-buckets-to-host-your-django-static-files-5d8e</guid>
      <description>&lt;h1&gt;
  
  
  Setup AWS S3 Buckets to Host Your Django Static Files
&lt;/h1&gt;

&lt;p&gt;When thinking about deploying your static files for your Django Web Application, there are a few options to choose from:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Amazon S3&lt;/li&gt;
&lt;li&gt;Apache Liquid&lt;/li&gt;
&lt;li&gt;Azure Storage&lt;/li&gt;
&lt;li&gt;Digital Ocean&lt;/li&gt;
&lt;li&gt;Dropbox&lt;/li&gt;
&lt;li&gt;FTP&lt;/li&gt;
&lt;li&gt;Google Cloud Storage&lt;/li&gt;
&lt;li&gt;SFTP&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Today we will be looking at Amazon S3 and how to configure it to be ready to host your Static Files from Django.
&lt;/h3&gt;

&lt;p&gt;First you will have to go create an AWS account, you can signup for the free tier account and it is a great place to start playing around and testing out your solutions. You will be asked to provide a credit card but you will not be charged until you have used up the free tier resources, so have a look at your billing dashboard and keep an eye out that your usage does not reach your free tier limit.&lt;/p&gt;

&lt;p&gt;Once you are registered and logged into your AWS management console, go to the very top and type in S3 and select the first option, this will take you to the S3 service.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6srLA93X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bhpt8kjbmgagtk0dapow.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6srLA93X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bhpt8kjbmgagtk0dapow.JPG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can click on create a bucket, which will take you to the configuration page. From here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Choose a name for your bucket, this name will have to be unique so you might have to try a few options.&lt;/li&gt;
&lt;li&gt;Select your region you want your S3 bucket to be hosted in.&lt;/li&gt;
&lt;li&gt;Uncheck the option that states, Block all public access.&lt;/li&gt;
&lt;li&gt;The rest we can leave at defaults for now.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now our Bucket is created but will still not be able to work fully with our Django app. We have to create a bucket policy first to allow a public read and getObject to our S3 bucket.&lt;/p&gt;

&lt;p&gt;Now click on you bucket name and then navigate to the permission tab.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yHJgZ9mY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ah38h2r3582xig8lg8xa.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yHJgZ9mY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ah38h2r3582xig8lg8xa.JPG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once there you can scroll down and edit the bucket policy with the following:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HHFvhH2s--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w2t4tuhg99j9gyzm4d4r.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HHFvhH2s--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w2t4tuhg99j9gyzm4d4r.JPG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Save your configuration and now at the top under your bucket name you will see that it states Publicly accessible in red, which means now we are able to access that content in the bucket outside of our AWS environment, which means our Django app will now be able to read the objects within our buckets.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>python</category>
      <category>django</category>
      <category>cloudskills</category>
    </item>
    <item>
      <title>How to pass your AWS Cloud Practitioner Certification</title>
      <dc:creator>JP Scriven</dc:creator>
      <pubDate>Sun, 28 Feb 2021 17:47:31 +0000</pubDate>
      <link>https://dev.to/cfjps/how-to-pass-your-aws-cloud-practitioner-certification-mmk</link>
      <guid>https://dev.to/cfjps/how-to-pass-your-aws-cloud-practitioner-certification-mmk</guid>
      <description>&lt;h1&gt;
  
  
  Why to get your AWS Cloud Practitioner and How to Pass it the first time.
&lt;/h1&gt;

&lt;p&gt;I started looking into AWS about just over a year ago and decided to get AWS Cloud certified. They have made some great services and serverless technologies in the last few years and continuing to do so. They also have some great AI/ML services for you to get started with. I was between going immediately for the AWS Developer/SysOp Associate directly and/or to do the AWS Cloud Practitioner first.&lt;/p&gt;

&lt;p&gt;Think the AWS Cloud Practitioner is great for everyone, even if you are already a cloud engineer. You don't have to study for this exam too long but gives you a great overview of what AWS can offer and as well goes into Billing and Costs and their different plans. You will get more comfortable with AWS and this will help you when you go for your associates certificates. &lt;/p&gt;

&lt;p&gt;If you have been working on AWS for a long time already and now looking to get AWS certified I would suggest then to go directly for the Associate levels instead of the Cloud Practitioner.&lt;/p&gt;

&lt;h2&gt;
  
  
  How long should I study for the AWS Cloud Practitioner?
&lt;/h2&gt;

&lt;p&gt;I would suggest anywhere between 2-4 weeks depending on how you're on time and how many hours you can commit. Try to get real in-depth knowledge of all the services within the &lt;a href="https://aws.amazon.com/certification/certified-cloud-practitioner"&gt;Exam Guideline&lt;/a&gt;&lt;br&gt;
Specially get comfortable with EC2, S3, RDS, DynamoDB, CloudWatch, Billing and Costs, RI vs Savings Plans, Shared Responsibility Model.&lt;/p&gt;

&lt;h2&gt;
  
  
  Resources to use for studying:
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.udemy.com/course/aws-certified-cloud-practitioner-new/learn/"&gt;Udemy&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.udemy.com/course/practice-exams-aws-certified-cloud-practitioner/"&gt;Udemy Practice Test&lt;/a&gt;&lt;br&gt;
&lt;a href="https://aws.amazon.com/certification/certified-cloud-practitioner/"&gt;AWS Whitepapers as listed on the AWS Cloud Practitioner site&lt;/a&gt;&lt;br&gt;
This should be enough to pass the certificate.&lt;/p&gt;

&lt;h2&gt;
  
  
  Build some real-world projects:
&lt;/h2&gt;

&lt;p&gt;I started by building some simple projects on AWS to get a more hands-on experience and then went on building a little bit more complex projects. This was great to answer some questions on the exam you might not have been 100% sure on. Spend allot of time understanding EC2 instances and S3 Buckets, after you get a better understanding of them go over to the database side of AWS which is RDS, DynamoDB, Redshift, EMR etc. To get a high level of the functions of each of these. Spend some time reading the docs on Billing and Costs as this can be tricky to simulate on your account if you do not want to pay a monthly fee for services. The docs and whitepapers are more than enough to pass this exam.&lt;/p&gt;

&lt;p&gt;Good luck!&lt;/p&gt;

</description>
      <category>aws</category>
      <category>cloudskills</category>
      <category>serverless</category>
      <category>100daysofcloud</category>
    </item>
  </channel>
</rss>
