<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><generator uri="https://jekyllrb.com/" version="4.2.2">Jekyll</generator><link href="/feed.xml" rel="self" type="application/atom+xml" /><link href="/" rel="alternate" type="text/html" hreflang="en" /><updated>2022-10-25T17:29:50+00:00</updated><id>/feed.xml</id><title type="html">The Knowledge Seeker</title><subtitle>Static Blog created by AWS CDK, Jekyll &amp; Python</subtitle><author><name>Friendly Neighborhood Engineer</name></author><entry><title type="html">Host your Jekyll Blog with AWS CDK</title><link href="/host-jekyll-aws-cdk-python/" rel="alternate" type="text/html" title="Host your Jekyll Blog with AWS CDK" /><published>2022-10-25T00:00:00+00:00</published><updated>2022-10-25T00:00:00+00:00</updated><id>/host-jekyll-aws-cdk-python</id><content type="html" xml:base="/host-jekyll-aws-cdk-python/"><![CDATA[<p>Are you interested in creating a blog? Jekyll is a static site generator that makes it easy to create a blog and create blog posts using markdown language. Once you create your blog, AWS is a great option for hosting it. AWS is the leading cloud provider in the market today and has all the tools you’d need to host your blog and more. We discussed options for creating a blog in an earlier post; you should check it out <a href="https://blog.cleanslatetg.cloud/start-a-blog/">https://blog.cleanslatetg.cloud/start-a-blog/</a>.</p>

<p>There are several ways that infrastructure can be deployed to AWS, from creating things by hand in the AWS console to using the AWS SDK for your programming language of choice AWS provides multiple options for creating resources. One great option that is a hybrid of IaC and programming is AWS CDK. CDK is an IaC tool that allows users to create and manage infrastructure stacks easily and to define resources using their preferred programming language. We discussed CDK in depth in a previous post. If you’d like to know more about CDK, you should check out the About AWS CDK post: <a href="https://blog.cleanslatetg.cloud/about-aws-cdk/">https://blog.cleanslatetg.cloud/about-aws-cdk/</a>. For this example, we will create our Jekyll static site in AWS using CDK with Python.</p>

<h2 id="tech-stack">Tech Stack</h2>

<h3 id="source-control">Source Control</h3>

<ul>
  <li>GitHub
    <ul>
      <li>Users will need to create and host a repo on GitHub</li>
      <li>The provided example code is hosted on GitHub
        <ul>
          <li><a href="https://github.com/cleanslate-technology-group/indyaws-cdk-python-jekyll-blog">https://github.com/cleanslate-technology-group/indyaws-cdk-python-jekyll-blog</a></li>
        </ul>
      </li>
      <li>GitHub was chosen for this project for several reasons. Users can create free accounts and private repos, a large community of users already using GitHub, and GitHub integrations work well with AWS CodePipeline.</li>
      <li>This application can be hosted using another source control service but be aware that if you choose to use a different source control, you may need to modify the CDK code to use an external CI/CD system other than CodePipeline.</li>
    </ul>
  </li>
</ul>

<h3 id="blog-infrastructure">Blog Infrastructure</h3>

<ul>
  <li>Route 53
    <ul>
      <li>Route 53 is where you will purchase and host the domain for your blog</li>
      <li>The domain will need to be purchased and available before running CDK</li>
    </ul>
  </li>
  <li>Amazon Certificate Manager (ACM)
    <ul>
      <li>AWS provides free SSL certificates that, if integrated with AWS Route 53, can be automatically renewed without any intervention by the user</li>
      <li>ACM will be used to create the necessary SSL certs that will be used for HTTPS traffic to the static site CloudFront distribution.</li>
    </ul>
  </li>
  <li>S3
    <ul>
      <li>Two S3 buckets will be required to host the static site and static media. This could be one single bucket; however, splitting out the media files from the static site makes it a little easier to perform CloudFront invalidations, and some Jekyll templates expect media files to be separate from the site content.</li>
      <li>Static Site files
        <ul>
          <li>Public bucket configured as a static website</li>
        </ul>
      </li>
      <li>Media Files
        <ul>
          <li>A private bucket that uses a CloudFront OAI for access</li>
        </ul>
      </li>
    </ul>
  </li>
  <li>CloudFront
    <ul>
      <li>Distribution for the static site
        <ul>
          <li>Hosts the static Jekyll files</li>
          <li>Uses the Route 53 domains and ACM certs to handle web traffic</li>
        </ul>
      </li>
      <li>Distribution for the media files
        <ul>
          <li>Hosts files with the CloudFront URL</li>
        </ul>
      </li>
    </ul>
  </li>
</ul>

<h3 id="cicd">CI/CD</h3>

<ul>
  <li>CodeStar Connection (GitHub)
    <ul>
      <li>A connection that allows for AWS CodePipeline to connect to the user’s GitHub repo. This connection allows CodePipeline to deploy on check-in to a specified branch.</li>
    </ul>
  </li>
  <li>CodeBuild
    <ul>
      <li>CodeBuild is a build system that allows for the Jekyll site files to be created and to perform the invalidation of a CloudFront distribution. The Jeykll static site files are passed to different stages in CodePipeline as artifacts.</li>
    </ul>
  </li>
  <li>CodePipeline
    <ul>
      <li>A CI/CD Pipeline is used to orchestrate the generation of static blog files, deployment of files to S3 and invalidation of CloudFront resources.</li>
    </ul>
  </li>
</ul>

<h2 id="creating-your-blog">Creating your Blog</h2>

<h3 id="prerequisites">Prerequisites</h3>

<ul>
  <li>Create an AWS account to host the blog</li>
  <li>Purchase a domain using Route 53 for the Blog URL</li>
  <li>Install the AWS CLI</li>
  <li>Create an AWS CLI profile</li>
  <li>Install AWS CDK</li>
  <li>Install Python 3</li>
</ul>

<h3 id="steps">Steps</h3>

<ol>
  <li>Create a private GitHub repository for your blog</li>
  <li>Clone the repo <a href="https://github.com/cleanslate-technology-group/indyaws-cdk-python-jekyll-blog">https://github.com/cleanslate-technology-group/indyaws-cdk-python-jekyll-blog</a> into your repo</li>
  <li>Find a Jekyll theme you’d like to use (if you don’t want to use the theme provided in the cloned repo)
    <ul>
      <li>For more info about Jekyll themes, see the Jekyll docs <a href="https://jekyllrb.com/docs/themes/">https://jekyllrb.com/docs/themes/</a></li>
    </ul>
  </li>
  <li>(Optional) - In the blog folder, delete all of the files and replace them with the desired Jekyll template files</li>
  <li>
    <p>In the infrastructure folder, activate the Python virtual environment</p>

    <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code> <span class="c"># Mac or Linux </span>
 <span class="nb">source</span> .venv/bin/activate
    
 <span class="c"># Windows</span>
 <span class="c"># .venv\Scripts\activate.bat</span>
</code></pre></div>    </div>
  </li>
  <li>
    <p>Install the requirements in the requirements.txt file</p>

    <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code> pip <span class="nb">install</span> <span class="nt">-r</span> requirements.txt
</code></pre></div>    </div>
  </li>
  <li>
    <p>Bootstrap the AWS Account &amp; Region</p>

    <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code> cdk bootstrap <span class="nt">--profile</span> &lt;profileName&gt;
</code></pre></div>    </div>
  </li>
  <li>
    <p>At the root of your repository, create .env file. This file will be used to provide environment variables to the CDK script</p>

    <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code> <span class="nb">touch</span> .env
</code></pre></div>    </div>
  </li>
  <li>
    <p>Populate the .env file with the following values</p>

    <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code> <span class="nv">AWS_ACCOUNT_NUMBER</span><span class="o">=</span>&lt;AWS_ACCOUNT_NUMBER&gt;
 <span class="nv">AWS_REGION</span><span class="o">=</span>&lt;AWS_REGION&gt;
 <span class="nv">DOMAIN_NAME</span><span class="o">=</span>&lt;DOMAIN_NAME&gt;
 <span class="nv">BASE_DOMAIN</span><span class="o">=</span>&lt;BASE_DOMAIN&gt;
 <span class="nv">REPO_OWNER</span><span class="o">=</span>&lt;REPO_OWNER&gt;
 <span class="nv">REPO_NAME</span><span class="o">=</span>&lt;REPO_NAME&gt;
 <span class="nv">REPO_BRANCH</span><span class="o">=</span>&lt;REPO_BRANCH&gt;
</code></pre></div>    </div>

    <ul>
      <li>AWS_ACCOUNT_NUMBER - This is the account number of the AWS account used to host the blog. This will be used to create an environment in CDK</li>
      <li>AWS_REGION - The region in the AWS account that the blog will be deployed to. This will be used to create an environment in CDK</li>
      <li>DOMAIN_NAME - This is the domain name that you want your blog to have (excluding www. The www record will be added automatically). Example: blog.supercoolsite.com</li>
      <li>BASE_DOMAIN - This is the root domain you purchased on Route 53. This should not contain any subdomains. If you are not using subdomains for your blog, then the value of the DOMAIN_NAME and BASE_DOMAIN will be the same. Example: supercoolsite.com</li>
      <li>REPO_OWNER - Name of the owner of your repository. It will either be your GitHub username if you are hosting the repo from your GitHub user or will be the name of the GitHub organization that owns the repository.</li>
      <li>REPO_NAME - Name of your repository</li>
      <li>REPO_BRANCH - Branch that will be used by CI/CD to detect commits and deploy from. I would recommend using the main branch.</li>
    </ul>
  </li>
  <li>Commit and publish the changes to your repository up to your remote main branch</li>
  <li>
    <p>Deploy the CDK stack using the deploy command</p>

    <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>cdk deploy <span class="nt">--profile</span> &lt;profileName&gt;
</code></pre></div>    </div>
  </li>
  <li>After the deployment has finished, login to your AWS accounts management console, then select the region that you deployed the blog into</li>
  <li>Using the search bar at the top of the management console, search for and select “CodePipeline”</li>
  <li>Once in the CodePipline service, you will see the pipeline that was created by CDK for the blog. This is where you can see the progress of your blog deployments in the future. The first run of the CodePipeline will fail because you have to finish configuring the link between your AWS account and GitHub.</li>
  <li>In the left-hand menu, under CodePipeline, select <strong>Setting —&gt; Connections</strong></li>
  <li>On the connections, click on the pending connection named <strong>jekyll-static-site</strong></li>
  <li>Once on the jekyll-static-site connection page, click the button to finish setting up the connection. Walk through the prompts to complete the setup.</li>
  <li>After the connection setup has been completed, you can return to CodePipeline. Select the pipeline for the blog and press the <strong>Release Changes</strong> button to force a new deployment.</li>
  <li>After the deployment has been completed, you should be able to see your blog at the domain name you provided in the .env file.</li>
  <li>Your blog is now published. You can post new articles to your blog by following the steps specified by your Jekyll theme. Once your new article is ready to be published, you can automatically deploy it by simply checking in your changes to the branch specified for the <strong>REPO_BRANCH</strong> variable in the .env file.</li>
</ol>

<p>Happy Blogging!</p>]]></content><author><name>Friendly Neighborhood Engineer</name></author><summary type="html"><![CDATA[Are you interested in creating a blog? Jekyll is a static site generator that makes it easy to create a blog and create blog posts using markdown language. Once you create your blog, AWS is a great option for hosting it. AWS is the leading cloud provider in the market today and has all the tools you’d need to host your blog and more. We discussed options for creating a blog in an earlier post; you should check it out https://blog.cleanslatetg.cloud/start-a-blog/. There are several ways that infrastructure can be deployed to AWS, from creating things by hand in the AWS console to using the AWS SDK for your programming language of choice AWS provides multiple options for creating resources. One great option that is a hybrid of IaC and programming is AWS CDK. CDK is an IaC tool that allows users to create and manage infrastructure stacks easily and to define resources using their preferred programming language. We discussed CDK in depth in a previous post. If you’d like to know more about CDK, you should check out the About AWS CDK post: https://blog.cleanslatetg.cloud/about-aws-cdk/. For this example, we will create our Jekyll static site in AWS using CDK with Python. Tech Stack Source Control GitHub Users will need to create and host a repo on GitHub The provided example code is hosted on GitHub https://github.com/cleanslate-technology-group/indyaws-cdk-python-jekyll-blog GitHub was chosen for this project for several reasons. Users can create free accounts and private repos, a large community of users already using GitHub, and GitHub integrations work well with AWS CodePipeline. This application can be hosted using another source control service but be aware that if you choose to use a different source control, you may need to modify the CDK code to use an external CI/CD system other than CodePipeline. Blog Infrastructure Route 53 Route 53 is where you will purchase and host the domain for your blog The domain will need to be purchased and available before running CDK Amazon Certificate Manager (ACM) AWS provides free SSL certificates that, if integrated with AWS Route 53, can be automatically renewed without any intervention by the user ACM will be used to create the necessary SSL certs that will be used for HTTPS traffic to the static site CloudFront distribution. S3 Two S3 buckets will be required to host the static site and static media. This could be one single bucket; however, splitting out the media files from the static site makes it a little easier to perform CloudFront invalidations, and some Jekyll templates expect media files to be separate from the site content. Static Site files Public bucket configured as a static website Media Files A private bucket that uses a CloudFront OAI for access CloudFront Distribution for the static site Hosts the static Jekyll files Uses the Route 53 domains and ACM certs to handle web traffic Distribution for the media files Hosts files with the CloudFront URL CI/CD CodeStar Connection (GitHub) A connection that allows for AWS CodePipeline to connect to the user’s GitHub repo. This connection allows CodePipeline to deploy on check-in to a specified branch. CodeBuild CodeBuild is a build system that allows for the Jekyll site files to be created and to perform the invalidation of a CloudFront distribution. The Jeykll static site files are passed to different stages in CodePipeline as artifacts. CodePipeline A CI/CD Pipeline is used to orchestrate the generation of static blog files, deployment of files to S3 and invalidation of CloudFront resources. Creating your Blog Prerequisites Create an AWS account to host the blog Purchase a domain using Route 53 for the Blog URL Install the AWS CLI Create an AWS CLI profile Install AWS CDK Install Python 3 Steps Create a private GitHub repository for your blog Clone the repo https://github.com/cleanslate-technology-group/indyaws-cdk-python-jekyll-blog into your repo Find a Jekyll theme you’d like to use (if you don’t want to use the theme provided in the cloned repo) For more info about Jekyll themes, see the Jekyll docs https://jekyllrb.com/docs/themes/ (Optional) - In the blog folder, delete all of the files and replace them with the desired Jekyll template files In the infrastructure folder, activate the Python virtual environment # Mac or Linux source .venv/bin/activate # Windows # .venv\Scripts\activate.bat Install the requirements in the requirements.txt file pip install -r requirements.txt Bootstrap the AWS Account &amp; Region cdk bootstrap --profile &lt;profileName&gt; At the root of your repository, create .env file. This file will be used to provide environment variables to the CDK script touch .env Populate the .env file with the following values AWS_ACCOUNT_NUMBER=&lt;AWS_ACCOUNT_NUMBER&gt; AWS_REGION=&lt;AWS_REGION&gt; DOMAIN_NAME=&lt;DOMAIN_NAME&gt; BASE_DOMAIN=&lt;BASE_DOMAIN&gt; REPO_OWNER=&lt;REPO_OWNER&gt; REPO_NAME=&lt;REPO_NAME&gt; REPO_BRANCH=&lt;REPO_BRANCH&gt; AWS_ACCOUNT_NUMBER - This is the account number of the AWS account used to host the blog. This will be used to create an environment in CDK AWS_REGION - The region in the AWS account that the blog will be deployed to. This will be used to create an environment in CDK DOMAIN_NAME - This is the domain name that you want your blog to have (excluding www. The www record will be added automatically). Example: blog.supercoolsite.com BASE_DOMAIN - This is the root domain you purchased on Route 53. This should not contain any subdomains. If you are not using subdomains for your blog, then the value of the DOMAIN_NAME and BASE_DOMAIN will be the same. Example: supercoolsite.com REPO_OWNER - Name of the owner of your repository. It will either be your GitHub username if you are hosting the repo from your GitHub user or will be the name of the GitHub organization that owns the repository. REPO_NAME - Name of your repository REPO_BRANCH - Branch that will be used by CI/CD to detect commits and deploy from. I would recommend using the main branch. Commit and publish the changes to your repository up to your remote main branch Deploy the CDK stack using the deploy command cdk deploy --profile &lt;profileName&gt; After the deployment has finished, login to your AWS accounts management console, then select the region that you deployed the blog into Using the search bar at the top of the management console, search for and select “CodePipeline” Once in the CodePipline service, you will see the pipeline that was created by CDK for the blog. This is where you can see the progress of your blog deployments in the future. The first run of the CodePipeline will fail because you have to finish configuring the link between your AWS account and GitHub. In the left-hand menu, under CodePipeline, select Setting —&gt; Connections On the connections, click on the pending connection named jekyll-static-site Once on the jekyll-static-site connection page, click the button to finish setting up the connection. Walk through the prompts to complete the setup. After the connection setup has been completed, you can return to CodePipeline. Select the pipeline for the blog and press the Release Changes button to force a new deployment. After the deployment has been completed, you should be able to see your blog at the domain name you provided in the .env file. Your blog is now published. You can post new articles to your blog by following the steps specified by your Jekyll theme. Once your new article is ready to be published, you can automatically deploy it by simply checking in your changes to the branch specified for the REPO_BRANCH variable in the .env file. Happy Blogging!]]></summary></entry><entry><title type="html">What is AWS CDK?</title><link href="/about-aws-cdk/" rel="alternate" type="text/html" title="What is AWS CDK?" /><published>2022-10-24T00:00:00+00:00</published><updated>2022-10-24T00:00:00+00:00</updated><id>/about-aws-cdk</id><content type="html" xml:base="/about-aws-cdk/"><![CDATA[<p>AWS Cloud Development Kit (CDK) is an infrastructure as code (IaC) tool that allows users to define resource stacks using popular programming languages and then deploy those stacks using AWS CloudFormation. CDK is a command line interface (cli) tool that can be downloaded to a user’s development machine or CI/CD systems. The cdk cli tool provides functionality to create new projects, check differences between the deployed stack and the local configuration, synthesize the cdk code into CloudFormation script, and deploy directly from the machine running the tool. CDK is a purpose-built tool built on top of AWS cloudformation to provide enhanced functionality than native CloudFormation. Using fully featured programming languages allows users to create complex logic and conditions that can sometimes be required when creating resource stacks. At runtime, CDK can look up and resolve dynamic values that should not or could not be statically defined.</p>

<h3 id="basic-concepts">Basic Concepts</h3>

<ul>
  <li>Constructs
    <ul>
      <li>Constructs are the building block of CDK.</li>
      <li>Constructs can range from single resources provided by AWS to complicated custom collections of resources created to work together.</li>
      <li>The constructs created by AWS are defined in the AWS Construct Library.</li>
      <li>There are 3 levels of constructs
        <ul>
          <li>L1
            <ul>
              <li>Low-level construct with a 1-to-1 mapping to the corresponding CloudFormation resource</li>
              <li>L1 resource names start with <strong>Cfn</strong></li>
            </ul>
          </li>
          <li>L2
            <ul>
              <li>Higher-level construct that allows for resource creation with enhanced functionality</li>
              <li>Assists with resource creation by providing defaults and boilerplates</li>
            </ul>
          </li>
          <li>L3
            <ul>
              <li>High-level construct that allows for common tasks that require multiple resources to be easily completed</li>
            </ul>
          </li>
        </ul>
      </li>
      <li>For more information about constructs, check out the docs <a href="https://docs.aws.amazon.com/cdk/v2/guide/constructs.html">https://docs.aws.amazon.com/cdk/v2/guide/constructs.html</a></li>
    </ul>
  </li>
  <li>Stacks
    <ul>
      <li>Deployable collection of resources</li>
      <li>CDK stacks get synthesized into CloudFormation stacks using the <strong>cdk synth</strong> command</li>
      <li>Stacks can be nested using the NestedStack construct</li>
      <li>For more information about stacks, check out the docs <a href="https://docs.aws.amazon.com/cdk/v2/guide/stacks.html">https://docs.aws.amazon.com/cdk/v2/guide/stacks.html</a></li>
    </ul>
  </li>
  <li>App
    <ul>
      <li>Container for one or many stacks</li>
      <li>Stacks inside of the same app can reference resources in one another</li>
      <li>Stacks can be deployed individually within an app. This is helpful when defining multiple environments</li>
      <li>For more information about the app, check out the docs <a href="https://docs.aws.amazon.com/cdk/v2/guide/apps.html">https://docs.aws.amazon.com/cdk/v2/guide/apps.html</a></li>
    </ul>
  </li>
  <li>Environments
    <ul>
      <li>Environments specify the AWS account and region that a stack should be associated to</li>
      <li>Environments are not required for stacks; however, if it’s not explicitly provided, then a stack is considered environment-agnostic</li>
      <li>For more information about environments, check out the docs <a href="https://docs.aws.amazon.com/cdk/v2/guide/environments.html">https://docs.aws.amazon.com/cdk/v2/guide/environments.html</a></li>
    </ul>
  </li>
  <li>Bootstrapping
    <ul>
      <li>Bootstrapping is the process of configuring an account and region to use CDK</li>
      <li>Bootstrapping must be run the first time that that CDK is used in an account and environment; however, subsequent cdk runs do not need to bootstrap</li>
      <li>Bootstrapping is account and region-specific, so it must be run in all regions in a particular account you wish to use CDK with</li>
      <li>CDK creates a CloudFormation script in the specific region to deploy the CDKToolkit</li>
      <li>For more information about bootstrapping, check out the docs <a href="https://docs.aws.amazon.com/cdk/v2/guide/bootstrapping.html">https://docs.aws.amazon.com/cdk/v2/guide/bootstrapping.html</a></li>
    </ul>
  </li>
</ul>

<h3 id="commands">Commands</h3>

<p>There are many commands available using the cdk cli tool. To use the cdk tool you must first install it on your machine. Additionally, you will need an AWS account, the aws cli and a profile already set up on the local machine. For information about the aws cli please see the aws cli documentation  <a href="https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-welcome.html">https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-welcome.html</a>. For information about how to install the cdk cli tool and additional information about the following commands, see the cdk documentation <a href="https://docs.aws.amazon.com/cdk/v2/guide/bootstrapping.html">https://docs.aws.amazon.com/cdk/v2/guide/bootstrapping.html</a>.</p>

<ul>
  <li>
    <p>list - Lists the stacks in the App</p>

    <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>  cdk list <span class="nt">--profile</span> &lt;profileName&gt;
</code></pre></div>    </div>
  </li>
  <li>
    <p>synth - Synthesizes cdk code into CloudFormation scripts in the cdk.out folder</p>

    <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>  cdk synth &lt;stackName&gt; <span class="nt">--profile</span> &lt;profileName&gt;
</code></pre></div>    </div>
  </li>
  <li>
    <p>bootstrap - Bootstraps an account and region by using cloudformation to deploy the CDKToolkit</p>

    <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>  cdk bootstrap <span class="nt">--profile</span> &lt;profileName&gt;
</code></pre></div>    </div>
  </li>
  <li>
    <p>deploy - Synthesizes and deploys cdk stacks to AWS</p>

    <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>  cdk deploy &lt;stackName&gt; <span class="nt">--profile</span> &lt;profileName&gt;
</code></pre></div>    </div>
  </li>
  <li>
    <p>destroy - Destroys the specified cdk stack</p>

    <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>  cdk destroy &lt;stackName&gt; <span class="nt">--profile</span> &lt;profileName&gt;
</code></pre></div>    </div>
  </li>
  <li>
    <p>diff - Checks the state of the current configuration against the configuration hosted in the account</p>

    <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>  cdk diff &lt;stackName&gt; <span class="nt">--profile</span> &lt;profileName&gt;
</code></pre></div>    </div>
  </li>
  <li>
    <p>init - Initializes a new cdk app</p>

    <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>  cdk init <span class="nt">--language</span> &lt;languageName&gt; <span class="nt">--profile</span> &lt;profileName&gt;
</code></pre></div>    </div>
  </li>
</ul>

<p>CDK is a powerful tool with a lot more features than have been covered in this post. I highly recommend you read through the docs and work through some examples to get hands-on with CDK. The CDK workshop provides some great examples to get you hands-on with CDK (<a href="https://cdkworkshop.com/">https://cdkworkshop.com/</a>).</p>

<p>CDK is a great option for DevOps engineers who would need more functionality out of their IaC tooling and developers who would feel more comfortable keeping their IaC stacks closer to their code. IaC is extremely important for running applications in the cloud, and AWS CDK is a great option to have in your tech stack.</p>]]></content><author><name>Friendly Neighborhood Engineer</name></author><summary type="html"><![CDATA[AWS Cloud Development Kit (CDK) is an infrastructure as code (IaC) tool that allows users to define resource stacks using popular programming languages and then deploy those stacks using AWS CloudFormation. CDK is a command line interface (cli) tool that can be downloaded to a user’s development machine or CI/CD systems. The cdk cli tool provides functionality to create new projects, check differences between the deployed stack and the local configuration, synthesize the cdk code into CloudFormation script, and deploy directly from the machine running the tool. CDK is a purpose-built tool built on top of AWS cloudformation to provide enhanced functionality than native CloudFormation. Using fully featured programming languages allows users to create complex logic and conditions that can sometimes be required when creating resource stacks. At runtime, CDK can look up and resolve dynamic values that should not or could not be statically defined. Basic Concepts Constructs Constructs are the building block of CDK. Constructs can range from single resources provided by AWS to complicated custom collections of resources created to work together. The constructs created by AWS are defined in the AWS Construct Library. There are 3 levels of constructs L1 Low-level construct with a 1-to-1 mapping to the corresponding CloudFormation resource L1 resource names start with Cfn L2 Higher-level construct that allows for resource creation with enhanced functionality Assists with resource creation by providing defaults and boilerplates L3 High-level construct that allows for common tasks that require multiple resources to be easily completed For more information about constructs, check out the docs https://docs.aws.amazon.com/cdk/v2/guide/constructs.html Stacks Deployable collection of resources CDK stacks get synthesized into CloudFormation stacks using the cdk synth command Stacks can be nested using the NestedStack construct For more information about stacks, check out the docs https://docs.aws.amazon.com/cdk/v2/guide/stacks.html App Container for one or many stacks Stacks inside of the same app can reference resources in one another Stacks can be deployed individually within an app. This is helpful when defining multiple environments For more information about the app, check out the docs https://docs.aws.amazon.com/cdk/v2/guide/apps.html Environments Environments specify the AWS account and region that a stack should be associated to Environments are not required for stacks; however, if it’s not explicitly provided, then a stack is considered environment-agnostic For more information about environments, check out the docs https://docs.aws.amazon.com/cdk/v2/guide/environments.html Bootstrapping Bootstrapping is the process of configuring an account and region to use CDK Bootstrapping must be run the first time that that CDK is used in an account and environment; however, subsequent cdk runs do not need to bootstrap Bootstrapping is account and region-specific, so it must be run in all regions in a particular account you wish to use CDK with CDK creates a CloudFormation script in the specific region to deploy the CDKToolkit For more information about bootstrapping, check out the docs https://docs.aws.amazon.com/cdk/v2/guide/bootstrapping.html Commands There are many commands available using the cdk cli tool. To use the cdk tool you must first install it on your machine. Additionally, you will need an AWS account, the aws cli and a profile already set up on the local machine. For information about the aws cli please see the aws cli documentation https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-welcome.html. For information about how to install the cdk cli tool and additional information about the following commands, see the cdk documentation https://docs.aws.amazon.com/cdk/v2/guide/bootstrapping.html. list - Lists the stacks in the App cdk list --profile &lt;profileName&gt; synth - Synthesizes cdk code into CloudFormation scripts in the cdk.out folder cdk synth &lt;stackName&gt; --profile &lt;profileName&gt; bootstrap - Bootstraps an account and region by using cloudformation to deploy the CDKToolkit cdk bootstrap --profile &lt;profileName&gt; deploy - Synthesizes and deploys cdk stacks to AWS cdk deploy &lt;stackName&gt; --profile &lt;profileName&gt; destroy - Destroys the specified cdk stack cdk destroy &lt;stackName&gt; --profile &lt;profileName&gt; diff - Checks the state of the current configuration against the configuration hosted in the account cdk diff &lt;stackName&gt; --profile &lt;profileName&gt; init - Initializes a new cdk app cdk init --language &lt;languageName&gt; --profile &lt;profileName&gt; CDK is a powerful tool with a lot more features than have been covered in this post. I highly recommend you read through the docs and work through some examples to get hands-on with CDK. The CDK workshop provides some great examples to get you hands-on with CDK (https://cdkworkshop.com/). CDK is a great option for DevOps engineers who would need more functionality out of their IaC tooling and developers who would feel more comfortable keeping their IaC stacks closer to their code. IaC is extremely important for running applications in the cloud, and AWS CDK is a great option to have in your tech stack.]]></summary></entry><entry><title type="html">You should start a blog</title><link href="/start-a-blog/" rel="alternate" type="text/html" title="You should start a blog" /><published>2022-10-23T00:00:00+00:00</published><updated>2022-10-23T00:00:00+00:00</updated><id>/start-a-blog</id><content type="html" xml:base="/start-a-blog/"><![CDATA[<p>Have you ever wanted to share your knowledge or passion with the world? We all have things we are interested in, good, and want to share with the world. We tell our friends, families, and coworkers about these passions, but sometimes we want to reach a bigger audience. A blog is a great way to do that. Blogs can be about anything; it could be about work projects or skills, cooking, or your last knitting project. The point is that you have something to share with the world, and a blog can help you to reach that larger audience.</p>

<p>Like anything new, starting a blog can be tough. It’s hard to know how to get started. At a high level, there are a couple of things to consider when starting a blog, how you want to host it and where you want to host it. Let’s first start with how you want to host it. There are many options for creating a blog. Typically, they fall into the category of an off-the-shelf application such as WordPress, a static-generated site, or a custom site.</p>

<h3 id="how-to-host">How to Host</h3>

<p>Applications such as WordPress can be great options for hosting a blog or other types of sites. WordPress is one of if not the most popular website platforms on the market today. It’s easy to use, has many third-party plugins, and has a strong support community. While WordPress is a strong option, it also comes with some trade-offs. WordPress uses PHP and server-side code to host your website, which means it must be run on a server. Since the site needs to run on a server, there is typically a cost to host the site. Often the cost to host a WordPress site is minimal for smaller sites, but the costs can quickly add up after adding redundancy to the site and extra plugins. The site running on a server also means that it needs to have security patching and maintenance performed on it to ensure the safety of your site. If the WordPress blog is hosted on a platform that manages your site for you, it will typically contribute to your overall cost. Finally, solutions such as WordPress typically offer many features that are overkill for a simple blog. Most blogs don’t need advanced features and, therefore, can make using these tools more complicated for users.</p>

<p>Static site generators are a great option for hosting a simple blog. They are frameworks created using popular programming languages such as Ruby, Javascript, and Go. These frameworks allow users to create content by writing posts in markdown and then generate all of the code required to create the blog. Since there is no server-side code, these sites can be hosted on platforms such as AWS for a very low cost, if not free. Many of these frameworks also have templates that can be used for the site layout and aesthetics. An additional benefit of static sites is the reduced overhead. Since servers are not required to run the sites, you don’t have to worry about patching and maintenance on servers. One of my personal favorite static site generators is Jeykll. It’s an easy-to-use framework written in Ruby. It has many great, free templates available for users, and it has a large community that can help address any issues or questions.</p>

<p>A custom site could also be an option for individuals with the skill and desire to create their site. WordPress and static site generators do not require development skills from users. Users can choose from tons of different templates. The benefit of creating a custom site is that it allows you to create the site exactly the way you want it. It’s a good option if you have the required skills, but for someone like myself who does not come from a front-end development background, the learning curve is more than I’d want to take on for a simple blog.</p>

<h3 id="where-to-host">Where to Host</h3>

<p>Now that you understand how to host your blog better, it’s important to understand where to host it. There are a lot of companies on the market today that host websites. WordPress.com, Squarespace, and Wix are well-known options for off-the-shelf applications. They offer a variety of different options and pricing to choose from. If you would like to use an off-the-shelf solution such as WordPress and don’t want to have to manage the underlying resources yourself, then you should consider one of these providers.</p>

<p>If you would rather host your site yourself, or a static or custom site, then other platforms should be considered. For static sites, platforms such as Netlify can be good options. Netlify and other similar platforms offer entry-level starter tiers for free for users to get their blogs published globally. These platforms require very little to no knowledge of the underlying infrastructure required to host your site, and you can get your site up and running quickly.</p>

<p>Platforms like Netlify can be great for getting started but are very limited in what they offer. To expand your options, you should consider using a cloud platform such as AWS. AWS is a great option for hosting any of the discussed types of blogs. You can host off-the-shelf solutions along with static and custom sites. Using AWS gives you access to a wide array of services for not just your blog but any other applications you may want to use in the future. AWS always only charges for the resources you use, so hosting a static blog globally can be done for a very low cost, if not free.</p>

<p>There is a wide array of options to choose from when hosting a blog. There is not a one size fits all option either. You need to pick the right application and hosting provider to meet your individual needs. Personally, I chose to go with Jeykll and AWS but if WordPress with a managed provider works better for you, then do that. What’s most important at the end of the day is that you are sharing your knowledge and passion with the world.</p>]]></content><author><name>Friendly Neighborhood Engineer</name></author><summary type="html"><![CDATA[Have you ever wanted to share your knowledge or passion with the world? We all have things we are interested in, good, and want to share with the world. We tell our friends, families, and coworkers about these passions, but sometimes we want to reach a bigger audience. A blog is a great way to do that. Blogs can be about anything; it could be about work projects or skills, cooking, or your last knitting project. The point is that you have something to share with the world, and a blog can help you to reach that larger audience. Like anything new, starting a blog can be tough. It’s hard to know how to get started. At a high level, there are a couple of things to consider when starting a blog, how you want to host it and where you want to host it. Let’s first start with how you want to host it. There are many options for creating a blog. Typically, they fall into the category of an off-the-shelf application such as WordPress, a static-generated site, or a custom site. How to Host Applications such as WordPress can be great options for hosting a blog or other types of sites. WordPress is one of if not the most popular website platforms on the market today. It’s easy to use, has many third-party plugins, and has a strong support community. While WordPress is a strong option, it also comes with some trade-offs. WordPress uses PHP and server-side code to host your website, which means it must be run on a server. Since the site needs to run on a server, there is typically a cost to host the site. Often the cost to host a WordPress site is minimal for smaller sites, but the costs can quickly add up after adding redundancy to the site and extra plugins. The site running on a server also means that it needs to have security patching and maintenance performed on it to ensure the safety of your site. If the WordPress blog is hosted on a platform that manages your site for you, it will typically contribute to your overall cost. Finally, solutions such as WordPress typically offer many features that are overkill for a simple blog. Most blogs don’t need advanced features and, therefore, can make using these tools more complicated for users. Static site generators are a great option for hosting a simple blog. They are frameworks created using popular programming languages such as Ruby, Javascript, and Go. These frameworks allow users to create content by writing posts in markdown and then generate all of the code required to create the blog. Since there is no server-side code, these sites can be hosted on platforms such as AWS for a very low cost, if not free. Many of these frameworks also have templates that can be used for the site layout and aesthetics. An additional benefit of static sites is the reduced overhead. Since servers are not required to run the sites, you don’t have to worry about patching and maintenance on servers. One of my personal favorite static site generators is Jeykll. It’s an easy-to-use framework written in Ruby. It has many great, free templates available for users, and it has a large community that can help address any issues or questions. A custom site could also be an option for individuals with the skill and desire to create their site. WordPress and static site generators do not require development skills from users. Users can choose from tons of different templates. The benefit of creating a custom site is that it allows you to create the site exactly the way you want it. It’s a good option if you have the required skills, but for someone like myself who does not come from a front-end development background, the learning curve is more than I’d want to take on for a simple blog. Where to Host Now that you understand how to host your blog better, it’s important to understand where to host it. There are a lot of companies on the market today that host websites. WordPress.com, Squarespace, and Wix are well-known options for off-the-shelf applications. They offer a variety of different options and pricing to choose from. If you would like to use an off-the-shelf solution such as WordPress and don’t want to have to manage the underlying resources yourself, then you should consider one of these providers. If you would rather host your site yourself, or a static or custom site, then other platforms should be considered. For static sites, platforms such as Netlify can be good options. Netlify and other similar platforms offer entry-level starter tiers for free for users to get their blogs published globally. These platforms require very little to no knowledge of the underlying infrastructure required to host your site, and you can get your site up and running quickly. Platforms like Netlify can be great for getting started but are very limited in what they offer. To expand your options, you should consider using a cloud platform such as AWS. AWS is a great option for hosting any of the discussed types of blogs. You can host off-the-shelf solutions along with static and custom sites. Using AWS gives you access to a wide array of services for not just your blog but any other applications you may want to use in the future. AWS always only charges for the resources you use, so hosting a static blog globally can be done for a very low cost, if not free. There is a wide array of options to choose from when hosting a blog. There is not a one size fits all option either. You need to pick the right application and hosting provider to meet your individual needs. Personally, I chose to go with Jeykll and AWS but if WordPress with a managed provider works better for you, then do that. What’s most important at the end of the day is that you are sharing your knowledge and passion with the world.]]></summary></entry></feed>