<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Redpill Linpro</title>
    <description>Redpill Linpro is an established actor in the cloud segment. These pages presents some of our offerings. 
</description>
    <link>/cloud/</link>
    <atom:link href="/cloud/feed.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Tue, 26 Apr 2022 14:04:16 +0000</pubDate>
    <lastBuildDate>Tue, 26 Apr 2022 14:04:16 +0000</lastBuildDate>
    <generator>Jekyll v4.2.1</generator>
    
      <item>
        <title>4 reasons why a container platform is the right way forward</title>
        <description>&lt;p&gt;&lt;b&gt;You might have heard about containers and how they greatly benefit innovation, but why?&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;A container platform, or Platform as a Service (PaaS), is in many ways the wheels of DevOps and Agile delivery. In short, these platforms make it simpler to run and develop applications.&lt;/p&gt;

&lt;p&gt;As the name container itself implies, all the dependencies your microservice needs to run is packed into a standardised carrier. It now has an environment to run and a clearly defined interface in order to communicate with other services.&lt;/p&gt;

&lt;p&gt;Containers also facilitates the growing popular idea of decoupled architecture. The application architecture is split up into smaller microservices which then run in separate containers. Each and every container is then run on top of a container platform, and orchestrated automatically by services such as Kubernetes and OpenShift. This decoupled architecture is the modern way of Software Engineering.&lt;/p&gt;

&lt;p&gt;Below I have collected the top four business benefits and opportunities for moving over to a container-platform:&lt;/p&gt;

&lt;h4 id=&quot;1-easy-to-get-started-with&quot;&gt;1. Easy to get started with&lt;/h4&gt;
&lt;p&gt;Whether you struggle with a monolithic legacy application, or are just starting up, a container platforms is relatively easy to get aboard with. All major cloud providers offer their own container Platform as a Service. Meaning, in all simplicity ,you only need to bring your code in order to start running your applications.&lt;/p&gt;

&lt;p&gt;From a startup’s point of view, it is essentially plug and play. But even companies struggling with legacy infrastructure can make fast use of PaaS platforms, by shaving off and rewriting smaller parts from a monolithic application. Gradually migrating to a segmented container platform.&lt;/p&gt;

&lt;h4 id=&quot;2-higher-productivity&quot;&gt;2. Higher productivity&lt;/h4&gt;
&lt;p&gt;As noted earlier, containers drive DevOps and Agile delivery. Splitting up your architecture into smaller services, makes it easier to maintain, develop, debug and add features to your code. Setting up a container platform with Continuous Integration and Continuous Deployment (CI/CD) in addition, will provide a self-service platform. Then you will no longer depend on operations provisioning the code on test, staging or production platforms. CI/CD lets developers test the code and deploy it themselves, but also roll it back if there is a problem and then roll out again after a fix.&lt;/p&gt;

&lt;p&gt;Smaller, faster releases result in faster development cycles and ends in higher productivity.&lt;/p&gt;

&lt;h4 id=&quot;3-more-time-to-innovate&quot;&gt;3. More time to innovate&lt;/h4&gt;
&lt;p&gt;Companies undoubtedly need to evolve and innovate fast to keep their customers continuously using their services. However, normally far too many IT resources are bundled up in maintaining and managing legacy infrastructure. This means less time to focus on improving and on innovation.&lt;/p&gt;

&lt;p&gt;Container-platforms can be automated all the way from deployment, scaling and up to provisioning of compute resources. By running applications on such a platform, developers can now focus more on making new features and building new apps and less on provisioning.&lt;/p&gt;

&lt;p&gt;Operations can focus more on operating a stable platform and will deal less with provisioning of code.&lt;/p&gt;

&lt;h4 id=&quot;4-faster-time-to-market&quot;&gt;4. Faster time to market&lt;/h4&gt;
&lt;p&gt;From a brilliant whiteboard idea to market release, companies struggling with legacy infrastructure will necessary stumble upon some obstacles on the way. What should be a quick release for hitting that new market trend, results in delays and sometimes no release at all. This while competition is already out with their brand new solutions, helping themselves to new customers.&lt;/p&gt;

&lt;p&gt;Having applications running as microservices, you can quickly change and switch entire parts of you application stack without affecting other services. A container is as easy to start as it is to kill off and replace, having a split architecture through container platforms will therefore accelerate faster deployment to your customers.&lt;/p&gt;

&lt;p&gt;In summary, there is no doubt that containers and PaaS is the way forward, and as all major Cloud Providers have container platforms as a service, making it easier to move over to PaaS one microservice at a time.Redpill Linpro can help you with your PaaS strategy, both with choosing the correct platform, planning, migration and optimisation.&lt;/p&gt;

&lt;h4 id=&quot;more-to-explore&quot;&gt;More to explore&lt;/h4&gt;
&lt;p&gt;We have expertise in container platforms on both AWS and Open Source, and offer our own &lt;a href=&quot;https://www.redpill-linpro.com/cloud/rlnc/container.html&quot;&gt;Redpill Linpro Nordic Cloud Container Platform&lt;/a&gt; with guaranteed data storage in Norway.&lt;/p&gt;

&lt;!-- Contact --&gt;
&lt;div class=&quot;two spacing&quot;&gt;&lt;/div&gt;
&lt;div class=&quot;row&quot;&gt;
  &lt;div class=&quot;medium-12 medium-centered columns&quot;&gt;
    






&lt;div class=&quot;rl-contact-box-wrapper&quot;&gt;


  &lt;div class=&quot;rl-contact-box content row&quot;&gt;
    &lt;div class=&quot;small-1 column&quot;&gt;&amp;nbsp;&lt;/div&gt;
    
    &lt;div class=&quot;small-1 medium-4 column&quot;&gt;
      &lt;div class=&quot;rl-contact-image&quot;&gt;
        
        
&lt;div class=&quot;rl-image-ratio-block&quot; style=&quot;background-image:url(/cloud/images/employees/mia.jpg)&quot;&gt;&lt;/div&gt;

      &lt;/div&gt;
    &lt;/div&gt;
    
    &lt;div class=&quot;small-10 medium-6 column end&quot;&gt;
      &lt;div class=&quot;rl-contact-text&quot;&gt;
        &lt;h2 class=&quot;rl-contact-heading&quot;&gt;Contact&lt;/h2&gt;
        &lt;p&gt;&lt;span class=&quot;rl-contact-name&quot;&gt;Mia Ryan&lt;/span&gt;&lt;br /&gt;
           &lt;span class=&quot;rl-contact-title&quot;&gt;Sales Advisor at Redpill&amp;nbsp;Linpro&lt;/span&gt;&lt;br /&gt;
           &lt;a class=&quot;button rl-contact-link&quot; href=&quot;/cloud/contact.html&quot;&gt;Contact&lt;/a&gt;&lt;br /&gt;
        &lt;/p&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;two spacing&quot;&gt;&lt;/div&gt;




  &lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;two spacing&quot;&gt;&lt;/div&gt;
</description>
        <pubDate>Tue, 13 Apr 2021 00:00:00 +0000</pubDate>
        <link>/cloud/blog/2021/04/13/4-reasons-why-a-container-platform-is-the-right-way-forward.html</link>
        <guid isPermaLink="true">/cloud/blog/2021/04/13/4-reasons-why-a-container-platform-is-the-right-way-forward.html</guid>
        
        
        <category>Cloud</category>
        
      </item>
    
      <item>
        <title>Containers 101</title>
        <description>&lt;p&gt;&lt;b&gt;Container driven development is catching on like wildfire, and for good reasons. In the age of digital transformation, time to market is becoming a competitive edge impossible to ignore. To be able to speed up the software development and deployment, monolithic application development sooner or later will be extinct.&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;Other factors that drive the world towards containers are microservice architecture, continuous integration and delivery (CI/CD), DevOps bringing dev and ops closer together and cloud computing with multi infrastructure portability. More on that later, in this text we’ll focus on the container technology basics.&lt;/p&gt;

&lt;h4 id=&quot;the-basics&quot;&gt;The basics&lt;/h4&gt;
&lt;p&gt;In a traditional application world, an application requires code, runtime, system tools, system libraries and settings. In a container, the application code is encapsulated together with all those building blocks it needs to run.&lt;/p&gt;

&lt;p&gt;Why would you choose to do that?&lt;/p&gt;

&lt;p&gt;Mostly because presenting a consistent software environment as a container makes it a lot easier for the application to go from the developer’s desktop to testing to production deployment.&lt;/p&gt;

&lt;p&gt;There is simply no more need to make sure all libraries and settings in production are corresponding to the ones used in development, dramatically reducing the time and effort required for releasing new code.&lt;/p&gt;

&lt;p&gt;Containers also isolate the application from its surroundings, both reducing conflicts between different applications on the same infrastructure and minimizing application issues to a single container instead of the entire infrastructure.&lt;/p&gt;

&lt;p&gt;When updating the application code, a new container is build to replace the old container. When deploying the new container into production, the old container is simply thrown away. This is a good reason why a container should be stateless, that is; no state or data should be stored within it, as the data would be lost when the container is replaced.&lt;/p&gt;

&lt;h4 id=&quot;container-architecture&quot;&gt;Container architecture&lt;/h4&gt;
&lt;p&gt;Container technology isn’t really new; Linux containers (LXC) have been around for about 10 years. Yet first when a standard way to divide applications into containers was established, a major breakthrough was made.&lt;/p&gt;

&lt;p&gt;There are other suppliers involved, but no one disputes that Docker has led the charge and sits at the heart of the market. Docker revolutionized container adaption by providing a container standard and thereby making it easy for developers to build and run their containers.&lt;/p&gt;

&lt;p&gt;By fundamentally changing the way developers build applications, Docker became one of the most popular open source projects in history.&lt;/p&gt;

&lt;p&gt;As well as holding the container standard, Docker also provides operations to start, stop and build containers.&lt;/p&gt;

&lt;h4 id=&quot;container-orchestration&quot;&gt;Container orchestration&lt;/h4&gt;
&lt;p&gt;Unless handled with care, running containers includes a risk of ending up herding cats. To avoid this, software has been written to handle containers beyond starting and stopping. The ability to automatecontainer management is one of the prime benefits of container based applications.&lt;/p&gt;

&lt;p&gt;This brings on container orchestration. Orchestration is where much of the current innovation lies in the container technology ecosystem and where the competition is heating up most.&lt;/p&gt;

&lt;p&gt;Tools like Docker Compose provide basic support for defining simple multi-container applications. However, full orchestration involves more complicated tasks like scheduling of how and when containers should run, continuous deployment (CD), cluster management and provisioning of extra resources, possibly across multiple hosts.&lt;/p&gt;

&lt;p&gt;Kubernetes, backed by Google, is currently the most popular container orchestration tool. Other container orchestration tools include Docker Swarm and Apache Mesos.&lt;/p&gt;

&lt;h4 id=&quot;container-platforms-platform-as-a-service-paas&quot;&gt;Container platforms: Platform as a Service (PaaS)&lt;/h4&gt;
&lt;p&gt;Container based applications comes with the ability to run on a variety of different physical and virtual machines, in the cloud or not. PaaS is a general term for a cloud computing service that provides a platform for users to easily develop, run, and manage applications in a cloud.&lt;/p&gt;

&lt;p&gt;When offering PaaS, Cloud providers offers infrastructure, servers, networking, storage, database, operating system (OS), security, runtime environment and infrastructure monitoring all in one. Abstracting all those lower infrastructure layers, developers only needs to bring their containers and application data.&lt;/p&gt;

&lt;p&gt;PaaS simply enables developers to concentrate on what they do best; coding, as well as empowering them to manage their application without regards to lower infrastructure.&lt;/p&gt;

&lt;p&gt;Say you want to move an application from one cloud platform to another, or implement automatic scaling and restarting applications. PaaS solutions offers flexibility, workload management advantages and provides the ability to easily set up fault-tolerant systems.&lt;/p&gt;

&lt;p&gt;Well known PaaS includes AWS Elastic Beanstalk, Google App Engine and RedHat OpenShift.&lt;/p&gt;

&lt;h4 id=&quot;further-reading&quot;&gt;Further reading&lt;/h4&gt;
&lt;p&gt;For further reading on the business benefits of containers, check out my colleague Mia Ryan’s &lt;a href=&quot;https://www.redpill-linpro.com/cloud/blog/2021/04/13/4-reasons-why-a-container-platform-is-the-right-way-forward.html&quot;&gt;blog post&lt;/a&gt;.&lt;/p&gt;

&lt;!-- Contact --&gt;
&lt;div class=&quot;two spacing&quot;&gt;&lt;/div&gt;
&lt;div class=&quot;row&quot;&gt;
  &lt;div class=&quot;medium-12 medium-centered columns&quot;&gt;
    






&lt;div class=&quot;rl-contact-box-wrapper&quot;&gt;


  &lt;div class=&quot;rl-contact-box content row&quot;&gt;
    &lt;div class=&quot;small-1 column&quot;&gt;&amp;nbsp;&lt;/div&gt;
    
    &lt;div class=&quot;small-1 medium-4 column&quot;&gt;
      &lt;div class=&quot;rl-contact-image&quot;&gt;
        
        
&lt;div class=&quot;rl-image-ratio-block&quot; style=&quot;background-image:url(/cloud/images/employees/margretm.jpg)&quot;&gt;&lt;/div&gt;

      &lt;/div&gt;
    &lt;/div&gt;
    
    &lt;div class=&quot;small-10 medium-6 column end&quot;&gt;
      &lt;div class=&quot;rl-contact-text&quot;&gt;
        &lt;h2 class=&quot;rl-contact-heading&quot;&gt;Contact&lt;/h2&gt;
        &lt;p&gt;&lt;span class=&quot;rl-contact-name&quot;&gt;Margrethe Monsen&lt;/span&gt;&lt;br /&gt;
           &lt;span class=&quot;rl-contact-title&quot;&gt;Managing Director at Redpill&amp;nbsp;Linpro&lt;/span&gt;&lt;br /&gt;
           &lt;a class=&quot;button rl-contact-link&quot; href=&quot;/cloud/contact.html&quot;&gt;Contact&lt;/a&gt;&lt;br /&gt;
        &lt;/p&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;two spacing&quot;&gt;&lt;/div&gt;




  &lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;two spacing&quot;&gt;&lt;/div&gt;
</description>
        <pubDate>Mon, 12 Apr 2021 00:00:00 +0000</pubDate>
        <link>/cloud/blog/2021/04/12/Containers-101.html</link>
        <guid isPermaLink="true">/cloud/blog/2021/04/12/Containers-101.html</guid>
        
        
        <category>Cloud</category>
        
      </item>
    
      <item>
        <title>Finalizing the VPC template</title>
        <description>&lt;p&gt;&lt;b&gt;I want to wrap up the VPC template from the  previous blog entry &lt;a href=&quot;https://www.redpill-linpro.com/techblog/2020/11/27/cloudformation-vpc2.html&quot;&gt;“Moving
forward with Cloudformation templates”&lt;/a&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;What we ended up with there was a VPC with a Private and a Public Subnet in 3
Availability Zones.&lt;/p&gt;

&lt;p&gt;Now I want to start to use the
&lt;a href=&quot;https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/outputs-section-structure.html&quot;&gt;Outputs&lt;/a&gt;
section of the template.&lt;/p&gt;

&lt;p&gt;And when that has been introduced, I want to use &lt;a href=&quot;https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-nested-stacks.html&quot;&gt;Nested Stacks&lt;/a&gt;&lt;/p&gt;

&lt;h1 id=&quot;why-outputs&quot;&gt;Why Outputs?&lt;/h1&gt;

&lt;p&gt;When we create a VPC with the template from the last blog, we get a VPC, but
information about that stack is lost on us. You need to query for all VPC to
find the VPC, need to search for subnets to be able to use them.&lt;/p&gt;

&lt;p&gt;With Outputs, you can query the Stack it self to get information about the
resources it creates.&lt;/p&gt;

&lt;h2 id=&quot;real-example&quot;&gt;Real example&lt;/h2&gt;

&lt;p&gt;I have the template from last blog stored in a file called &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;blogvpc.yaml&lt;/code&gt;,
then I create a stack with it.&lt;/p&gt;
&lt;div class=&quot;language-console highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;jonas@pigz ~/bløgg$&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;aws &lt;span class=&quot;nt&quot;&gt;--profile&lt;/span&gt; blogg cloudformation create-stack &lt;span class=&quot;nt&quot;&gt;--stack-name&lt;/span&gt; forblog &lt;span class=&quot;nt&quot;&gt;--template-body&lt;/span&gt; file://blogvpc.yaml
&lt;span class=&quot;go&quot;&gt;{
  &quot;StackId&quot;:&quot;arn:aws:cloudformation:eu-west-2:123NaN123201:stack/forblog/ef5b8d00-91fd-11eb-b513-06c721e1f154&quot;
}
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;When it was done, I could see the result:&lt;/p&gt;

&lt;div class=&quot;language-console highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;jonas@pigz ~/bløgg$&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;aws &lt;span class=&quot;nt&quot;&gt;--profile&lt;/span&gt; blogg cloudformation describe-stacks &lt;span class=&quot;nt&quot;&gt;--stack-name&lt;/span&gt; forblog  &lt;span class=&quot;nt&quot;&gt;--template-body&lt;/span&gt; file://blogvpc.yaml
&lt;span class=&quot;go&quot;&gt;{
    &quot;Stacks&quot;: [
        {
            &quot;StackId&quot;: &quot;arn:aws:cloudformation:eu-west-2:123NaN123201:stack/forblog/ef5b8d00-91fd-11eb-b513-06c721e1f154&quot;,
            &quot;StackName&quot;: &quot;forblog&quot;,
            &quot;Description&quot;: &quot;This is an attempt to create a VPC in a Cloudformation stack&quot;,
            &quot;CreationTime&quot;: &quot;2021-03-31T08:48:59.519Z&quot;,
            &quot;RollbackConfiguration&quot;: {},
            &quot;StackStatus&quot;: &quot;CREATE_COMPLETE&quot;,
            &quot;DisableRollback&quot;: false,
            &quot;NotificationARNs&quot;: [],
            &quot;Tags&quot;: [],
            &quot;EnableTerminationProtection&quot;: false,
            &quot;DriftInformation&quot;: {
                &quot;StackDriftStatus&quot;: &quot;NOT_CHECKED&quot;
            }
        }
    ]
}
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;As you can see there is not a lot of useful information in this output.&lt;/p&gt;

&lt;p&gt;Yes, I can run some other commands, for digging into the Stack.&lt;/p&gt;

&lt;div class=&quot;language-console highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;jonas@pigz ~/bløgg$&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;aws &lt;span class=&quot;nt&quot;&gt;--profile&lt;/span&gt; blogg cloudformation describe-stack-resources &lt;span class=&quot;nt&quot;&gt;--stack-name&lt;/span&gt; forblog
&lt;span class=&quot;go&quot;&gt;{
    &quot;StackResources&quot;: [
        {
            &quot;StackName&quot;: &quot;forblog&quot;,
            &quot;StackId&quot;: &quot;arn:aws:cloudformation:eu-west-2:123NaN123201:stack/forblog/ef5b8d00-91fd-11eb-b513-06c721e1f154&quot;,
            &quot;LogicalResourceId&quot;: &quot;GatewayToInternet&quot;,
            &quot;PhysicalResourceId&quot;: &quot;forbl-Gatew-1ILE8XW7D3OMG&quot;,
            &quot;ResourceType&quot;: &quot;AWS::EC2::VPCGatewayAttachment&quot;,
            &quot;Timestamp&quot;: &quot;2021-03-31T08:49:36.433Z&quot;,
            &quot;ResourceStatus&quot;: &quot;CREATE_COMPLETE&quot;,
            &quot;DriftInformation&quot;: {
                &quot;StackResourceDriftStatus&quot;: &quot;NOT_CHECKED&quot;
            }
        },
&lt;/span&gt;&lt;span class=&quot;c&quot;&gt;....
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;But that gives me &lt;em&gt;all&lt;/em&gt; the resources, and is tedious to format queries to
grep out the parts that I need, most of the resources are elements I do not
want to know about.&lt;/p&gt;

&lt;h3 id=&quot;adding-outputs&quot;&gt;Adding Outputs&lt;/h3&gt;

&lt;p&gt;I write plural of Outputs as that is the name of the section in
Cloudformation, but we start with adding only 1.&lt;/p&gt;

&lt;p&gt;To our existing template, we add the following at the end.&lt;/p&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;na&quot;&gt;Outputs&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;VPCid&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Description&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;The VPCid&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Value&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;VPC&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And then run an update of the stack&lt;/p&gt;

&lt;div class=&quot;language-console highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;jonas@pigz ~/bløgg$&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;aws &lt;span class=&quot;nt&quot;&gt;--profile&lt;/span&gt; blogg cloudformation update-stack &lt;span class=&quot;nt&quot;&gt;--stack-name&lt;/span&gt; forblog &lt;span class=&quot;nt&quot;&gt;--template-body&lt;/span&gt; file://blogvpc.yaml
&lt;span class=&quot;go&quot;&gt;{
  &quot;StackId&quot;:&quot;arn:aws:cloudformation:eu-west-2:123NaN123201:stack/forblog/ef5b8d00-91fd-11eb-b513-06c721e1f154&quot;
}
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Then I can check for the new description&lt;/p&gt;

&lt;div class=&quot;language-console highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;jonas@pigz ~/bløgg$&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;aws &lt;span class=&quot;nt&quot;&gt;--profile&lt;/span&gt; blogg cloudformation describe-stacks &lt;span class=&quot;nt&quot;&gt;--stack-name&lt;/span&gt; forblog
&lt;span class=&quot;go&quot;&gt;{
    &quot;Stacks&quot;: [
        {
            &quot;StackId&quot;: &quot;arn:aws:cloudformation:eu-west-2:123NaN123201:stack/forblog/ef5b8d00-91fd-11eb-b513-06c721e1f154&quot;,
            &quot;StackName&quot;: &quot;forblog&quot;,
            &quot;Description&quot;: &quot;This is an attempt to create a VPC in a Cloudformation stack&quot;,
            &quot;CreationTime&quot;: &quot;2021-03-31T08:48:59.519Z&quot;,
            &quot;LastUpdatedTime&quot;: &quot;2021-03-31T09:20:15.381Z&quot;,
            &quot;RollbackConfiguration&quot;: {},
            &quot;StackStatus&quot;: &quot;UPDATE_COMPLETE&quot;,
            &quot;DisableRollback&quot;: false,
            &quot;NotificationARNs&quot;: [],
            &quot;Outputs&quot;: [
                {
                    &quot;OutputKey&quot;: &quot;VPCid&quot;,
                    &quot;OutputValue&quot;: &quot;vpc-085967d5f0b867c95&quot;,
                    &quot;Description&quot;: &quot;The VPCid&quot;
                }
            ],
            &quot;Tags&quot;: [],
            &quot;EnableTerminationProtection&quot;: false,
            &quot;DriftInformation&quot;: {
                &quot;StackDriftStatus&quot;: &quot;NOT_CHECKED&quot;
            }
        }
    ]
}
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Only the parts we choose to output will be visible there. But now we will turn
the output to something useful.&lt;/p&gt;

&lt;h3 id=&quot;adding-export&quot;&gt;Adding export&lt;/h3&gt;

&lt;p&gt;We can export values from a stack to use it in another stack, we just need to
add an &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Export:&lt;/code&gt; part to the Outputs statements we want to export.&lt;/p&gt;

&lt;p&gt;But as we do not get that far on VPCid alone we add export for a Private
Subnet as well.&lt;/p&gt;

&lt;p&gt;So I change the Outputs part to this:&lt;/p&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;na&quot;&gt;Outputs&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;VPCid&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Description&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;The VPCid&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Value&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;VPC&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Export&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;Name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;BlogVpc&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;PrivateSubnet0&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Description&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;A subnet&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Value&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;PrivateSubnet0&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Export&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;Name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;PrivateSubnet0&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;and update the stack, and then check for the description I get:&lt;/p&gt;

&lt;div class=&quot;language-console highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;jonas@pigz ~/bløgg$&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;aws &lt;span class=&quot;nt&quot;&gt;--profile&lt;/span&gt; blogg cloudformation describe-stacks &lt;span class=&quot;nt&quot;&gt;--stack-name&lt;/span&gt; forblog
&lt;span class=&quot;go&quot;&gt;{
    &quot;Stacks&quot;: [
        {
            &quot;StackId&quot;: &quot;arn:aws:cloudformation:eu-west-2:123NaN123201:stack/forblog/ef5b8d00-91fd-11eb-b513-06c721e1f154&quot;,
            &quot;StackName&quot;: &quot;forblog&quot;,
            &quot;Description&quot;: &quot;This is an attempt to create a VPC in a Cloudformation stack&quot;,
            &quot;CreationTime&quot;: &quot;2021-03-31T08:48:59.519Z&quot;,
            &quot;LastUpdatedTime&quot;: &quot;2021-03-31T10:47:07.379Z&quot;,
            &quot;RollbackConfiguration&quot;: {},
            &quot;StackStatus&quot;: &quot;UPDATE_COMPLETE&quot;,
            &quot;DisableRollback&quot;: false,
            &quot;NotificationARNs&quot;: [],
            &quot;Outputs&quot;: [
                {
                    &quot;OutputKey&quot;: &quot;PrivateSubnet0&quot;,
                    &quot;OutputValue&quot;: &quot;subnet-0bd91e942916edd41&quot;,
                    &quot;Description&quot;: &quot;A subnet&quot;,
                    &quot;ExportName&quot;: &quot;PrivateSubnet0&quot;
                },
                {
                    &quot;OutputKey&quot;: &quot;VPCid&quot;,
                    &quot;OutputValue&quot;: &quot;vpc-085967d5f0b867c95&quot;,
                    &quot;Description&quot;: &quot;The VPCid&quot;,
                    &quot;ExportName&quot;: &quot;BlogVpc&quot;
                }
            ],
            &quot;Tags&quot;: [],
            &quot;EnableTerminationProtection&quot;: false,
            &quot;DriftInformation&quot;: {
                &quot;StackDriftStatus&quot;: &quot;NOT_CHECKED&quot;
            }
        }
    ]
}
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;This change does not look like something to write home about, but actually,
now we can use the resources from this stack in another.&lt;/p&gt;

&lt;h3 id=&quot;using-the-export-in-another-template&quot;&gt;Using the export in another template&lt;/h3&gt;

&lt;p&gt;Let us create a template called &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;avm.yaml&lt;/code&gt; that starts an EC2 instance in our
VPC.&lt;/p&gt;
&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nn&quot;&gt;---&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;Description&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;A silly template for using Export&lt;/span&gt;

&lt;span class=&quot;na&quot;&gt;Parameters&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;AMI&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::Image::Id&lt;/span&gt;

&lt;span class=&quot;na&quot;&gt;Resources&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;TheVM&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::Instance&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;ImageId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AMI&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;InstanceType&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;t3.micro&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;SubnetId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;s&quot;&gt;Fn::ImportValue: PrivateSubnet0&lt;/span&gt;

&lt;span class=&quot;na&quot;&gt;Outputs&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;TheVMid&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Description&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;ID of the VM&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Value&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;TheVM&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;The newest AMI for Ubuntu 18.04 in eu-west-2 is, when I write this,
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ami-066213f162acbccdc&lt;/code&gt; so I use that when I create the stack:&lt;/p&gt;

&lt;div class=&quot;language-console highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;jonas@pigz ~/bløgg$&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;aws &lt;span class=&quot;nt&quot;&gt;--profile&lt;/span&gt; blogg cloudformation create-stack &lt;span class=&quot;nt&quot;&gt;--stack-name&lt;/span&gt; thevm &lt;span class=&quot;nt&quot;&gt;--template-body&lt;/span&gt; file://avm.yaml &lt;span class=&quot;nt&quot;&gt;--parameters&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;ParameterKey&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;AMI,ParameterValue&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;ami-066213f162acbccdc
&lt;span class=&quot;go&quot;&gt;{
  &quot;StackId&quot;: &quot;arn:aws:cloudformation:eu-west-2:123NaN123201:stack/thevm/233c51a0-921b-11eb-b3b7-024fe784c338&quot;
}
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;And then when we get description of the stack, we get the ID of an instance.&lt;/p&gt;

&lt;div class=&quot;language-console highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;jonas@pigz ~/bløgg$&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;aws &lt;span class=&quot;nt&quot;&gt;--profile&lt;/span&gt; blogg cloudformation describe-stacks &lt;span class=&quot;nt&quot;&gt;--stack-name&lt;/span&gt; thevm
&lt;span class=&quot;go&quot;&gt;{
    &quot;Stacks&quot;: [
        {
            &quot;StackId&quot;: &quot;arn:aws:cloudformation:eu-west-2:123NaN123201:stack/thevm/233c51a0-921b-11eb-b3b7-024fe784c338&quot;,
            &quot;StackName&quot;: &quot;thevm&quot;,
            &quot;Description&quot;: &quot;A silly template for using Export&quot;,
            &quot;Parameters&quot;: [
                {
                    &quot;ParameterKey&quot;: &quot;AMI&quot;,
                    &quot;ParameterValue&quot;: &quot;ami-066213f162acbccdc&quot;
                }
            ],
            &quot;CreationTime&quot;: &quot;2021-03-31T12:18:01.855Z&quot;,
            &quot;RollbackConfiguration&quot;: {},
            &quot;StackStatus&quot;: &quot;CREATE_COMPLETE&quot;,
            &quot;DisableRollback&quot;: false,
            &quot;NotificationARNs&quot;: [],
            &quot;Outputs&quot;: [
                {
                    &quot;OutputKey&quot;: &quot;TheVMid&quot;,
                    &quot;OutputValue&quot;: &quot;i-0c6c58bb36a3e4afc&quot;,
                    &quot;Description&quot;: &quot;ID of the VM&quot;
                }
            ],
            &quot;Tags&quot;: [],
            &quot;EnableTerminationProtection&quot;: false,
            &quot;DriftInformation&quot;: {
                &quot;StackDriftStatus&quot;: &quot;NOT_CHECKED&quot;
            }
        }
    ]
}
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h3 id=&quot;cleanup&quot;&gt;Cleanup&lt;/h3&gt;
&lt;p&gt;And then a cleanup:&lt;/p&gt;
&lt;div class=&quot;language-console highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;jonas@pigz ~/bløgg$&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;aws &lt;span class=&quot;nt&quot;&gt;--profile&lt;/span&gt; blogg cloudformation delete-stack &lt;span class=&quot;nt&quot;&gt;--stack-name&lt;/span&gt; thevm
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Checking for if the stack has been removed:&lt;/p&gt;
&lt;div class=&quot;language-console highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;jonas@pigz ~/bløgg$&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;aws &lt;span class=&quot;nt&quot;&gt;--profile&lt;/span&gt; blogg cloudformation describe-stacks &lt;span class=&quot;nt&quot;&gt;--stack-name&lt;/span&gt; thevm
&lt;span class=&quot;go&quot;&gt;
An error occurred (ValidationError) when calling the DescribeStacks operation: Stack with id thevm does not exist
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;It is gone, so now I remove the VPC stack.&lt;/p&gt;
&lt;div class=&quot;language-console highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;jonas@pigz ~/bløgg$&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;aws &lt;span class=&quot;nt&quot;&gt;--profile&lt;/span&gt; blogg cloudformation delete-stack &lt;span class=&quot;nt&quot;&gt;--stack-name&lt;/span&gt; forblog
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;things-to-note-about-exports&quot;&gt;Things to note about Exports&lt;/h2&gt;

&lt;h3 id=&quot;uniqueness-of-the-name&quot;&gt;Uniqueness of the Name&lt;/h3&gt;
&lt;p&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ExportName&lt;/code&gt; is unique in a region for your account. I find it useful to
prefix the exports with a value so two stacks from the same template can
coexist in the same region. So you have the same templates for stage
environments as the production environments.&lt;/p&gt;

&lt;p&gt;More about this below.&lt;/p&gt;

&lt;h3 id=&quot;locking-of-resources&quot;&gt;Locking of resources&lt;/h3&gt;

&lt;p&gt;Resources that you export can not be replaced or deleted. Cloudformation will
protest if you try to change your stack with that result. See
&lt;a href=&quot;https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-stack-exports.html&quot;&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;h1 id=&quot;nesting&quot;&gt;Nesting&lt;/h1&gt;
&lt;p&gt;That was the Export part, let us look at Nesting next.&lt;/p&gt;

&lt;h2 id=&quot;why-nesting&quot;&gt;Why nesting&lt;/h2&gt;

&lt;p&gt;With nesting, you can start stacks from a parent stack. Doing that allows you
to reuse templates. I will now rewrite the VPC template from previous blog to
use that. And by that reduce the repetition significantly.&lt;/p&gt;

&lt;p&gt;The nested stack templates must exist in S3 and be readable for the account
that creates the stack. Actually, if you create a stack from a local file, the
AWS cli just copies your template to an S3 bucket it creates for that purpose.&lt;/p&gt;

&lt;h2 id=&quot;the-parent-stack&quot;&gt;The Parent stack.&lt;/h2&gt;

&lt;p&gt;The complete stack is available
&lt;a href=&quot;https://s3.eu-central-1.amazonaws.com/templates.bitbit/techblog/vpc.nested.yaml&quot;&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let us just dive in and take a look at it&lt;/p&gt;

&lt;h3 id=&quot;description-and-parameters&quot;&gt;Description and Parameters&lt;/h3&gt;
&lt;p&gt;I like having a link to the template in the description together with a
description of what the templates implements&lt;/p&gt;

&lt;p&gt;The parameters have sane default values, so you do not need to pass any when
you start the stack. But there is the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ExportPrefix&lt;/code&gt; which can be used if you
are starting many different stacks from the same template.&lt;/p&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nn&quot;&gt;---&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;Description&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Template for simple VPC, 9 subnets in 3 AZ, IPv4 only. Url for template, https://s3.eu-central-1.amazonaws.com/templates.bitbit/techblog/vpc.nested.yaml&lt;/span&gt;

&lt;span class=&quot;na&quot;&gt;Parameters&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;SecondOctet&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Description&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;The X in your 10.X.0.0/16 VPC&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Number&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;MinValue&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;MaxValue&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;255&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Default&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;42&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;ExportPrefix&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;String&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Description&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Custom prefix for exported values. Can be empty&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;AllowedPattern&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;^[a-zA-Z0-9-_]*$&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;ConstraintDescription&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;^[a-zA-Z0-9-_]&apos;&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;MaxLength&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;28&apos;&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;MinLength&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;0&apos;&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Default&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;vpc-&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;Owner&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Description&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Name of owner of the resource&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;String&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Default&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Techblog&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h3 id=&quot;basic-resources&quot;&gt;Basic Resources&lt;/h3&gt;

&lt;p&gt;Here we define the VPC, Internet Gateway and routing tables, the usual
stuff. Everything that is not Availability Zone specific&lt;/p&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;na&quot;&gt;Resources&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;VPC&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::VPC&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;EnableDnsSupport&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;true&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;EnableDnsHostnames&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;true&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;CidrBlock&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Sub&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;10.${SecondOctet}.0.0/16&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;Tags&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Key&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;owner&lt;/span&gt;
          &lt;span class=&quot;na&quot;&gt;Value&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Owner&lt;/span&gt;
        &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Key&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;StackDescription&lt;/span&gt;
          &lt;span class=&quot;na&quot;&gt;Value&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;AWS::StackName&apos;&lt;/span&gt;
        &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Key&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Network&lt;/span&gt;
          &lt;span class=&quot;na&quot;&gt;Value&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Public&lt;/span&gt;
        &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Key&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Name&lt;/span&gt;
          &lt;span class=&quot;na&quot;&gt;Value&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Sub&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;${AWS::StackName} - VPC&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;InternetGW&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::InternetGateway&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;GatewayToInternet&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::VPCGatewayAttachment&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;VpcId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;VPC&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;InternetGatewayId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;InternetGW&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;RouteTablePublic&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::RouteTable&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;VpcId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;VPC&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;Tags&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Key&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;owner&lt;/span&gt;
          &lt;span class=&quot;na&quot;&gt;Value&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Owner&lt;/span&gt;
        &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Key&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Name&lt;/span&gt;
          &lt;span class=&quot;na&quot;&gt;Value&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Sub&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;${AWS::StackName} - Route Table Public&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;RoutePublicIPv4&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::Route&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;DestinationCidrBlock&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;0.0.0.0/0&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;RouteTableId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;RouteTablePublic&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;GatewayId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;InternetGW&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;RouteTablePrivate&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::RouteTable&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;VpcId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;VPC&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;Tags&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Key&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;owner&lt;/span&gt;
          &lt;span class=&quot;na&quot;&gt;Value&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Owner&lt;/span&gt;
        &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Key&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Name&lt;/span&gt;
          &lt;span class=&quot;na&quot;&gt;Value&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Sub&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;${AWS::StackName} - Route Table Private&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h3 id=&quot;subnets&quot;&gt;Subnets&lt;/h3&gt;

&lt;p&gt;And here comes the special part, when defining the subnets, we define stacks
for each of the Availability Zones, and those define resources specific for
the Availability Zone.&lt;/p&gt;

&lt;p&gt;We need to send some parameters to the stacks, but the only thing that differs
between the stacks is the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;AZ&lt;/code&gt; parameter, which is used to denote the
Availability Zone.&lt;/p&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  &lt;span class=&quot;na&quot;&gt;SubnetsAZa&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::CloudFormation::Stack&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;TemplateURL&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;https://s3.eu-central-1.amazonaws.com/templates.bitbit/techblog/vpc.az.yaml&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;Parameters&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;SecondOctet&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;SecondOctet&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;ExportPrefix&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;ExportPrefix&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;Owner&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Owner&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;AZ&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;VPC&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;VPC&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;RouteTablePublic&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;RouteTablePublic&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;RouteTablePrivate&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;RouteTablePrivate&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;SubnetsAZb&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::CloudFormation::Stack&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;TemplateURL&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;https://s3.eu-central-1.amazonaws.com/templates.bitbit/techblog/vpc.az.yaml&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;Parameters&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;SecondOctet&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;SecondOctet&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;ExportPrefix&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;ExportPrefix&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;Owner&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Owner&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;AZ&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;1&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;VPC&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;VPC&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;RouteTablePublic&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;RouteTablePublic&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;RouteTablePrivate&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;RouteTablePrivate&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;SubnetsAZc&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::CloudFormation::Stack&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;TemplateURL&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;https://s3.eu-central-1.amazonaws.com/templates.bitbit/techblog/vpc.az.yaml&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;Parameters&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;SecondOctet&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;SecondOctet&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;ExportPrefix&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;ExportPrefix&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;Owner&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Owner&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;AZ&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;2&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;VPC&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;VPC&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;RouteTablePublic&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;RouteTablePublic&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;RouteTablePrivate&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;RouteTablePrivate&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h3 id=&quot;outputs&quot;&gt;Outputs&lt;/h3&gt;

&lt;p&gt;This stack only outputs and exports resources that are not Availability Zone specific.&lt;/p&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;na&quot;&gt;Outputs&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;VPCid&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Description&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;The VPCid&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Value&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;VPC&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Export&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;Name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Sub&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;${ExportPrefix}VPCid&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;VPCidr&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Description&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;The VPC IPv4 Subnet&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Value&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!GetAtt&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;VPC.CidrBlock&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Export&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;Name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Sub&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;${ExportPrefix}VPCidr&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;RouteTablePublic&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Description&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Route Table for the Public Subnets&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Value&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;RouteTablePrivate&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Export&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;Name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Sub&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;${ExportPrefix}RouteTablePublic&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;RouteTablePrivate&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Description&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Route Table for the Private Subnets&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Value&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;RouteTablePrivate&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Export&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;Name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Sub&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;${ExportPrefix}RouteTablePrivate&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h2 id=&quot;the-child-stacks&quot;&gt;The child stacks&lt;/h2&gt;

&lt;h3 id=&quot;description-and-parameters-1&quot;&gt;Description and Parameters&lt;/h3&gt;
&lt;p&gt;As in the parent template here us a link to the template in the description together with a
description of what the templates implements&lt;/p&gt;

&lt;p&gt;The parameters here have their values to passed by the parent stack.&lt;/p&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nn&quot;&gt;---&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;Description&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Template for subnets in an Availability Zone VPC, IPv4 only. Url for template, https://s3.eu-central-1.amazonaws.com/templates.bitbit/techblog/vpc.az.yaml&lt;/span&gt;

&lt;span class=&quot;na&quot;&gt;Parameters&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;SecondOctet&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Description&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;The X in your 10.X.0.0/16 VPC&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Number&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;MinValue&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;MaxValue&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;255&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;ExportPrefix&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;String&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Description&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Custom prefix for exported values. Can be empty&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;AllowedPattern&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;^[a-zA-Z0-9-_]*$&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;ConstraintDescription&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;^[a-zA-Z0-9-_]&apos;&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;MaxLength&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;28&apos;&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;MinLength&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;0&apos;&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;Owner&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Description&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Name of owner of the resource&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;String&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;AZ&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Description&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;The number of the AZ the resource should be in, 0 - 2 for 3 AZ&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Number&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;MinValue&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;MaxValue&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;2&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;VPC&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Description&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;The VPC this AZ belongs to&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::VPC::Id&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;RouteTablePublic&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Description&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;The route table for the Public Subnet&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;String&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;RouteTablePrivate&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Description&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;The route table for the Private Subnet&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;String&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h3 id=&quot;the-subnets&quot;&gt;The Subnets&lt;/h3&gt;

&lt;p&gt;Here we define the 3 types of subnets we have in each Availability Zone. One
Public Subnet, one Private Subnet behind NAT gateway, and a Private Subnet
without access to Internet.&lt;/p&gt;

&lt;p&gt;I use the Availability Zone number in the definition of of the CIDR for the
subnet.&lt;/p&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;na&quot;&gt;Resources&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;PublicSubnet&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;AWS::EC2::Subnet&apos;&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;VpcId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;VPC&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;AvailabilityZone&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;s&quot;&gt;Fn::Select:&lt;/span&gt;
          &lt;span class=&quot;s&quot;&gt;- !Ref AZ&lt;/span&gt;
          &lt;span class=&quot;s&quot;&gt;- Fn::GetAZs: &quot;&quot;&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;CidrBlock&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Sub&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;10.${SecondOctet}.${AZ}.0/24&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;MapPublicIpOnLaunch&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;true&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;Tags&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Key&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;owner&lt;/span&gt;
          &lt;span class=&quot;na&quot;&gt;Value&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Owner&lt;/span&gt;
        &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Key&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;StackDescription&lt;/span&gt;
          &lt;span class=&quot;na&quot;&gt;Value&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;AWS::StackName&apos;&lt;/span&gt;
        &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Key&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Network&lt;/span&gt;
          &lt;span class=&quot;na&quot;&gt;Value&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Public&lt;/span&gt;
        &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Key&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Name&lt;/span&gt;
          &lt;span class=&quot;na&quot;&gt;Value&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Sub&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;${ExportPrefix}PublicSubnet-${AZ}&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;PrivateSubnet&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;AWS::EC2::Subnet&apos;&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;VpcId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;VPC&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;AvailabilityZone&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;s&quot;&gt;Fn::Select:&lt;/span&gt;
          &lt;span class=&quot;s&quot;&gt;- !Ref AZ&lt;/span&gt;
          &lt;span class=&quot;s&quot;&gt;- Fn::GetAZs: &quot;&quot;&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;CidrBlock&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Sub&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;10.${SecondOctet}.1${AZ}.0/24&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;Tags&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Key&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;owner&lt;/span&gt;
          &lt;span class=&quot;na&quot;&gt;Value&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Owner&lt;/span&gt;
        &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Key&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;StackDescription&lt;/span&gt;
          &lt;span class=&quot;na&quot;&gt;Value&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;AWS::StackName&apos;&lt;/span&gt;
        &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Key&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Network&lt;/span&gt;
          &lt;span class=&quot;na&quot;&gt;Value&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Private&lt;/span&gt;
        &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Key&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Name&lt;/span&gt;
          &lt;span class=&quot;na&quot;&gt;Value&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Sub&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;${ExportPrefix}PrivateSubnet-${AZ}&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;PrivateNATSubnet&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;AWS::EC2::Subnet&apos;&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;VpcId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;VPC&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;AvailabilityZone&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;s&quot;&gt;Fn::Select:&lt;/span&gt;
          &lt;span class=&quot;s&quot;&gt;- !Ref AZ&lt;/span&gt;
          &lt;span class=&quot;s&quot;&gt;- Fn::GetAZs: &quot;&quot;&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;CidrBlock&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Sub&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;10.${SecondOctet}.2${AZ}.0/24&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;Tags&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Key&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;owner&lt;/span&gt;
          &lt;span class=&quot;na&quot;&gt;Value&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Owner&lt;/span&gt;
        &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Key&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;StackDescription&lt;/span&gt;
          &lt;span class=&quot;na&quot;&gt;Value&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;AWS::StackName&apos;&lt;/span&gt;
        &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Key&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Network&lt;/span&gt;
          &lt;span class=&quot;na&quot;&gt;Value&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Private&lt;/span&gt;
        &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Key&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Name&lt;/span&gt;
          &lt;span class=&quot;na&quot;&gt;Value&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Sub&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;${ExportPrefix}PrivateNATSubnet-${AZ}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h3 id=&quot;nat-gateway-and-route-table&quot;&gt;NAT Gateway and route table&lt;/h3&gt;

&lt;p&gt;There is a NAT Gateway in each Availability Zone. And it has its own route table.&lt;/p&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;
  &lt;span class=&quot;na&quot;&gt;NatGWIP&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::EIP&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;Domain&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;vpc&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;NatGW&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::NatGateway&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;AllocationId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!GetAtt&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;NatGWIP.AllocationId&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;SubnetId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;PublicSubnet&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;Tags&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Key&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;owner&lt;/span&gt;
          &lt;span class=&quot;na&quot;&gt;Value&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Owner&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;RouteTableNATPrivate&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::RouteTable&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;VpcId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;VPC&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;Tags&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Key&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;owner&lt;/span&gt;
          &lt;span class=&quot;na&quot;&gt;Value&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Owner&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;RoutePrivateNATIPv4&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::Route&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;DestinationCidrBlock&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;0.0.0.0/0&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;RouteTableId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;RouteTableNATPrivate&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;NatGatewayId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;NatGW&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h3 id=&quot;associating-the-subnets-and-route-tables&quot;&gt;Associating the subnets and route tables&lt;/h3&gt;
&lt;p&gt;That needs to be done for each subnet. The isolated Private Subnet uses a
Route Table that was created in the parent stack and sent as a
Parameter. Same for the Public Subnet. There is a unique Route Table for each
NAT’ed subnet as they have their own NAT gateway.&lt;/p&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  &lt;span class=&quot;na&quot;&gt;Route2SubnetPublicIPv4&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::SubnetRouteTableAssociation&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;RouteTableId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;RouteTablePublic&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;SubnetId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;PublicSubnet&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;Route2SubnetPrivateNATIPv4&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::SubnetRouteTableAssociation&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;RouteTableId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;RouteTableNATPrivate&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;SubnetId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;PrivateNATSubnet&lt;/span&gt;



  &lt;span class=&quot;na&quot;&gt;Route2SubnetPrivateIPv4&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::SubnetRouteTableAssociation&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;RouteTableId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;RouteTablePrivate&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;SubnetId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;PrivateSubnet&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h3 id=&quot;outputs-1&quot;&gt;Outputs&lt;/h3&gt;

&lt;p&gt;Here we export the Subnets for the Availability Zone and the Route Table for
the NAT Gateway. Remember that the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ExportName&lt;/code&gt; needs to be unique, so I prefix
it with the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ExportPrefix&lt;/code&gt; Parameter, and postfix with the number of the
Availability Zone in the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;AZ&lt;/code&gt; Parameter.&lt;/p&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;na&quot;&gt;Outputs&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;PublicSubnet&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Description&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Public Subnet&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Value&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;PublicSubnet&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Export&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;Name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Sub&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;${ExportPrefix}PublicSubnetAZ${AZ}&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;PrivateSubnet&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Description&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Private Subnet&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Value&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;PrivateSubnet&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Export&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;Name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Sub&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;${ExportPrefix}PrivateSubnetAZ${AZ}&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;PrivateNATSubnet&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Description&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Private NAT Subnet&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Value&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;PrivateNATSubnet&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Export&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;Name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Sub&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;${ExportPrefix}PrivateNATSubnetAZ${AZ}&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;RouteTableNATPrivate&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Description&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Route Table for Private NAT Subnet&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Value&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;RouteTableNATPrivate&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Export&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;Name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Sub&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;${ExportPrefix}RouteTableNATPrivateAZ${AZ}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;take-it-for-a-spin&quot;&gt;Take it for a spin…&lt;/h2&gt;

&lt;p&gt;We create a single stack from the parent template by running&lt;/p&gt;

&lt;div class=&quot;language-console highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;jonas@pigz ~/bløgg$&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;aws &lt;span class=&quot;nt&quot;&gt;--profile&lt;/span&gt; blogg cloudformation create-stack &lt;span class=&quot;nt&quot;&gt;--stack-name&lt;/span&gt; nested-blog &lt;span class=&quot;nt&quot;&gt;--template-url&lt;/span&gt; https://s3.eu-central-1.amazonaws.com/templates.bitbit/techblog/vpc.nested.yaml
&lt;span class=&quot;go&quot;&gt;{
    &quot;StackId&quot;: &quot;arn:aws:cloudformation:eu-west-2:123NaN123201:stack/nested-blog/edb4d580-9237-11eb-9a54-0a355b7dff20&quot;
}
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Then after quite some while we can look at the stack&lt;/p&gt;

&lt;div class=&quot;language-console highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;jonas@pigz ~/bløgg$&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;aws &lt;span class=&quot;nt&quot;&gt;--profile&lt;/span&gt; blogg cloudformation describe-stacks &lt;span class=&quot;nt&quot;&gt;--stack-name&lt;/span&gt; nested-blog
&lt;span class=&quot;go&quot;&gt;{
    &quot;Stacks&quot;: [
        {
            &quot;StackId&quot;: &quot;arn:aws:cloudformation:eu-west-2:123NaN123201:stack/nested-blog/edb4d580-9237-11eb-9a54-0a355b7dff20&quot;,
            &quot;StackName&quot;: &quot;nested-blog&quot;,
            &quot;Description&quot;: &quot;Template for simple VPC, 9 subnets in 3 AZ, IPv4 only. Url for template, https://s3.eu-central-1.amazonaws.com/templates.bitbit/techblog/vpc.nested.yaml&quot;,
            &quot;Parameters&quot;: [
                {
                    &quot;ParameterKey&quot;: &quot;Owner&quot;,
                    &quot;ParameterValue&quot;: &quot;Techblog&quot;
                },
                {
                    &quot;ParameterKey&quot;: &quot;ExportPrefix&quot;,
                    &quot;ParameterValue&quot;: &quot;vpc-&quot;
                },
                {
                    &quot;ParameterKey&quot;: &quot;SecondOctet&quot;,
                    &quot;ParameterValue&quot;: &quot;42&quot;
                }
            ],
            &quot;CreationTime&quot;: &quot;2021-03-31T15:44:07.614Z&quot;,
            &quot;RollbackConfiguration&quot;: {},
            &quot;StackStatus&quot;: &quot;CREATE_COMPLETE&quot;,
            &quot;DisableRollback&quot;: false,
            &quot;NotificationARNs&quot;: [],
            &quot;Outputs&quot;: [
                {
                    &quot;OutputKey&quot;: &quot;RouteTablePrivate&quot;,
                    &quot;OutputValue&quot;: &quot;rtb-0ad3e61a075aeea7c&quot;,
                    &quot;Description&quot;: &quot;Route Table for the Private Subnets&quot;,
                    &quot;ExportName&quot;: &quot;vpc-RouteTablePrivate&quot;
                },
                {
                    &quot;OutputKey&quot;: &quot;VPCid&quot;,
                    &quot;OutputValue&quot;: &quot;vpc-05e40be58b0da76cc&quot;,
                    &quot;Description&quot;: &quot;The VPCid&quot;,
                    &quot;ExportName&quot;: &quot;vpc-VPCid&quot;
                },
                {
                    &quot;OutputKey&quot;: &quot;VPCidr&quot;,
                    &quot;OutputValue&quot;: &quot;10.42.0.0/16&quot;,
                    &quot;Description&quot;: &quot;The VPC IPv4 Subnet&quot;,
                    &quot;ExportName&quot;: &quot;vpc-VPCidr&quot;
                },
                {
                    &quot;OutputKey&quot;: &quot;RouteTablePublic&quot;,
                    &quot;OutputValue&quot;: &quot;rtb-0ad3e61a075aeea7c&quot;,
                    &quot;Description&quot;: &quot;Route Table for the Public Subnets&quot;,
                    &quot;ExportName&quot;: &quot;vpc-RouteTablePublic&quot;
                }
            ],
            &quot;Tags&quot;: [],
            &quot;EnableTerminationProtection&quot;: false,
            &quot;DriftInformation&quot;: {
                &quot;StackDriftStatus&quot;: &quot;NOT_CHECKED&quot;
            }
        }
    ]
}
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;That does not show us the Subnet stacks, but we can ask Cloudformation for all exports, and get a long list, I include it here for fun and profit.&lt;/p&gt;

&lt;div class=&quot;language-console highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;jonas@pigz ~/bløgg$&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;aws &lt;span class=&quot;nt&quot;&gt;--profile&lt;/span&gt; blogg cloudformation list-exports
&lt;span class=&quot;go&quot;&gt;{
    &quot;Exports&quot;: [
        {
            &quot;ExportingStackId&quot;: &quot;arn:aws:cloudformation:eu-west-2:123NaN123201:stack/nested-blog-SubnetsAZa-1S3IELV5150CM/fcf7d8d0-9237-11eb-a30a-0a953df5d268&quot;,
            &quot;Name&quot;: &quot;vpc-PrivateNATSubnetAZ0&quot;,
            &quot;Value&quot;: &quot;subnet-0fa4f57de3e503ff2&quot;
        },
        {
            &quot;ExportingStackId&quot;: &quot;arn:aws:cloudformation:eu-west-2:123NaN123201:stack/nested-blog-SubnetsAZb-8ULH4BH3LOQ6/fcf4a480-9237-11eb-b513-06c721e1f154&quot;,
            &quot;Name&quot;: &quot;vpc-PrivateNATSubnetAZ1&quot;,
            &quot;Value&quot;: &quot;subnet-027efcf30c5209d95&quot;
        },
        {
            &quot;ExportingStackId&quot;: &quot;arn:aws:cloudformation:eu-west-2:123NaN123201:stack/nested-blog-SubnetsAZc-1N9U05AXMUP8V/fce11c80-9237-11eb-93ff-022e9396137a&quot;,
            &quot;Name&quot;: &quot;vpc-PrivateNATSubnetAZ2&quot;,
            &quot;Value&quot;: &quot;subnet-00ef014554daa6ccc&quot;
        },
        {
            &quot;ExportingStackId&quot;: &quot;arn:aws:cloudformation:eu-west-2:123NaN123201:stack/nested-blog-SubnetsAZa-1S3IELV5150CM/fcf7d8d0-9237-11eb-a30a-0a953df5d268&quot;,
            &quot;Name&quot;: &quot;vpc-PrivateSubnetAZ0&quot;,
            &quot;Value&quot;: &quot;subnet-0a1ad9437c884b157&quot;
        },
        {
            &quot;ExportingStackId&quot;: &quot;arn:aws:cloudformation:eu-west-2:123NaN123201:stack/nested-blog-SubnetsAZb-8ULH4BH3LOQ6/fcf4a480-9237-11eb-b513-06c721e1f154&quot;,
            &quot;Name&quot;: &quot;vpc-PrivateSubnetAZ1&quot;,
            &quot;Value&quot;: &quot;subnet-025a179fe5b3820f8&quot;
        },
        {
            &quot;ExportingStackId&quot;: &quot;arn:aws:cloudformation:eu-west-2:123NaN123201:stack/nested-blog-SubnetsAZc-1N9U05AXMUP8V/fce11c80-9237-11eb-93ff-022e9396137a&quot;,
            &quot;Name&quot;: &quot;vpc-PrivateSubnetAZ2&quot;,
            &quot;Value&quot;: &quot;subnet-07d004eb9c1192773&quot;
        },
        {
            &quot;ExportingStackId&quot;: &quot;arn:aws:cloudformation:eu-west-2:123NaN123201:stack/nested-blog-SubnetsAZa-1S3IELV5150CM/fcf7d8d0-9237-11eb-a30a-0a953df5d268&quot;,
            &quot;Name&quot;: &quot;vpc-PublicSubnetAZ0&quot;,
            &quot;Value&quot;: &quot;subnet-017edbd14176b6c02&quot;
        },
        {
            &quot;ExportingStackId&quot;: &quot;arn:aws:cloudformation:eu-west-2:123NaN123201:stack/nested-blog-SubnetsAZb-8ULH4BH3LOQ6/fcf4a480-9237-11eb-b513-06c721e1f154&quot;,
            &quot;Name&quot;: &quot;vpc-PublicSubnetAZ1&quot;,
            &quot;Value&quot;: &quot;subnet-03460753b66112c9f&quot;
        },
        {
            &quot;ExportingStackId&quot;: &quot;arn:aws:cloudformation:eu-west-2:123NaN123201:stack/nested-blog-SubnetsAZc-1N9U05AXMUP8V/fce11c80-9237-11eb-93ff-022e9396137a&quot;,
            &quot;Name&quot;: &quot;vpc-PublicSubnetAZ2&quot;,
            &quot;Value&quot;: &quot;subnet-062419d50a7aa907c&quot;
        },
        {
            &quot;ExportingStackId&quot;: &quot;arn:aws:cloudformation:eu-west-2:123NaN123201:stack/nested-blog-SubnetsAZa-1S3IELV5150CM/fcf7d8d0-9237-11eb-a30a-0a953df5d268&quot;,
            &quot;Name&quot;: &quot;vpc-RouteTableNATPrivateAZ0&quot;,
            &quot;Value&quot;: &quot;rtb-0ea59402ad6fb359b&quot;
        },
        {
            &quot;ExportingStackId&quot;: &quot;arn:aws:cloudformation:eu-west-2:123NaN123201:stack/nested-blog-SubnetsAZb-8ULH4BH3LOQ6/fcf4a480-9237-11eb-b513-06c721e1f154&quot;,
            &quot;Name&quot;: &quot;vpc-RouteTableNATPrivateAZ1&quot;,
            &quot;Value&quot;: &quot;rtb-096736e362d8009b4&quot;
        },
        {
            &quot;ExportingStackId&quot;: &quot;arn:aws:cloudformation:eu-west-2:123NaN123201:stack/nested-blog-SubnetsAZc-1N9U05AXMUP8V/fce11c80-9237-11eb-93ff-022e9396137a&quot;,
            &quot;Name&quot;: &quot;vpc-RouteTableNATPrivateAZ2&quot;,
            &quot;Value&quot;: &quot;rtb-0f044d02cd62dbf41&quot;
        },
        {
            &quot;ExportingStackId&quot;: &quot;arn:aws:cloudformation:eu-west-2:123NaN123201:stack/nested-blog/edb4d580-9237-11eb-9a54-0a355b7dff20&quot;,
            &quot;Name&quot;: &quot;vpc-RouteTablePrivate&quot;,
            &quot;Value&quot;: &quot;rtb-0ad3e61a075aeea7c&quot;
        },
        {
            &quot;ExportingStackId&quot;: &quot;arn:aws:cloudformation:eu-west-2:123NaN123201:stack/nested-blog/edb4d580-9237-11eb-9a54-0a355b7dff20&quot;,
            &quot;Name&quot;: &quot;vpc-RouteTablePublic&quot;,
            &quot;Value&quot;: &quot;rtb-0ad3e61a075aeea7c&quot;
        },
        {
            &quot;ExportingStackId&quot;: &quot;arn:aws:cloudformation:eu-west-2:123NaN123201:stack/nested-blog/edb4d580-9237-11eb-9a54-0a355b7dff20&quot;,
            &quot;Name&quot;: &quot;vpc-VPCid&quot;,
            &quot;Value&quot;: &quot;vpc-05e40be58b0da76cc&quot;
        },
        {
            &quot;ExportingStackId&quot;: &quot;arn:aws:cloudformation:eu-west-2:123NaN123201:stack/nested-blog/edb4d580-9237-11eb-9a54-0a355b7dff20&quot;,
            &quot;Name&quot;: &quot;vpc-VPCidr&quot;,
            &quot;Value&quot;: &quot;10.42.0.0/16&quot;
        }
    ]
}
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;We can get the short version of that by using the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--query&lt;/code&gt; argument&lt;/p&gt;
&lt;div class=&quot;language-console highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;jonas@pigz ~/bløgg$&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;aws &lt;span class=&quot;nt&quot;&gt;--profile&lt;/span&gt; blogg cloudformation list-exports &lt;span class=&quot;nt&quot;&gt;--query&lt;/span&gt; Exports[].Name
&lt;span class=&quot;go&quot;&gt;[
    &quot;vpc-PrivateNATSubnetAZ0&quot;,
    &quot;vpc-PrivateNATSubnetAZ1&quot;,
    &quot;vpc-PrivateNATSubnetAZ2&quot;,
    &quot;vpc-PrivateSubnetAZ0&quot;,
    &quot;vpc-PrivateSubnetAZ1&quot;,
    &quot;vpc-PrivateSubnetAZ2&quot;,
    &quot;vpc-PublicSubnetAZ0&quot;,
    &quot;vpc-PublicSubnetAZ1&quot;,
    &quot;vpc-PublicSubnetAZ2&quot;,
    &quot;vpc-RouteTableNATPrivateAZ0&quot;,
    &quot;vpc-RouteTableNATPrivateAZ1&quot;,
    &quot;vpc-RouteTableNATPrivateAZ2&quot;,
    &quot;vpc-RouteTablePrivate&quot;,
    &quot;vpc-RouteTablePublic&quot;,
    &quot;vpc-VPCid&quot;,
    &quot;vpc-VPCidr&quot;
]
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;clean-up-afterwards&quot;&gt;Clean up afterwards.&lt;/h3&gt;

&lt;div class=&quot;language-console highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;jonas@pigz ~/bløgg$&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;aws &lt;span class=&quot;nt&quot;&gt;--profile&lt;/span&gt; blogg cloudformation delete-stack &lt;span class=&quot;nt&quot;&gt;--stack-name&lt;/span&gt; nested-blog
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;This will remove the child stacks and then the parent stack.&lt;/p&gt;

&lt;p&gt;Now the VPC stack is out of the way, and next time I can describe templates
defining something more interesting than a VPC.&lt;/p&gt;
</description>
        <pubDate>Wed, 31 Mar 2021 00:00:00 +0000</pubDate>
        <link>/cloud/blog/2021/03/31/output-from-cloudformation.html</link>
        <guid isPermaLink="true">/cloud/blog/2021/03/31/output-from-cloudformation.html</guid>
        
        
      </item>
    
      <item>
        <title>Video conferencing and privacy, findings and conclusion</title>
        <description>&lt;p&gt;&lt;b&gt;In our &lt;a href=&quot;https://www.redpill-linpro.com/cloud/blog/2021/03/24/video_conferencing_and_privacy_1.html&quot;&gt;prevous blog post&lt;/a&gt;,
 we described how to tackle the challenge of choosing the right video conferencing solution and describe a methodology. In this post we will let you in on our findings and conclusions.&lt;/b&gt;&lt;/p&gt;

&lt;h4 id=&quot;findings---part-1&quot;&gt;Findings - part 1&lt;/h4&gt;

&lt;p&gt;To start, a very interesting observation is that none of the well-known and most used video conferencing solutions did make it beyond the first part of the review. This means that legal requirements for processing of personal data were not met in an adequate manner. This is inasmuch surprising, as the agreements otherwise appear quite sound and worked out.&lt;/p&gt;

&lt;p&gt;The review identified several shortcomings which roughly can be grouped into the following categories.&lt;/p&gt;

&lt;p&gt;&lt;i&gt;1. Inadequate data processing agreements&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;The DPA does not fulfil relevant requirements in the GDPR such as restricting the data controllers authority to give directions on data processing, or the agreement restricts rights or obligations which are not compatible with GDPR. It might also be the case that necessary safeguards are not in place, or not satisfactory.&lt;/p&gt;

&lt;p&gt;&lt;i&gt;2. Unlawful data transfer or processing&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;&lt;i&gt;3. Accountability of the controller is constrained&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;Some agreements include clauses that allow for unilateral and unannounced changes of the agreement, which makes it impossible for the controller to fulfil their accountability requirements. This is also often the case where sub-processors are involved where the list of sub processors can be updated without further notice.&lt;/p&gt;

&lt;p&gt;&lt;i&gt;4. Data processing for other purposes&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;Some providers reserve the right to process data for their own, or third parties, purposes which is not acceptable&lt;/p&gt;

&lt;p&gt;The review contains also detailed information about the findings, and reasoning for why an agreement was deemed inadequate with regards to the GDPR.&lt;/p&gt;

&lt;h4 id=&quot;findings---part-2&quot;&gt;Findings - part 2&lt;/h4&gt;

&lt;p&gt;For the second part, the remaining services where reviewed on data security and how the technical solution supports data privacy in their default configuration. The assessment is based on several criteria like encryption, authentication for participants and the meeting host, but also privacy requirements like unauthorised or unannounced recording possibilities. A detailed description of these requirements can be found in chapter 4.&lt;/p&gt;

&lt;p&gt;Further, a set of three use cases have been defined, with varying degrees of privacy and security requirements. The different video conferencing solutions have been assessed on how well they fulfil the security and privacy requirements on the background of these use cases.&lt;/p&gt;

&lt;p&gt;Basically, the use cases are ranged from low to high requirements on privacy, based on the nature of the discussed topic as well as the protection requirements of all participants.&lt;/p&gt;

&lt;p&gt;The review did only find three categories of shortcomings preventing a positive rating:&lt;/p&gt;

&lt;p&gt;&lt;i&gt;1. No mandatory authentication of participants with for example a username and password&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;&lt;i&gt;2. No role-based access control (RBAC)&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;&lt;i&gt;3. Camera/microphone cannot be deactivated by default when entering the conference&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;Another evaluated criteria is the quality of end-to-end encryption, where the review differentiates between weak and strong end-to-end encryption. The difference is that for strong end-to-end encryption, the encryption keys are negotiated for each session between the end devices, and the encryption keys are not available to the provider. Weak end-to-end encryption on the other hand only prevents from casual observation by the provider (as encryption keys are available to the provider).&lt;/p&gt;

&lt;p&gt;All video conferencing solutions reviewed in this part did at least pass the requirements for the least-demanding use case, and most did also provide enough protection for conferences with high demands on privacy and security.&lt;/p&gt;

&lt;p&gt;End-to-end encryption is only available for few of the reviewed solutions.&lt;/p&gt;

&lt;h4 id=&quot;jitsi-meet&quot;&gt;Jitsi Meet&lt;/h4&gt;
&lt;p&gt;&lt;a href=&quot;https://www.redpill-linpro.com/cloud/rlnc/vcaas.html&quot;&gt;Redpill Linpros VCaaS solution is based on Jitsi Meet&lt;/a&gt; a free and open source video conferencing solution. Jitsi Meet is one of the OSS solutions reviewed in the Berlin note, with quite good results on the technical side - with a few caveats:&lt;/p&gt;

&lt;p&gt;&lt;i&gt;1. Jitsi Meet has no role-based access controll&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;&lt;i&gt;2. Jitsi Meet does not provide a wide range of features for access control&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;The standard setup of Jitsi Meet is to allow anybody to set up and connect to running video conferences. This is quite convenient in day-to-day use, but will become an issue when hosting large meetings that require confidentiality or privacy. Jitsi Meet does provide two features to handle this: setting passwords on meeting rooms, as well as requiring authentication before being able to create or join a virtual meeting room.&lt;/p&gt;

&lt;p&gt;Setting a password that is shared separately from the meeting invitation is certainly a way to increase privacy for meetings with low or moderate requirements, especially for groups that know each other and will guard themselves against unknown participants.&lt;/p&gt;

&lt;p&gt;Some of the use cases described in the review have higher demands on confidentiality and privacy, and the Berlin note recommends to use RBAC and individual authentication in these cases. This is also recommended when hosting video conferences participants that do not know each other personally, where privacy requirements are relevant.&lt;/p&gt;

&lt;h4 id=&quot;conclusions&quot;&gt;Conclusions&lt;/h4&gt;

&lt;p&gt;It was quite surprising to find that almost all of the well-known video conferencing solutions (like Zoom, Teams, Webex, Gotomeeting or Skype) do not provide a service with a data privacy agreement conforming to European law. There are exceptions, and the review lists several solutions that do conform to legal requirements as well as provide secure and private solutions.&lt;/p&gt;

&lt;p&gt;All services that did pass the legal requirements did also pass the security and privacy requirements, at least for the least-demanding use case outlined in the review. Three video conferencing solutions did pass all requirements, and two of these are open source software - including the one with strongest end-to-end encryption.&lt;/p&gt;

&lt;p&gt;While not all criteria in this review might be applicable to your specific requirements, this review does provide valuable insight into how to conduct an assessment, and especially the findings of the legal review should be thought-provoking. The review also gives a good overview over video conferencing solutions available.&lt;/p&gt;

&lt;!-- Contact --&gt;
&lt;div class=&quot;two spacing&quot;&gt;&lt;/div&gt;
&lt;div class=&quot;row&quot;&gt;
  &lt;div class=&quot;medium-12 medium-centered columns&quot;&gt;
    






&lt;div class=&quot;rl-contact-box-wrapper&quot;&gt;


  &lt;div class=&quot;rl-contact-box content row&quot;&gt;
    &lt;div class=&quot;small-1 column&quot;&gt;&amp;nbsp;&lt;/div&gt;
    
    &lt;div class=&quot;small-1 medium-4 column&quot;&gt;
      &lt;div class=&quot;rl-contact-image&quot;&gt;
        
        
&lt;div class=&quot;rl-image-ratio-block&quot; style=&quot;background-image:url(/cloud/images/employees/michael.jpg)&quot;&gt;&lt;/div&gt;

      &lt;/div&gt;
    &lt;/div&gt;
    
    &lt;div class=&quot;small-10 medium-6 column end&quot;&gt;
      &lt;div class=&quot;rl-contact-text&quot;&gt;
        &lt;h2 class=&quot;rl-contact-heading&quot;&gt;Contact&lt;/h2&gt;
        &lt;p&gt;&lt;span class=&quot;rl-contact-name&quot;&gt;Michael Nemecky&lt;/span&gt;&lt;br /&gt;
           &lt;span class=&quot;rl-contact-title&quot;&gt;Operations Manager at Redpill&amp;nbsp;Linpro&lt;/span&gt;&lt;br /&gt;
           &lt;a class=&quot;button rl-contact-link&quot; href=&quot;/cloud/contact.html&quot;&gt;Contact&lt;/a&gt;&lt;br /&gt;
        &lt;/p&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;two spacing&quot;&gt;&lt;/div&gt;




  &lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;two spacing&quot;&gt;&lt;/div&gt;
</description>
        <pubDate>Wed, 24 Mar 2021 00:00:00 +0000</pubDate>
        <link>/cloud/blog/2021/03/24/video_conferencing_and_privacy_2.html</link>
        <guid isPermaLink="true">/cloud/blog/2021/03/24/video_conferencing_and_privacy_2.html</guid>
        
        
        <category>Cloud</category>
        
      </item>
    
      <item>
        <title>Video conferencing and privacy, choosing a solution</title>
        <description>&lt;p&gt;&lt;b&gt;The last year has been a challenge for most people in Scandinavia and the rest of the world, battling against COVID19 and trying to keep their lives and jobs up and running. But it has also been a year of change, with increased use and acceptance of home working pushing the boundaries for several technologies that support team working and collaboration.&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;At our workplace, video conferencing has become one of the most used technologies during this year. Despite working in a tech-savvy company, we would seldom use video conferencing on a regular basis before, but more than often we just would walk into our colleagues office and discuss the matter at hand. This, among other things, has drastically changed.&lt;/p&gt;

&lt;p&gt;Choosing the right video conferencing system is often about finding a solution that offers the required features, is easy to use and integrate, and, above all, does not cost a fortune. The privacy aspects are more than often overlooked, especially when everybody just “needs to get this running”, as was the case in the early days of COVID.&lt;/p&gt;

&lt;h4 id=&quot;the-challenge&quot;&gt;The challenge&lt;/h4&gt;

&lt;p&gt;A lot of meetings that would have been a private chat between two colleagues in an office have moved to video. Almost everybody would have the presence of mind to close the door to their office or meeting room when discussing sensitive matters, or matters that require more privacy. This might not be the case for a video conference, or any other online conversation, for that matter.&lt;/p&gt;

&lt;p&gt;The challenge arises from the fact that while tools like video conferencing try to make anybody feel like they are just a (sophisticated) extension of the physical world, in reality your private conversation might travel around the world and use services you never knew about.&lt;/p&gt;

&lt;h4 id=&quot;choosing-a-solution&quot;&gt;Choosing a solution&lt;/h4&gt;

&lt;p&gt;The legal and security aspects should be assessed together with the functional aspects when choosing a video conferencing solution. Video conferencing tools do process personal data, and as such are subject to data privacy laws like the GDPR, as well as other laws and regulations depending on your concrete situation.&lt;/p&gt;

&lt;p&gt;In addition, how you plan to use the tools, as well as other requirements like confidentiality or integrity, contractual constraints or company policy will shape whether a specific video conferencing solution will fit or not.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://www.datenschutz-berlin.de/ueber-uns/zur-person&quot;&gt;The Data Security Officer for Berlin, Germany, Maja Smoltczyk&lt;/a&gt; has released a note on the use of video conference solutions that might be helpful in assessing the different offerings available on the market:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;For the &lt;a href=&quot;https://www.datenschutz-berlin.de/fileadmin/user_upload/pdf/pressemitteilungen/2020/20200703-PR-brief_review_video_conferencing_services_for_controllers_in_Berlin.pdf&quot;&gt;press release&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;For the &lt;a href=&quot;https://www.datenschutz-berlin.de/fileadmin/user_upload/pdf/orientierungshilfen/2021-BlnBDI-Hinweise_Berliner_Verantwortliche_zu_Anbietern_Videokonferenz-Dienste.pdf&quot;&gt;review&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;While the note primarily is targeted at public offices in Berlin, the observations and general conclusions are valid for anyone using video conferencing. The approach described in the note can also be used as a blueprint for own reviews of tools.&lt;/p&gt;

&lt;h4 id=&quot;methodology&quot;&gt;Methodology&lt;/h4&gt;

&lt;p&gt;The review consists of two steps:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;The lawfulness of the data processing agreement with the provider is verified, based on publicly available information provided. Also, a cursory check is conducted whether all sub-providers in use are listed in the agreement&lt;/li&gt;
  &lt;li&gt;A check to identify which security measures for authentication, authorization and encryption are provided “out of the box”, i.e. without any adjustments&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;When a solution was deemed unsatisfactory during one step, the remaining steps were not conducted in this review, and not all solutions have therefore been reviewed for their security measures, for example. Also, the review is based on the publicly available agreement for the solutions reviewed, and does not take into account that other agreements can be negotiated.&lt;/p&gt;

&lt;p&gt;Still, the review gives a good overview over the current state, and what details to focus on when reviewing data privacy agreements.&lt;/p&gt;

&lt;p&gt;We will reveal our findings and conclusions in the next blog post:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://www.redpill-linpro.com/cloud/blog/2021/03/24/video_conferencing_and_privacy_2.html&quot;&gt;Video conferencing and privacy - findings and conclusions&lt;/a&gt;.&lt;/p&gt;

&lt;!-- Contact --&gt;
&lt;div class=&quot;two spacing&quot;&gt;&lt;/div&gt;
&lt;div class=&quot;row&quot;&gt;
  &lt;div class=&quot;medium-12 medium-centered columns&quot;&gt;
    






&lt;div class=&quot;rl-contact-box-wrapper&quot;&gt;


  &lt;div class=&quot;rl-contact-box content row&quot;&gt;
    &lt;div class=&quot;small-1 column&quot;&gt;&amp;nbsp;&lt;/div&gt;
    
    &lt;div class=&quot;small-1 medium-4 column&quot;&gt;
      &lt;div class=&quot;rl-contact-image&quot;&gt;
        
        
&lt;div class=&quot;rl-image-ratio-block&quot; style=&quot;background-image:url(/cloud/images/employees/michael.jpg)&quot;&gt;&lt;/div&gt;

      &lt;/div&gt;
    &lt;/div&gt;
    
    &lt;div class=&quot;small-10 medium-6 column end&quot;&gt;
      &lt;div class=&quot;rl-contact-text&quot;&gt;
        &lt;h2 class=&quot;rl-contact-heading&quot;&gt;Contact&lt;/h2&gt;
        &lt;p&gt;&lt;span class=&quot;rl-contact-name&quot;&gt;Michael Nemecky&lt;/span&gt;&lt;br /&gt;
           &lt;span class=&quot;rl-contact-title&quot;&gt;Operations Manager at Redpill&amp;nbsp;Linpro&lt;/span&gt;&lt;br /&gt;
           &lt;a class=&quot;button rl-contact-link&quot; href=&quot;/cloud/contact.html&quot;&gt;Contact&lt;/a&gt;&lt;br /&gt;
        &lt;/p&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;two spacing&quot;&gt;&lt;/div&gt;




  &lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;two spacing&quot;&gt;&lt;/div&gt;
</description>
        <pubDate>Wed, 24 Mar 2021 00:00:00 +0000</pubDate>
        <link>/cloud/blog/2021/03/24/video_conferencing_and_privacy_1.html</link>
        <guid isPermaLink="true">/cloud/blog/2021/03/24/video_conferencing_and_privacy_1.html</guid>
        
        
        <category>Cloud</category>
        
      </item>
    
      <item>
        <title>Moving forward with Cloudformation templates</title>
        <description>&lt;p&gt;Now we continue improving the VPC template from my previous blog entry &lt;a href=&quot;https://www.redpill-linpro.com/cloud/blog/2020/09/21/cloudformation-vpc.html&quot;&gt;“Starting with Cloudformation
templates”&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What we ended up with there was a VPC with one subnet connected to the
Internet. Or what is know in AWS lingo as a “Public Subnet”.&lt;/p&gt;

&lt;p&gt;The goal now is a VPC with presence in tree Availability Zones with a “Public
Subnet” in each, and a “Private Subnet” in each as well.&lt;/p&gt;

&lt;h1 id=&quot;humble-beginnings&quot;&gt;Humble beginnings&lt;/h1&gt;

&lt;p&gt;Before we go all out on tree Availability Zones, let us set it up with only
one. It will not be that hard to expand the template to tree Availability Zones
when we have got it up and running on one.&lt;/p&gt;

&lt;h2 id=&quot;public-vs-private-subnet&quot;&gt;Public vs Private subnet&lt;/h2&gt;

&lt;p&gt;The main difference between a Private and a Public subnet is its routing
to Internet.&lt;/p&gt;

&lt;h3 id=&quot;public-subnet&quot;&gt;Public subnet&lt;/h3&gt;

&lt;p&gt;The Public subnet is routed directly through an Internet Gateway
so you need an Elastic IP on a resource accessing Internet. Resources can then
also be available on the Internet through their Elastic IP.&lt;/p&gt;

&lt;h3 id=&quot;private-subnet&quot;&gt;Private subnet&lt;/h3&gt;

&lt;p&gt;The Private subnet does not have direct route to Internet, and can be
configured in a manner it does not have access to Internet at all. We will
allow access to the Internet through a NAT Gateway. Resources in a Private
subnet have no use of Elastic IP.&lt;/p&gt;

&lt;h3 id=&quot;nat-gateway&quot;&gt;NAT Gateway&lt;/h3&gt;

&lt;p&gt;The NAT Gateway we talk about here is a managed service from AWS, and it comes
with a price. Each instance of NAT Gateway costs $0.045 per hour and $0.045
per GB data transferred in or out. In our setup with tree Availability Zones and
a NAT Gateway in each of them, we get up to $100 a month just for the Gateways
alone.&lt;/p&gt;

&lt;p&gt;You can read more about NAT Gateway pricing
&lt;a href=&quot;https://aws.amazon.com/vpc/pricing/&quot;&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;private-subnet-in-cloudformation&quot;&gt;Private Subnet in Cloudformation&lt;/h2&gt;

&lt;p&gt;As stated, the main difference is in the routing. And we know we need a NAT
Gateway, let us check the
&lt;a href=&quot;https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-natgateway.html&quot;&gt;documentation.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It gives us this skeleton:&lt;/p&gt;
&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::NatGateway&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;AllocationId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;String&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;SubnetId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;String&lt;/span&gt;
    &lt;span class=&quot;s&quot;&gt;Tags&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Tag&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Both &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SubnetId&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;AllocationId&lt;/code&gt; are required. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SubnetId&lt;/code&gt; needs a reference
to a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;AWS::EC2::Subnet&lt;/code&gt; resource. But &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;AllocationId&lt;/code&gt; is &lt;em&gt;The allocation ID of an Elastic IP
address to associate with the NAT gateway.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;So we check the documentation for &lt;a href=&quot;https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-eip.html&quot;&gt;Elastic
IP&lt;/a&gt;
and it gives us&lt;/p&gt;
&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::EIP&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;Domain&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;String&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;InstanceId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;String&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;PublicIpv4Pool&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;String&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;Tags&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Tag&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Of those, only &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Domain&lt;/code&gt; is of interest, and as it is to be used with a NAT
Gateway we not care for EC2-Classic, so we set this to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;vpc&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The documentation also mentions that if we are creating this resource in the
same template as our VPC we need to create dependency on the VPC-gateway
attachment.&lt;/p&gt;

&lt;p&gt;A very important thing we can read from the documentation page is the return
values of the resource. If you ask for the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;!Ref&lt;/code&gt; value, you will get the IP
address associated with the resource, but we want the allocation ID of it.&lt;/p&gt;

&lt;p&gt;To access that value we need to use the
&lt;a href=&quot;https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-getatt.html&quot;&gt;Fn::GetAtt&lt;/a&gt;
function. And we need to use it with the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;AllocationId&lt;/code&gt; key word. Look for
that below. There we use the shorter &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;!GetAtt&lt;/code&gt; form of the function.&lt;/p&gt;

&lt;h3 id=&quot;dependency&quot;&gt;Dependency&lt;/h3&gt;

&lt;p&gt;You can give Cloudformation directions on order it must create resources. You
can do that by using the keyword &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;DependsOn&lt;/code&gt;. Like for example:&lt;/p&gt;
&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  &lt;span class=&quot;na&quot;&gt;GatewayToInternet&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::VPCGatewayAttachment&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;VpcId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;VPC&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;InternetGatewayId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;InternetGW&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;NatGWIP&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;DependsOn&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;GatewayToInternet&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::EIP&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;Domain&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;vpc&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;You do not need to specify the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;DependsOn&lt;/code&gt; relationship if the dependency is
show through reference as seen here:&lt;/p&gt;
&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  &lt;span class=&quot;na&quot;&gt;InternetGW&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::InternetGateway&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;GatewayToInternet&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::VPCGatewayAttachment&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;VpcId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;VPC&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;InternetGatewayId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;InternetGW&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Here it would be superfluous to declare that &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GatewayToInternet&lt;/code&gt; was dependent
on &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;InternetGW&lt;/code&gt;. You can read more about &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;DependsOn&lt;/code&gt;
&lt;a href=&quot;https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-dependson.html&quot;&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;how-a-subnet-is-defined&quot;&gt;How a subnet is defined&lt;/h2&gt;

&lt;p&gt;Now we need to look back to a normal subnet and see what is needed to define it
and its routing. The parts from my previous blog are:&lt;/p&gt;
&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  &lt;span class=&quot;na&quot;&gt;SubNett&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::Subnet&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;CidrBlock&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;10.0.42.0/24&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;VpcId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;VPC&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;RouteTablePublic&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::RouteTable&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;VpcId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;VPC&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;RoutePublic&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::Route&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;DestinationCidrBlock&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;0.0.0.0/0&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;RouteTableId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;RouteTablePublic&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;GatewayId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;InternetGW&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;Route2Subnet&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::SubnetRouteTableAssociation&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;RouteTableId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;RouteTablePublic&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;SubnetId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;SubNett&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;So there is a route, in a route table. Then there is a subnet, and then there
is the association between subnet and route table.&lt;/p&gt;

&lt;p&gt;The difference from this to the Private subnet is where to route the traffic
not local to the VPC.&lt;/p&gt;

&lt;h3 id=&quot;route-for-a-private-subnet&quot;&gt;Route for a Private subnet&lt;/h3&gt;

&lt;p&gt;As we stated in last blog, these are all the options for the Route resource:&lt;/p&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::Route&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;DestinationCidrBlock&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;String&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;DestinationIpv6CidrBlock&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;String&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;EgressOnlyInternetGatewayId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;String&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;GatewayId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;String&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;InstanceId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;String&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;NatGatewayId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;String&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;NetworkInterfaceId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;String&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;RouteTableId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;String&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;TransitGatewayId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;String&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;VpcPeeringConnectionId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;String&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Now, we will not use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GatewayId&lt;/code&gt; but the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;NatGatewayId&lt;/code&gt; for the Private subnet.&lt;/p&gt;

&lt;h2 id=&quot;private-subnet-1&quot;&gt;Private Subnet&lt;/h2&gt;

&lt;p&gt;Putting the parts together, our Private subnet definition becomes:&lt;/p&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  &lt;span class=&quot;na&quot;&gt;PrivateSubNett&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::Subnet&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;CidrBlock&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;10.0.43.0/24&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;VpcId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;VPC&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;NatGWIP&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;DependsOn&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;GatewayToInternet&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::EIP&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;Domain&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;vpc&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;NatGW&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::NatGateway&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;AllocationId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!GetAtt&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;NatGWIP.AllocationId&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;SubnetId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;PrivateSubNett&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;RouteTablePrivate&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::RouteTable&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;VpcId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;VPC&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;RoutePrivate&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::Route&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;DestinationCidrBlock&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;0.0.0.0/0&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;RouteTableId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;RouteTablePrivate&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;NatGatewayId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;NatGW&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;Route2PrivateSubnet&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::SubnetRouteTableAssociation&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;RouteTableId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;RouteTablePrivate&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;SubnetId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;PrivateSubNett&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;putting-the-parts-together&quot;&gt;Putting the parts together&lt;/h2&gt;

&lt;p&gt;Now we combine the end product from previous blog and the last part, moving
sections around so they are logically grouped together.&lt;/p&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nn&quot;&gt;---&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;Description&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;This is an attempt to create a VPC in a Cloudformation stack&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;Resources&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;VPC&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;AWS::EC2::VPC&apos;&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;CidrBlock&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;10.0.0.0/16&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;InternetGW&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::InternetGateway&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;GatewayToInternet&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::VPCGatewayAttachment&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;VpcId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;VPC&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;InternetGatewayId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;InternetGW&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;NatGWIP&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;DependsOn&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;GatewayToInternet&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::EIP&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;Domain&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;vpc&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;NatGW&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::NatGateway&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;AllocationId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!GetAtt&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;NatGWIP.AllocationId&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;SubnetId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;PrivateSubNett&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;SubNett&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::Subnet&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;CidrBlock&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;10.0.42.0/24&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;VpcId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;VPC&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;PrivateSubNett&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::Subnet&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;CidrBlock&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;10.0.43.0/24&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;VpcId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;VPC&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;RouteTablePublic&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::RouteTable&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;VpcId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;VPC&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;RouteTablePrivate&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::RouteTable&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;VpcId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;VPC&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;RoutePublic&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::Route&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;DestinationCidrBlock&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;0.0.0.0/0&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;RouteTableId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;RouteTablePublic&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;GatewayId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;InternetGW&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;RoutePrivate&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::Route&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;DestinationCidrBlock&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;0.0.0.0/0&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;RouteTableId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;RouteTablePrivate&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;NatGatewayId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;NatGW&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;Route2Subnet&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::SubnetRouteTableAssociation&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;RouteTableId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;RouteTablePublic&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;SubnetId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;SubNett&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;Route2PrivateSubnet&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::SubnetRouteTableAssociation&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;RouteTableId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;RouteTablePrivate&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;SubnetId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;PrivateSubNett&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This makes up a template that will create a Private and a Public subnet.&lt;/p&gt;

&lt;h1 id=&quot;more-availability-zones&quot;&gt;More Availability Zones&lt;/h1&gt;

&lt;p&gt;Above, we did not say anything about the Availability Zone thing were
instantiated in. But now we want to create 3 Public subnets and 3 Private
subnets, with each Public and Private pair in distinct Availability Zones.&lt;/p&gt;

&lt;p&gt;But let us recap quickly what we need to define.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;A VPC, only one.&lt;/li&gt;
  &lt;li&gt;An Internet Gateway, only one.&lt;/li&gt;
  &lt;li&gt;A VPC Gateway Attachment, only one.&lt;/li&gt;
  &lt;li&gt;Elastic IPs, three of them, one for each NAT Gateway&lt;/li&gt;
  &lt;li&gt;NAT Gateways, three of them, one for each Availability Zone.&lt;/li&gt;
  &lt;li&gt;Subnets, six of them, one Private and one Public for each Availability Zone.&lt;/li&gt;
  &lt;li&gt;Route Tables, four total, one for the Public subnets, and one for each of
the Private subnets&lt;/li&gt;
  &lt;li&gt;Routes, four total, one for the Public subnets, and one for each of the
Private subnets&lt;/li&gt;
  &lt;li&gt;Subnet Associations, six total, one for each subnet.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So that is a lot of resources that need to be spelled out. And the only thing
that we are missing before we start copy’n’paste bonanza is a way to decide
which Availability Zone to instantiate our resources.&lt;/p&gt;

&lt;h2 id=&quot;specifying-the-availability-zone&quot;&gt;Specifying the Availability Zone&lt;/h2&gt;

&lt;p&gt;For specifying the Availability Zone for our resources we use the fact that
the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;AWS::EC2::Subnet&lt;/code&gt; resource has a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;AvailabilityZone&lt;/code&gt; parameter that can be
set. So if we are to create a subnet in the Stockholm region, we could use the
values:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;eu-north-1a&lt;/li&gt;
  &lt;li&gt;eu-north-1b&lt;/li&gt;
  &lt;li&gt;eu-north-1c&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;and we would be set.&lt;/p&gt;

&lt;p&gt;But what if we want to use the template in Singapore? Then we would have to
change those values. So that would be no good.&lt;/p&gt;

&lt;p&gt;What we should do is to use the intrinsic function &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Fn::GetAZs&lt;/code&gt; which returns
an array of the Availability Zones in a region. If the function only gets
empty &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&quot;&quot;&lt;/code&gt; it defaults to the region the template is instantiated in. Then we
need to use the intrinsic function &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Fn::Select&lt;/code&gt; to give use the first, the
second and the third Availability Zone in the region. (You can read more about
these functions
&lt;a href=&quot;https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-getavailabilityzones.html&quot;&gt;here&lt;/a&gt;
and
&lt;a href=&quot;https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-select.html&quot;&gt;here&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;!Select&lt;/code&gt; function takes an two element array, where the first element is
the index that you want, and the second element is the array you want to
select from, using the index given.&lt;/p&gt;

&lt;h2 id=&quot;combining-everything&quot;&gt;Combining everything&lt;/h2&gt;

&lt;p&gt;Let us combine this, but yet break it up in sections for clarity.&lt;/p&gt;

&lt;h3 id=&quot;vpc-and-internet-gateway&quot;&gt;VPC and Internet Gateway&lt;/h3&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nn&quot;&gt;---&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;Description&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;This is an attempt to create a VPC in a Cloudformation stack&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;Resources&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;VPC&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;AWS::EC2::VPC&apos;&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;CidrBlock&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;10.0.0.0/16&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;InternetGW&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::InternetGateway&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;GatewayToInternet&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::VPCGatewayAttachment&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;VpcId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;VPC&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;InternetGatewayId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;InternetGW&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;elastic-ip-addresses-for-the-nat-gateways&quot;&gt;Elastic IP addresses for the NAT Gateways&lt;/h3&gt;
&lt;p&gt;Here we start on the tedious repetion of similar resources, I postfix the name
of all that kind of resources with the number assosiated with the Availability
Zone index&lt;/p&gt;
&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  &lt;span class=&quot;na&quot;&gt;NatGWIP0&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;DependsOn&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;GatewayToInternet&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::EIP&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;Domain&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;vpc&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;NatGWIP1&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;DependsOn&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;GatewayToInternet&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::EIP&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;Domain&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;vpc&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;NatGWIP2&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;DependsOn&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;GatewayToInternet&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::EIP&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;Domain&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;vpc&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;all-the-subnets&quot;&gt;All the subnets…&lt;/h3&gt;
&lt;p&gt;The IP addresses chosen for each subnet is done this way to behave nicely in
the next blog entry.&lt;/p&gt;
&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  &lt;span class=&quot;na&quot;&gt;PublicSubnet0&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::Subnet&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;CidrBlock&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;10.0.0.0/24&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;VpcId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;VPC&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;AvailabilityZone&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;kt&quot;&gt;!Select&lt;/span&gt;
          &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;
          &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!GetAZs&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;PrivateSubnet0&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::Subnet&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;CidrBlock&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;10.0.100.0/24&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;VpcId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;VPC&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;AvailabilityZone&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;kt&quot;&gt;!Select&lt;/span&gt;
          &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;
          &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!GetAZs&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;PublicSubnet1&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::Subnet&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;CidrBlock&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;10.0.1.0/24&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;VpcId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;VPC&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;AvailabilityZone&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;kt&quot;&gt;!Select&lt;/span&gt;
          &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;1&lt;/span&gt;
          &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!GetAZs&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;PrivateSubnet1&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::Subnet&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;CidrBlock&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;10.0.101.0/24&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;VpcId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;VPC&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;AvailabilityZone&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;kt&quot;&gt;!Select&lt;/span&gt;
          &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;1&lt;/span&gt;
          &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!GetAZs&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;PublicSubnet2&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::Subnet&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;CidrBlock&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;10.0.2.0/24&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;VpcId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;VPC&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;AvailabilityZone&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;kt&quot;&gt;!Select&lt;/span&gt;
          &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;2&lt;/span&gt;
          &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!GetAZs&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;PrivateSubnet2&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::Subnet&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;CidrBlock&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;10.0.102.0/24&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;VpcId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;VPC&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;AvailabilityZone&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;kt&quot;&gt;!Select&lt;/span&gt;
          &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;2&lt;/span&gt;
          &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!GetAZs&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;the-nat-gateways&quot;&gt;The NAT Gateways&lt;/h3&gt;
&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  &lt;span class=&quot;na&quot;&gt;NatGW0&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::NatGateway&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;AllocationId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!GetAtt&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;NatGWIP0.AllocationId&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;SubnetId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;PrivateSubnet0&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;NatGW1&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::NatGateway&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;AllocationId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!GetAtt&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;NatGWIP1.AllocationId&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;SubnetId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;PrivateSubnet1&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;NatGW2&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::NatGateway&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;AllocationId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!GetAtt&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;NatGWIP2.AllocationId&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;SubnetId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;PrivateSubnet2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;the-route-tables&quot;&gt;The Route Tables&lt;/h3&gt;
&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  &lt;span class=&quot;na&quot;&gt;RouteTablePublic&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::RouteTable&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;VpcId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;VPC&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;RouteTablePrivate0&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::RouteTable&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;VpcId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;VPC&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;RouteTablePrivate1&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::RouteTable&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;VpcId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;VPC&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;RouteTablePrivate2&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::RouteTable&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;VpcId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;VPC&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;the-routes&quot;&gt;The Routes&lt;/h3&gt;
&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  &lt;span class=&quot;na&quot;&gt;RoutePublic&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::Route&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;DestinationCidrBlock&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;0.0.0.0/0&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;RouteTableId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;RouteTablePublic&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;GatewayId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;InternetGW&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;RoutePrivate0&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::Route&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;DestinationCidrBlock&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;0.0.0.0/0&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;RouteTableId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;RouteTablePrivate0&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;NatGatewayId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;NatGW0&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;RoutePrivate1&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::Route&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;DestinationCidrBlock&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;0.0.0.0/0&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;RouteTableId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;RouteTablePrivate1&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;NatGatewayId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;NatGW1&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;RoutePrivate2&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::Route&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;DestinationCidrBlock&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;0.0.0.0/0&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;RouteTableId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;RouteTablePrivate2&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;NatGatewayId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;NatGW2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;association-between-route-tables-and-subnets&quot;&gt;Association between route tables and subnets&lt;/h3&gt;
&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  &lt;span class=&quot;na&quot;&gt;Route2PublicSubnet0&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::SubnetRouteTableAssociation&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;RouteTableId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;RouteTablePublic&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;SubnetId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;PublicSubnet0&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;Route2PrivateSubnet0&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::SubnetRouteTableAssociation&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;RouteTableId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;RouteTablePrivate0&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;SubnetId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;PrivateSubnet0&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;Route2PublicSubnet1&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::SubnetRouteTableAssociation&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;RouteTableId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;RouteTablePublic&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;SubnetId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;PublicSubnet1&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;Route2PrivateSubnet1&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::SubnetRouteTableAssociation&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;RouteTableId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;RouteTablePrivate1&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;SubnetId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;PrivateSubnet1&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;Route2PublicSubnet2&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::SubnetRouteTableAssociation&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;RouteTableId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;RouteTablePublic&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;SubnetId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;PublicSubnet2&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;Route2PrivateSubnet2&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::SubnetRouteTableAssociation&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;RouteTableId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;RouteTablePrivate2&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;SubnetId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;PrivateSubnet2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And there is still thing missing here. We need to export references to the
resources created here, so that we can use them in other stacks. That and
other improvements await in the next chapter.&lt;/p&gt;
</description>
        <pubDate>Fri, 27 Nov 2020 00:00:00 +0000</pubDate>
        <link>/cloud/blog/2020/11/27/cloudformation-vpc2.html</link>
        <guid isPermaLink="true">/cloud/blog/2020/11/27/cloudformation-vpc2.html</guid>
        
        
        <category>IaC</category>
        
      </item>
    
      <item>
        <title>Starting with Cloudformation templates</title>
        <description>&lt;p&gt;This is not the place to tell anyone why Infrastructure as Code is a good
idea. For that I can point the potential readers to a blog by my colleague Yngve
about that: &lt;a href=&quot;https://www.redpill-linpro.com/blogs/agile-it-operations-cloud-and-devops/why-code-your-infrastructure&quot;&gt;Why code your infrastructure?&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I a short series of blogs, I intend to demonstrate building infrastructure in AWS
in steps, where I will be building upon previous entries. Basic knowledge of
network and VPC is assumed.&lt;/p&gt;

&lt;p&gt;Note that following these instructions can and will incur costs from AWS,
those are the sole responsibility of the user, not me.&lt;/p&gt;

&lt;h2 id=&quot;what-is-cloudformation&quot;&gt;What is Cloudformation?&lt;/h2&gt;

&lt;p&gt;Cloudformation is AWS way of doing &lt;a href=&quot;https://aws.amazon.com/cloudformation/&quot;&gt;Infrastructure as
Code&lt;/a&gt;. The templates can be written in
YAML or JSON. We will only look at the YAML format as that is the one that is
actually human readable.&lt;/p&gt;

&lt;h3 id=&quot;resource-for-information&quot;&gt;Resource for information&lt;/h3&gt;
&lt;p&gt;The AWS documentation on Cloudformation is outstanding. I do not try to
construct anything in AWS without the guidance of the
&lt;a href=&quot;https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-reference.html&quot;&gt;documentation&lt;/a&gt;.
As a side note, the navigation in the AWS documentation is terrible, use a
search engine as DuckDuckGo or Google (the brave might want to try Bing) to
find what you are looking for.&lt;/p&gt;

&lt;p&gt;The term &lt;em&gt;stack&lt;/em&gt; is used a lot here. We call the collection of resources
created from the templates a &lt;em&gt;stack.&lt;/em&gt;&lt;/p&gt;

&lt;h3 id=&quot;anatomy-of-a-template&quot;&gt;Anatomy of a template&lt;/h3&gt;
&lt;p&gt;The template can consists of following sections&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Description&lt;/li&gt;
  &lt;li&gt;Metadata&lt;/li&gt;
  &lt;li&gt;Parameters&lt;/li&gt;
  &lt;li&gt;Mappings&lt;/li&gt;
  &lt;li&gt;Conditions&lt;/li&gt;
  &lt;li&gt;Resources&lt;/li&gt;
  &lt;li&gt;Outputs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Of these, only the Resources section is required.&lt;/p&gt;

&lt;h4 id=&quot;description&quot;&gt;Description&lt;/h4&gt;
&lt;p&gt;Just a free text that can be used as a description for your stack.&lt;/p&gt;

&lt;h4 id=&quot;metadata&quot;&gt;Metadata&lt;/h4&gt;
&lt;p&gt;You can use the optional Metadata section to include arbitrary JSON or YAML
objects that provide details about the template. I have yet to be bothered.&lt;/p&gt;

&lt;h4 id=&quot;parameters&quot;&gt;Parameters&lt;/h4&gt;
&lt;p&gt;Variables to your stack, can be used to build different environments depending
on the values. Values of the individual parameters can be defined in an
external JSON structure.&lt;/p&gt;

&lt;h4 id=&quot;mappings&quot;&gt;Mappings&lt;/h4&gt;
&lt;p&gt;Used for different sets of values for a specific key. So you can have a list
of AMIs for each AWS Region, or set of different EC2 instance types depending
on whether the environment should be stage or production.&lt;/p&gt;

&lt;h4 id=&quot;conditions&quot;&gt;Conditions&lt;/h4&gt;
&lt;p&gt;Here you can define boolean variables that can be used as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Condition&lt;/code&gt; field in
the Resources section&lt;/p&gt;

&lt;h4 id=&quot;resources&quot;&gt;Resources&lt;/h4&gt;
&lt;p&gt;This is the main part. Here all the definition of the environment is done.&lt;/p&gt;

&lt;h4 id=&quot;outputs&quot;&gt;Outputs&lt;/h4&gt;
&lt;p&gt;Here you can define and format values that are easily accessible from querying
your stack, and also define values that are exported from your stack and can
be imported into other stacks. Each export from a stack needs to have an unique
name within a Region (within your AWS account)&lt;/p&gt;

&lt;h3 id=&quot;regarding-tags&quot;&gt;Regarding tags&lt;/h3&gt;
&lt;p&gt;For this write up, I gloss over the usage of tags, in my opinion one can do
that in the learning phase, but tags are really useful assets to use. So I
would encourage users to spend some time designing a tag regime for their
resources, and manage those through Cloudformation.&lt;/p&gt;

&lt;h2 id=&quot;starting-on-your-first-stack&quot;&gt;Starting on your first stack&lt;/h2&gt;

&lt;p&gt;Let us create a VPC. If you have not done this before, I highly recommend you
to start by looking at the AWS documentation at
&lt;a href=&quot;https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-vpc.html&quot;&gt;AWS::EC2::VPC&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the section &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Syntax&lt;/code&gt; we get the following YAML code:&lt;/p&gt;
&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::VPC&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;CidrBlock&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;String&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;EnableDnsHostnames&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Boolean&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;EnableDnsSupport&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Boolean&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;InstanceTenancy&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;String&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;Tags&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Tag&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;If we then read on the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Properties&lt;/code&gt; section, we see that the only thing that
is &lt;em&gt;required&lt;/em&gt; is the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CidrBlock&lt;/code&gt;, so by stripping all other entries from the
YAML we end up with this minimal Cloudformation template&lt;/p&gt;

&lt;h3 id=&quot;small-steps&quot;&gt;Small steps&lt;/h3&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nn&quot;&gt;---&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;Description&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;This is an attempt to create a VPC in a Cloudformation stack&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;Resources&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;VPC&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;AWS::EC2::VPC&apos;&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;CidrBlock&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;10.0.0.0/16&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;If we save this to a file called vpc.yaml then we can create a VPC with a
command like this, given we have a CLI profile called &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;blogg&lt;/code&gt; (more about AWS
CLI and profiles &lt;a href=&quot;https://www.redpill-linpro.com/techblog/2020/02/18/awscli.html&quot;&gt;here&lt;/a&gt; :&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;jonas@pigz:~/bløgg&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;aws &lt;span class=&quot;nt&quot;&gt;--profile&lt;/span&gt; blogg cloudformation create-stack &lt;span class=&quot;nt&quot;&gt;--stack-name&lt;/span&gt; myawesomeVPC &lt;span class=&quot;nt&quot;&gt;--template-body&lt;/span&gt; file://vpc.yaml
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&quot;StackId&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;arn:aws:cloudformation:eu-central-1:123NaN123201:stack/myawesomeVPC/b9fe6cab-9dfc-4839-b5eb-16bed311730c&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
jonas@pigz:~/bløgg&lt;span class=&quot;err&quot;&gt;$&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;After a short while the stack has been created and the VPC has come to
existence&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;jonas@pigz ~/bløgg&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;aws &lt;span class=&quot;nt&quot;&gt;--profile&lt;/span&gt; blogg cloudformation describe-stacks &lt;span class=&quot;nt&quot;&gt;--stack-name&lt;/span&gt; myawesomeVPC
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&quot;Stacks&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;s2&quot;&gt;&quot;StackId&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;arn:aws:cloudformation:eu-central-1:123NaN123201:stack/myawesomeVPC/b9fe6cab-9dfc-4839-b5eb-16bed311730c&quot;&lt;/span&gt;,
            &lt;span class=&quot;s2&quot;&gt;&quot;StackName&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;myawesomeVPC&quot;&lt;/span&gt;,
            &lt;span class=&quot;s2&quot;&gt;&quot;Description&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;This is an attempt to create a VPC in a Cloudformation stack&quot;&lt;/span&gt;,
            &lt;span class=&quot;s2&quot;&gt;&quot;CreationTime&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;2020-02-30T25:66:42.898Z&quot;&lt;/span&gt;,
            &lt;span class=&quot;s2&quot;&gt;&quot;RollbackConfiguration&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;{}&lt;/span&gt;,
            &lt;span class=&quot;s2&quot;&gt;&quot;StackStatus&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;CREATE_COMPLETE&quot;&lt;/span&gt;,
            &lt;span class=&quot;s2&quot;&gt;&quot;DisableRollback&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;false&lt;/span&gt;,
            &lt;span class=&quot;s2&quot;&gt;&quot;NotificationARNs&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[]&lt;/span&gt;,
            &lt;span class=&quot;s2&quot;&gt;&quot;Tags&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;[]&lt;/span&gt;,
            &lt;span class=&quot;s2&quot;&gt;&quot;EnableTerminationProtection&quot;&lt;/span&gt;: &lt;span class=&quot;nb&quot;&gt;false&lt;/span&gt;,
            &lt;span class=&quot;s2&quot;&gt;&quot;DriftInformation&quot;&lt;/span&gt;: &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;s2&quot;&gt;&quot;StackDriftStatus&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;NOT_CHECKED&quot;&lt;/span&gt;
            &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;next-step&quot;&gt;Next step&lt;/h3&gt;

&lt;p&gt;As this is rather useless as it is, let us add a subnet, we check &lt;a href=&quot;https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-subnet.html&quot;&gt;the
documentation on the AWS
website&lt;/a&gt;
and get the following YAML for a subnet definition&lt;/p&gt;
&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::Subnet&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;AssignIpv6AddressOnCreation&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Boolean&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;AvailabilityZone&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;String&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;CidrBlock&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;String&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;Ipv6CidrBlock&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;String&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;MapPublicIpOnLaunch&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Boolean&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;Tags&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Tag&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;VpcId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;String&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The only properties values that must be set are &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;VpcId&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CidrBlock&lt;/code&gt;. The
value of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;VpcId&lt;/code&gt; comes from the Resource created before, and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CidrBlock&lt;/code&gt; needs
to be a CIDR inside the VPC CIDR.&lt;/p&gt;

&lt;p&gt;So with that we modify the old yaml structure to&lt;/p&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nn&quot;&gt;---&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;Description&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;This is an attempt to create a VPC in a Cloudformation stack&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;Resources&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;VPC&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;AWS::EC2::VPC&apos;&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;CidrBlock&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;10.0.0.0/16&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;SubNett&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::Subnet&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;CidrBlock&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;10.0.42.0/24&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;VpcId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;s&quot;&gt;Fn::Ref: VPC&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Note that we use the intrinsic function &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Fn::Ref&lt;/code&gt; there. In this case it
returns the value of the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;AWS::EC2::VPC&lt;/code&gt; resource, so we do not need to hard
code it into the template. Read more about the &lt;a href=&quot;https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference.html&quot;&gt;intrinsic function here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can then update our first stack to with those changes&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;jonas@pigz:~/bløgg&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;aws &lt;span class=&quot;nt&quot;&gt;--profile&lt;/span&gt; blogg cloudformation update-stack &lt;span class=&quot;nt&quot;&gt;--stack-name&lt;/span&gt; myawesomeVPC &lt;span class=&quot;nt&quot;&gt;--template-body&lt;/span&gt; file://vpc.yaml
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&quot;StackId&quot;&lt;/span&gt;: &lt;span class=&quot;s2&quot;&gt;&quot;arn:aws:cloudformation:eu-central-1:123NaN123201:stack/myawesomeVPC/19cb1c41-b3cb-4a1b-9d75-aef7df5fddb4&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
jonas@pigz:~/bløgg&lt;span class=&quot;err&quot;&gt;$&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;What we would then have is a VPC with a subnet with no access to
anything. It could be used for EC2 instances talking to each other, but that would
be about all that you could do. In other words, not that useful.&lt;/p&gt;

&lt;h3 id=&quot;internet-connectivity&quot;&gt;Internet connectivity&lt;/h3&gt;

&lt;p&gt;So what is needed to have connectivity to the Internet is an Internet Gateway,
That is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;AWS::EC2::InternetGateway&lt;/code&gt; in Cloudformation. If we read the
documentation for it is only&lt;/p&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::InternetGateway&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;Tags&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Tag&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;and the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Tags&lt;/code&gt; element is not required, so let us add that to our template.&lt;/p&gt;
&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nn&quot;&gt;---&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;Description&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;This is an attempt to create a VPC in a Cloudformation stack&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;Resources&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;VPC&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;AWS::EC2::VPC&apos;&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;CidrBlock&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;10.0.0.0/16&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;SubNett&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::Subnet&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;CidrBlock&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;10.0.42.0/24&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;VpcId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;s&quot;&gt;Fn::Ref: VPC&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;InternetGW&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::InternetGateway&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;But that gateway is not connected to our VPC at all. For that we need VPC
Gateway Attachment, which is defined with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;AWS::EC2::VPCGatewayAttachment&lt;/code&gt; and
is described in the documentation as&lt;/p&gt;
&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::VPCGatewayAttachment&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;InternetGatewayId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;String&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;VpcId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;String&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;VpnGatewayId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;String&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;where we must declare one and only one of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;InternetGatewayId&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;VpnGatewayId&lt;/code&gt;, we are
not dealing with a VPN, so our entry is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;InternetGatewayId&lt;/code&gt;. Adding to our
main template it becomes&lt;/p&gt;
&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nn&quot;&gt;---&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;Description&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;This is an attempt to create a VPC in a Cloudformation stack&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;Resources&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;VPC&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;AWS::EC2::VPC&apos;&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;CidrBlock&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;10.0.0.0/16&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;SubNett&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::Subnet&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;CidrBlock&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;10.0.42.0/24&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;VpcId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;VPC&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;InternetGW&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::InternetGateway&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;GatewayToInternet&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::VPCGatewayAttachment&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;VpcId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;VPC&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;InternetGatewayId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;InternetGW&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Notice that we have now gone over to the short notation of the intrinsic
function &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Fn::Ref&lt;/code&gt; which is just &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;!Ref&lt;/code&gt;. There is a limitation on the short
notation that you can not chain them, but that is a worry for another time.&lt;/p&gt;

&lt;p&gt;The subnet that would be managed with this template is one still without
Internet connection, as there is no routing there yet.&lt;/p&gt;

&lt;h3 id=&quot;routing&quot;&gt;Routing&lt;/h3&gt;

&lt;p&gt;We first need a route table, then a route in that route table, and then we
need to attach the route table to our subnet. In order, the elements we need
are: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;AWS::EC2::RouteTable&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;AWS::EC2::Route&lt;/code&gt; and
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;AWS::EC2::SubnetRouteTableAssociation&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The documentation for those elements gives us&lt;/p&gt;
&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::RouteTable&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;Tags&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Tag&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;VpcId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;String&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Here, the tags are optional.&lt;/p&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::Route&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;DestinationCidrBlock&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;String&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;DestinationIpv6CidrBlock&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;String&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;EgressOnlyInternetGatewayId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;String&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;GatewayId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;String&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;InstanceId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;String&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;NatGatewayId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;String&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;NetworkInterfaceId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;String&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;RouteTableId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;String&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;TransitGatewayId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;String&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;VpcPeeringConnectionId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;String&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Here the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;RouteTableId&lt;/code&gt; is mandatory, and we want to connect it to our gateway
so we use the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GatewayId&lt;/code&gt; element.&lt;/p&gt;

&lt;p&gt;Also the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;DestinationCidrBlock&lt;/code&gt; is mandatory (or the
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;DestinationIpv6CidrBlock&lt;/code&gt; if you are defining IPv6 network). Here we would
have the destination 0.0.0.0/0, AKA everything. So all traffic not going to
the IP range of the VPC will be sent to that route.&lt;/p&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::SubnetRouteTableAssociation&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;RouteTableId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;String&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;SubnetId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;String&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Both are required.&lt;/p&gt;

&lt;p&gt;So when we combine all this, we get:&lt;/p&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nn&quot;&gt;---&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;Description&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;This is an attempt to create a VPC in a Cloudformation stack&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;Resources&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;VPC&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;AWS::EC2::VPC&apos;&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;CidrBlock&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;10.0.0.0/16&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;SubNett&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::Subnet&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;CidrBlock&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;10.0.42.0/24&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;VpcId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;VPC&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;InternetGW&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::InternetGateway&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;GatewayToInternet&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::VPCGatewayAttachment&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;VpcId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;VPC&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;InternetGatewayId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;InternetGW&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;RouteTablePublic&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::RouteTable&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;VpcId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;VPC&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;RoutePublicIPv4&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::Route&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;DestinationCidrBlock&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;0.0.0.0/0&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;RouteTableId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;RouteTablePublic&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;GatewayId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;InternetGW&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;Route2Subnet&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;AWS::EC2::SubnetRouteTableAssociation&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;RouteTableId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;RouteTablePublic&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;SubnetId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;!Ref&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;SubNett&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And with that template, we have a functioning VPC with a subnet that can
connect to the internet. In later blogs I will build upon this template to
create a production ready VPC, and then build environments in those VPCs. Stay
tuned.&lt;/p&gt;
</description>
        <pubDate>Mon, 21 Sep 2020 00:00:00 +0000</pubDate>
        <link>/cloud/blog/2020/09/21/cloudformation-vpc.html</link>
        <guid isPermaLink="true">/cloud/blog/2020/09/21/cloudformation-vpc.html</guid>
        
        
        <category>IaC</category>
        
      </item>
    
      <item>
        <title>Why Machine Learning models should run in Containers</title>
        <description>&lt;p&gt;Machine Learning (ML) is being implemented to varying extents in businesses all over. However, seamlessly integrating ML workflows into existing infrastructure can be somewhat challenging. This is the first article in a series on DevOps for Machine Learning - how to automate the ML process. In this chapter we will explore the benefits of running ML models as microservices and with what tools.&lt;/p&gt;

&lt;h2 id=&quot;why-containers-in-the-first-place&quot;&gt;Why containers in the first place?&lt;/h2&gt;

&lt;p&gt;The initial demand for this solution came years ago. Software developers identified the need for better isolating installations and workloads on servers, without going for the more heavy-weight virtual machine strategy (vm).&lt;/p&gt;

&lt;p&gt;For developers in particular, a smooth running of their application code outside of their laptop was not automatically a given. Different versions of software, other types of OS distributions and differing underlying infrastructure could easily create disturbance.&lt;/p&gt;

&lt;p&gt;With the advent of Docker in 2013, containers became an increasingly popular solution to this problem. By running the application on a generic platform (PaaS), you can isolate the code and all of its dependencies in a container, where it can run effortlessly in any environment.&lt;/p&gt;

&lt;p&gt;Upgrades and maintenance work done to the underlying infrastructure or OS, will therefore not compromise the code-dependecies of the application in the container.&lt;/p&gt;

&lt;p&gt;Also, by moving application state to remote databases, containers can easily be discarded and spun up, enabling manageability and scale on a new level.&lt;/p&gt;

&lt;figure&gt;
  &lt;a href=&quot;/cloud/images/posts/Containers_illustration.jpg&quot; rel=&quot;lightbox&quot;&gt; 
   &lt;img class=&quot;single&quot; src=&quot;/cloud/images/posts/Containers_illustration.jpg&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
  &lt;figcaption&gt;&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;h2 id=&quot;so-how-do-you-implement-a-ml-model-in-a-container&quot;&gt;So how do you implement a ML model in a container?&lt;/h2&gt;

&lt;p&gt;A natural fit would be to wrap the model in a microservice. This is a REST based concept where the components of an application communicate over http instead of direct function calls.&lt;/p&gt;

&lt;p&gt;This approach decouples the ML model from specific applications, giving the model a separate lifecycle while simultaneously offering the API endpoints to other applications.&lt;/p&gt;

&lt;p&gt;There are several other benefits of running your ML model in this way. A container is more lightweight in comparison to a vm. It also transports well from training to testing and deployment. Having all dependencies wrapped up in a container there is no longer a problem with training your model from different environments.&lt;/p&gt;

&lt;p&gt;Also, if several teammates are collaborating on the same model project, conflicts with existing versions of for example Python or Tensorflow will not affect the training itself. The container can be spun up anywhere, anytime, and will always be an exact duplicate of the original container image, whether it is right now, in a month or in years.&lt;/p&gt;

&lt;p&gt;Furthermore, exposing your model container as an endpoint will separate it from its serving infrastructure, supporting decoupled architecture. This means that if you ever want to exchange the existing model for another, or implement it with other services, it is an easy switch and integration.&lt;/p&gt;

&lt;p&gt;Last, but not least, containers need orchestration to be able to take full advantage of all the benefits. Orchestration manages traffic, meaning it can automatically provision, deploy and kill off containers according to the volume of queries from the application.&lt;/p&gt;

&lt;p&gt;This presents several other convenient advantages for ML practitioners. One of them is for large training jobs. Orchestration can help you distribute the job over several nodes or containers, reducing the total amount of time to finish.&lt;/p&gt;

&lt;p&gt;You can also train in parallel. Another benefit is the possibility of A/B testing for more robust models, this is well known to software developers. Here you can select subsets of the user-base to test the new model on, assessing directly whether your retrained model actually yields an improvement.&lt;/p&gt;

&lt;p&gt;Furthermore you can roll out, test, deploy and roll back again as you like and whenever you want.&lt;/p&gt;

&lt;figure&gt;
  &lt;a href=&quot;/cloud/images/posts/Container_tools.jpg&quot; rel=&quot;lightbox&quot;&gt; 
   &lt;img class=&quot;single&quot; src=&quot;/cloud/images/posts/Container_tools.jpg&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
  &lt;figcaption&gt;&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;h3 id=&quot;the-tool-box&quot;&gt;The tool box&lt;/h3&gt;

&lt;p&gt;On the tool side, Docker also offers Docker Hub, a free “store” offering an enormous set of ready-build images, both official ones from differing development communities and more informal ones from enthusiasts.&lt;/p&gt;

&lt;p&gt;The quality does vary, but you can find container images offering eg. R or Tensorflow that will ease the initial setup. It should be noted that Docker is not the only player in this scene.RedHat has developed a drop-in replacement called Podman and also offers its own officially supported container image registry.&lt;/p&gt;

&lt;p&gt;On the orchestration side, there is a plethora of solutions like Docker Swarm, Kubernetes and OKD/OpenShift (which utilises Kubernetes). Perhaps the easiest way to get started is by using a PaaS solution from a public cloud provider like AWS or Azure. They have a variety of options you can choose from.&lt;/p&gt;

&lt;p&gt;With AWS, you could either do it from scratch, setting up a Docker container on a EC2 instance, or use the ready made ECS container service. In terms of orchestration you can run Kubernetes or Open Shift directly on the AWS platform, or you can use their EKS or ECS solutions where AWS offers prebuilt orchestration services.&lt;/p&gt;

&lt;p&gt;Why not try and set your model up in a container the next time and see for yourself?&lt;/p&gt;

&lt;!-- Contact --&gt;
&lt;div class=&quot;two spacing&quot;&gt;&lt;/div&gt;
&lt;div class=&quot;row&quot;&gt;
  &lt;div class=&quot;medium-12 medium-centered columns&quot;&gt;
    






&lt;div class=&quot;rl-contact-box-wrapper&quot;&gt;


  &lt;div class=&quot;rl-contact-box content row&quot;&gt;
    &lt;div class=&quot;small-1 column&quot;&gt;&amp;nbsp;&lt;/div&gt;
    
    &lt;div class=&quot;small-1 medium-4 column&quot;&gt;
      &lt;div class=&quot;rl-contact-image&quot;&gt;
        
        
&lt;div class=&quot;rl-image-ratio-block&quot; style=&quot;background-image:url(/cloud/images/employees/mia.jpg)&quot;&gt;&lt;/div&gt;

      &lt;/div&gt;
    &lt;/div&gt;
    
    &lt;div class=&quot;small-10 medium-6 column end&quot;&gt;
      &lt;div class=&quot;rl-contact-text&quot;&gt;
        &lt;h2 class=&quot;rl-contact-heading&quot;&gt;Contact&lt;/h2&gt;
        &lt;p&gt;&lt;span class=&quot;rl-contact-name&quot;&gt;Mia Ryan&lt;/span&gt;&lt;br /&gt;
           &lt;span class=&quot;rl-contact-title&quot;&gt;Sales Advisor at Redpill&amp;nbsp;Linpro&lt;/span&gt;&lt;br /&gt;
           &lt;a class=&quot;button rl-contact-link&quot; href=&quot;/cloud/contact.html&quot;&gt;Contact&lt;/a&gt;&lt;br /&gt;
        &lt;/p&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;two spacing&quot;&gt;&lt;/div&gt;




  &lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;two spacing&quot;&gt;&lt;/div&gt;
</description>
        <pubDate>Mon, 25 May 2020 00:00:00 +0000</pubDate>
        <link>/cloud/blog/2020/05/25/MLmodelsincontainers.html</link>
        <guid isPermaLink="true">/cloud/blog/2020/05/25/MLmodelsincontainers.html</guid>
        
        
        <category>IaC</category>
        
      </item>
    
      <item>
        <title>Is your data green enough?</title>
        <description>&lt;p&gt;&lt;b&gt;“Companies that opt to delay sustainable priorities over the next five years will find it impossible to catch up as sustainable business continues to become a new standard.”&lt;/b&gt;&lt;/p&gt;

&lt;h4 id=&quot;sustainability&quot;&gt;Sustainability&lt;/h4&gt;
&lt;p&gt;(Instalment 1 of 3)&lt;/p&gt;

&lt;figure&gt;
  &lt;a href=&quot;/cloud/images/posts/notebook-405755_1280.jpg&quot; rel=&quot;lightbox&quot;&gt; 
   &lt;img class=&quot;single&quot; src=&quot;/cloud/images/posts/notebook-405755_1280.jpg&quot; alt=&quot;Green computing&quot; /&gt;&lt;/a&gt;
  &lt;figcaption&gt;Green computing&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;The above quote is from &lt;a href=&quot;https://www.gartner.com/en/doc/713748-strategies-to-build-and-advance-sustainability-programs-in-logistics&quot;&gt;Gartner&lt;/a&gt; who says this in the analysis “Build and advance sustainability programs”. Although primarily directed at the logistics business, the analysis is based on key factors that are just as important for the IT-sector and it’s data centers.&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Data centers throughout the world are now using  approximately 3 % of the worlds available energy (about the same as Great Britain), and are responsible for 2 % of the worlds total carbon dioxide emissions.&lt;/li&gt;
  &lt;li&gt;This is now more than the aviation industry, and these numbers are expected to double every 4 years.&lt;/li&gt;
  &lt;li&gt;This - obviously - cannot continue.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;According to Gartner (and trends we see emerging more and more) - you should not be satisfied with this. Regardless of which part of this supply chain you are a part of, if you want to keep your business/customers, you have to change towards green.&lt;/p&gt;

&lt;h4 id=&quot;consumers&quot;&gt;Consumers&lt;/h4&gt;
&lt;p&gt;There is a big push towards sustainability in the consumer market. &lt;a href=&quot;https://www.forbes.com/sites/solitairetownsend/2018/11/21/consumers-want-you-to-help-them-make-a-difference/#76a736a56954&quot;&gt;Forbes&lt;/a&gt; did a survey about this and concluded: “Our survey revealed an overwhelming demand for brands to step up on sustainable lifestyles. If your brand isn’t helping your consumers improve their environmental and social footprint, then you’re in danger of disappointing 88% of them.”
This trend among consumers is coming to the IT-sector and it’s data centers as well. Should you, as a supplier in this market, follow your customers? Undoubtedly. But even better: Get there before them.&lt;/p&gt;

&lt;h4 id=&quot;suppliers&quot;&gt;Suppliers&lt;/h4&gt;
&lt;p&gt;Some suppliers have already worked on this; Microsoft has a &lt;a href=&quot;https://azure.microsoft.com/en-us/blog/microsoft-sustainability-calculator-helps-enterprises-analyze-the-carbon-emissions-of-their-it-infrastructure/&quot;&gt;sustainability calculator&lt;/a&gt; that helps the customer see how much of what kind of energy goes into their server rig, either on-premises or in Azure. They also announced that they  were 100% powered by renewable energy already in 2014, although by purchasing RECs (renewable energy credits).&lt;/p&gt;

&lt;p&gt;Amazon (AWS) are building huge &lt;a href=&quot;https://aws.amazon.com/about-aws/sustainability/&quot;&gt;wind and solar farms&lt;/a&gt; to help them in their goal of achieving net zero carbon emissions by 2040.&lt;/p&gt;

&lt;p&gt;Maybe the best idea so far is the dutch company Nerdalize who instead of putting their customers servers in data centers, put them in &lt;a href=&quot;https://www.theverge.com/2017/6/2/15728232/using-servers-to-heat-homes-nerdalize&quot;&gt;private households to heat radiators and water.&lt;/a&gt;  (Unfortunately, they seem to have gone out of business since their crowdfunded startup in 2017).&lt;/p&gt;

&lt;p&gt;&lt;b&gt;There is a big challenge here:&lt;/b&gt; IT is rather dependent on electricity. Servers and data centers cannot just turn off the power at night to be environmentally and politically correct. There are however quite a few ways to be environmentally aware about this. Read the next instalment to learn more.&lt;/p&gt;

&lt;!-- Contact --&gt;
&lt;div class=&quot;two spacing&quot;&gt;&lt;/div&gt;
&lt;div class=&quot;row&quot;&gt;
  &lt;div class=&quot;medium-12 medium-centered columns&quot;&gt;
    






&lt;div class=&quot;rl-contact-box-wrapper&quot;&gt;


  &lt;div class=&quot;rl-contact-box content row&quot;&gt;
    &lt;div class=&quot;small-1 column&quot;&gt;&amp;nbsp;&lt;/div&gt;
    
    &lt;div class=&quot;small-1 medium-4 column&quot;&gt;
      &lt;div class=&quot;rl-contact-image&quot;&gt;
        
        
&lt;div class=&quot;rl-image-ratio-block&quot; style=&quot;background-image:url(/cloud/images/employees/yngve.jpg)&quot;&gt;&lt;/div&gt;

      &lt;/div&gt;
    &lt;/div&gt;
    
    &lt;div class=&quot;small-10 medium-6 column end&quot;&gt;
      &lt;div class=&quot;rl-contact-text&quot;&gt;
        &lt;h2 class=&quot;rl-contact-heading&quot;&gt;Contact&lt;/h2&gt;
        &lt;p&gt;&lt;span class=&quot;rl-contact-name&quot;&gt;Yngve Sandal&lt;/span&gt;&lt;br /&gt;
           &lt;span class=&quot;rl-contact-title&quot;&gt;Architect at Redpill&amp;nbsp;Linpro&lt;/span&gt;&lt;br /&gt;
           &lt;a class=&quot;button rl-contact-link&quot; href=&quot;/cloud/contact.html&quot;&gt;Contact&lt;/a&gt;&lt;br /&gt;
        &lt;/p&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;two spacing&quot;&gt;&lt;/div&gt;




  &lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;two spacing&quot;&gt;&lt;/div&gt;
</description>
        <pubDate>Fri, 17 Apr 2020 00:00:00 +0000</pubDate>
        <link>/cloud/blog/2020/04/17/is_your_code_green_1.html</link>
        <guid isPermaLink="true">/cloud/blog/2020/04/17/is_your_code_green_1.html</guid>
        
        
        <category>Cloud</category>
        
      </item>
    
      <item>
        <title>Why code your infrastructure?</title>
        <description>&lt;p&gt;&lt;b&gt;One of the more popular buzz terms in infrastructure and cloud discussions these days is “Infrastructure as code”. But what is that exactly? How can infrastructure - previously supposed to consist of cabling, metal chassises and computer hardware - suddenly be lines of code? This article will assume that you are new to this field and will try to explain it from that point of view. &lt;/b&gt;&lt;/p&gt;

&lt;h4 id=&quot;what-it-is&quot;&gt;What it is&lt;/h4&gt;
&lt;p&gt;Very simply put, it is writing configuration files for how your infrastructure should look, and has been referred to as the Swiss army knife for both developers and systems administrators.&lt;/p&gt;

&lt;div class=&quot;row&quot;&gt;
  &lt;div class=&quot;medium-6 columns&quot;&gt;
    &lt;figure&gt;
      &lt;a href=&quot;/cloud/images/posts/code-1839406_640.jpg&quot; rel=&quot;lightbox&quot;&gt; 
        &lt;img src=&quot;/cloud/images/posts/code-1839406_640.jpg&quot; alt=&quot;Code&quot; /&gt;&lt;/a&gt;
      &lt;figcaption&gt;Code&lt;/figcaption&gt;
    &lt;/figure&gt; 
  &lt;/div&gt;
  &lt;div class=&quot;medium-6 columns&quot;&gt;
    &lt;figure&gt;
      &lt;a href=&quot;/cloud/images/posts/server-3100049_640.jpg&quot; rel=&quot;lightbox&quot;&gt; 
        &lt;img src=&quot;/cloud/images/posts/server-3100049_640.jpg&quot; alt=&quot;Infrastructure&quot; /&gt;&lt;/a&gt;
      &lt;figcaption&gt;Infrastructure&lt;/figcaption&gt;
    &lt;/figure&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Infrastructure_as_code&quot;&gt;Wikipedia&lt;/a&gt; tells us that it “is the process of managing and provisioning computer data centers through machine-readable definition files, rather than physical hardware configuration or interactive configuration tools.The IT infrastructure managed by this comprises both physical equipment such as bare-metal servers as well as virtual machines and associated configuration resources.”&lt;/p&gt;

&lt;p&gt;Although Infrastructure as Code (IaC) may be used to provision your data center, it is the advent of cloud computing that has really brought forth its value. Cloud computing, Infrastructure-as-a-Service (IaaS) and DevOps are all dependent on IaC, DevOps specifically because of the need for agile work processes and automated workflows.&lt;/p&gt;

&lt;p&gt;So Infrastructure as code is just code.&lt;/p&gt;

&lt;h4 id=&quot;benefits&quot;&gt;Benefits&lt;/h4&gt;
&lt;p&gt;There has to be some, right?&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Speed and simplicity. IaC lets you spin up an entire infrastructure of virtual servers, launch pre-configured databases,  network infrastructure, load balancers, storage and whatever else it consists of, simply by running a script.&lt;/li&gt;
  &lt;li&gt;Configuration Consistency. Even with good documentations and standards, there will always be the chance of some deviation  just from how that person executing the task chooses to do it. With IaC, the risk of this is severely reduced.&lt;/li&gt;
  &lt;li&gt;Minimization of risk. IaC not only automates the process, it also serves as a documentation of sorts - a description of how to create infrastructure. This will make the anxiety of that one engineer that knows everything quitting fade away to nothing. IaC - done correctly - is like a blueprint of your datacenter&lt;/li&gt;
  &lt;li&gt;Cost savings. Spend less time doing manual and repeating work and more on tasks that creates value for your company. IaC can also help you spin down again environments when they are no longer in use, saving money that way.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;how-to-do-it&quot;&gt;How to do it&lt;/h4&gt;
&lt;p&gt;    There are a lot of tools available, both paid and free, open source and closed. Some may only be used with a specific provider, and some are provider-agnostic. We separate between configuration &lt;strong&gt;&lt;em&gt;orchestration&lt;/em&gt;&lt;/strong&gt; tools and configuration &lt;strong&gt;&lt;em&gt;management&lt;/em&gt;&lt;/strong&gt; tools.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Configuration orchestration tools&lt;/strong&gt; are what you use to automate the deployment of servers and other infrastructure. 
Each of the three major public cloud providers each have their own tool, which can only be used there. 
AWS has CloudFormation, Google Cloud has Google Cloud Deployment Manager, and Microsoft Azure has Azure Resource Manager. In addition there is TerraForm from Hashicorp, which to some degree can be used on all the public cloud providers simultaneously and in addition integrate other third-party systems. The configuration languages used range from JSON and YAML to Python.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Configuration management tools&lt;/strong&gt; are what you use for setting up and configuring systems, software and services on the before mentioned servers. There are a multitude of tools available for this, some of the most well-known are&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Chef - where you create recipes and cookbooks in Ruby&lt;/li&gt;
  &lt;li&gt;Puppet - where you use Ruby to declare the state you want your systems to have and what they are supposed to do and Puppet will figure out how to get there (very simply put)&lt;/li&gt;
  &lt;li&gt;Saltstack - also a declarative tool using Python
Some mentioned, a lot not mentioned, but not forgotten.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But it is - of course - not that clean and simple. There are some overlapping here between orchestration and management tools which you will find out once you start trying this out. Finding the tool(s) that best suit your needs is a major part of this undertaking.&lt;/p&gt;

&lt;p&gt;(Some of the) &lt;strong&gt;Best Practices&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Codify everything.&lt;/strong&gt; Every part of your infrastructure and system specifications that are put into code is a part where you have solid documentation and where you don’t have to put in manual work when having to recreate it&lt;/li&gt;
  &lt;li&gt;Version Control. Source repository tools lik Git, Mercurial, Subversion, CodeCommit or similar should/must be used. This way you can keep your sanity when trying to track changes, you can also do rollbacks easily and make collaboration work.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Continuously test, integrate and deploy.&lt;/strong&gt; IaC needs to be a part of your CI/CD plans, and is simultaneously a tool you can use to make your CI/CD work more smoothly.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Make the infrastructure code modular.&lt;/strong&gt; In the same way that “decouple” is a mantra when designing your virtual infrastructure, you should also apply it to infrastructure code. &lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Aim for cattle, not pets.&lt;/strong&gt; While not practical in a household, it will make life so much easier when designing infrastructure. Any infrastructure resource is to be viewed as cattle that can easily be replaced as opposed to a pet that should be kept alive at all costs (and possibly for emotional reasons?)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Who does it and should &lt;em&gt;you&lt;/em&gt; do it?&lt;/strong&gt;
    Everyone does it - at least they will tell you so. Remember the part about buzzword?&lt;br /&gt;
    Should you do it? The answer is the same as to much of everything else in life - it depends. Chances are - if you are reading this, have understood most of it, and are starting to hum the IaC theme, you should. IaC will give you some, if not all of the benefits mentioned earlier both for large-scale deployments and for smaller more intimate server-environments for just the reasons listed earlier.&lt;/p&gt;

&lt;p&gt;I was going to have a section at the end called “Why you shouldn’t do it”, but it didn’t seem to make much sense at this point.&lt;/p&gt;

&lt;!-- Contact --&gt;
&lt;div class=&quot;two spacing&quot;&gt;&lt;/div&gt;
&lt;div class=&quot;row&quot;&gt;
  &lt;div class=&quot;medium-12 medium-centered columns&quot;&gt;
    






&lt;div class=&quot;rl-contact-box-wrapper&quot;&gt;


  &lt;div class=&quot;rl-contact-box content row&quot;&gt;
    &lt;div class=&quot;small-1 column&quot;&gt;&amp;nbsp;&lt;/div&gt;
    
    &lt;div class=&quot;small-1 medium-4 column&quot;&gt;
      &lt;div class=&quot;rl-contact-image&quot;&gt;
        
        
&lt;div class=&quot;rl-image-ratio-block&quot; style=&quot;background-image:url(/cloud/images/employees/yngve.jpg)&quot;&gt;&lt;/div&gt;

      &lt;/div&gt;
    &lt;/div&gt;
    
    &lt;div class=&quot;small-10 medium-6 column end&quot;&gt;
      &lt;div class=&quot;rl-contact-text&quot;&gt;
        &lt;h2 class=&quot;rl-contact-heading&quot;&gt;Contact&lt;/h2&gt;
        &lt;p&gt;&lt;span class=&quot;rl-contact-name&quot;&gt;Yngve Sandal&lt;/span&gt;&lt;br /&gt;
           &lt;span class=&quot;rl-contact-title&quot;&gt;Architect at Redpill&amp;nbsp;Linpro&lt;/span&gt;&lt;br /&gt;
           &lt;a class=&quot;button rl-contact-link&quot; href=&quot;/cloud/contact.html&quot;&gt;Contact&lt;/a&gt;&lt;br /&gt;
        &lt;/p&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;two spacing&quot;&gt;&lt;/div&gt;




  &lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;two spacing&quot;&gt;&lt;/div&gt;
</description>
        <pubDate>Fri, 07 Feb 2020 00:00:00 +0000</pubDate>
        <link>/cloud/blog/2020/02/07/infrastructure_as_code.html</link>
        <guid isPermaLink="true">/cloud/blog/2020/02/07/infrastructure_as_code.html</guid>
        
        
        <category>Cloud</category>
        
      </item>
    
  </channel>
</rss>
