<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Dan Kirkwood on Medium]]></title>
        <description><![CDATA[Stories by Dan Kirkwood on Medium]]></description>
        <link>https://medium.com/@dgkirkwood?source=rss-c8f858ff1bbe------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*3oP55t25q81JUNM3aoBdhw.jpeg</url>
            <title>Stories by Dan Kirkwood on Medium</title>
            <link>https://medium.com/@dgkirkwood?source=rss-c8f858ff1bbe------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 21:16:41 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dgkirkwood/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Secure your AWS ECS Microservices with Consul Service Mesh]]></title>
            <link>https://medium.com/hashicorp-engineering/secure-your-aws-ecs-microservices-with-consul-service-mesh-23df69949754?source=rss-c8f858ff1bbe------2</link>
            <guid isPermaLink="false">https://medium.com/p/23df69949754</guid>
            <category><![CDATA[hashicorp]]></category>
            <category><![CDATA[fargate]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[consul]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Dan Kirkwood]]></dc:creator>
            <pubDate>Mon, 13 Jul 2020 12:31:01 GMT</pubDate>
            <atom:updated>2020-07-13T12:31:01.411Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dr8PA1dd9GhSkJVmrd2rMQ.png" /></figure><p>A service mesh is a useful tool for connecting microservices. A good service mesh performs the following:</p><ul><li>Keep a live view of what service is where, verified with health checks</li><li>Enforce encrypted communication between services</li><li>Load balance connections between all healthy instances, or between a subset of instances as per a routing or splitting policy</li><li>Allow only authorized services to communicate</li></ul><p>Typically when we think about microservices we think of Kubernetes as the scheduler of choice for large scale containerized applications. For this reason most service mesh solutions are Kubernetes only. But what if my microservices application is on a different deployment platform? I could have .NET or Java applications which are loosely coupled services running on self-hosted VMs or cloud compute. I could have a large self-managed docker environment or applications scheduled with Nomad. Or I might be running in Amazon’s Elastic Container Service (ECS). Enter <a href="https://www.consul.io/">Consul </a>— a great solution for service mesh across Kubernetes and many different operating environments.</p><p>This blog will look at a Consul service mesh pattern for applications in ECS. This example is running on EC2 instances under an ECS managed cluster, but could be easily modified to run Fargate workloads as well.</p><h4>Before we begin</h4><p>This blog is <em>not </em>an introduction to either Consul or ECS. To understand more about Consul:</p><ul><li>Take a look at the <a href="https://www.consul.io/">Consul website</a> and <a href="https://www.consul.io/docs">documentation</a>.</li><li>Watch this <a href="https://www.youtube.com/watch?v=mxeMdl0KvBI">Consul introduction</a> from HashiCorp co-founder and CTO Armon Dadgar.</li><li>Read or watch one of the <a href="https://www.hashicorp.com/resources/criteo-containers-consul-connect/">many</a> <a href="https://slack.engineering/a-terrible-horrible-no-good-very-bad-day-at-slack-dfe05b485f82">blogs</a> and <a href="https://www.hashicorp.com/case-studies/mercedes/">case</a> <a href="https://www.hashicorp.com/resources/ebay-hashistack-fully-containerized-platform-iac/">studies</a> covering Consul production deployments.</li></ul><p>For more on ECS please visit the <a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/Welcome.html">AWS documentation</a>.</p><h3>Consul service mesh on ECS —Demo environment</h3><h4>Follow along at home</h4><p>To demonstrate this example I have created a repository to help you get started: <a href="https://github.com/dgkirkwood/consul-ecs-awsvpc">https://github.com/dgkirkwood/consul-ecs-awsvpc</a></p><p>To skip the long read and get straight to your environment, visit the Github link, and follow the readme instructions. As long as you have an AWS account and can follow basic Terraform instructions, you will have an ECS + Consul Service Mesh environment in a few minutes.</p><p><strong>** Disclaimer! **</strong> : This is a repo to be used purely for testing and demonstration purposes and should not be used for production.</p><h4>Understanding the environment</h4><p>The code in the linked repository creates an AWS environment using Terraform. Follow the readme file for how to get started. Note I will not go into any detail on the Terraform code in this blog unless it relates directly to the ECS or Consul configuration. The image below shows some of the resources created:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JKbnvuD-lVNH_PPv1rhNDQ.png" /><figcaption>ECS and EC2 environment created by Terraform</figcaption></figure><h4>Network</h4><p>A simple network consisting of a single VPC with a single public subnet supports this environment. The <em>network.tf</em> code also creates a single interface in this subnet per EC2 server, providing a static IP address to simplify the demo environment. Our security groups also attach to this interface.</p><h4>Compute</h4><p>This environment consists of three EC2 servers. You can find the Terraform definition for these servers in the <em>main.tf</em> file.</p><p><strong>consul-ec2–1:</strong> Ubuntu AMI which runs the Consul binary in server mode. This is a single server that would expand into a three or five node cluster for a production environment.<br><strong>ecs-ec2–1 &amp; ecs-ec2–2: </strong>An ECS-optimised AMI which becomes managed by the ECS service.</p><h4>ECS Resources</h4><p>The Terraform code creates a hierarchy of ECS objects for the demo environment. Our application consists of two simple services: An HTTP server and a HTTP client. Each of these services has its own task, container and service definitions that you can find in the <em>ecs.tf </em>file.</p><p><strong>ECS Cluster: </strong>Top-level logical mapping of servers to tasks. The cluster name for our environment is populated by one of the required variables in the repository.<br><strong>ECS Task Definition: </strong>A resource defining the connection between a container definition, the network type, and the available storage for those containers.</p><p><em>Note that the network type chosen for our tasks is AWS VPC. This will create an Elastic Network Interface (ENI) per task which will be assigned a dynamic IP address from your subnet. This is the same network type applied to Fargate tasks, and this code with a few modifications could apply to Fargate workloads as well.</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0360a7fb4f8f19fdeb80b731bee5ad98/href">https://medium.com/media/0360a7fb4f8f19fdeb80b731bee5ad98/href</a></iframe><p><strong>Container Definition: </strong>This is a JSON file containing the defined resources for containers that will run inside your task definition. The container definition for one of our tasks is shown here.</p><p>Note that for both of the services in this example, we have defined three containers.</p><ol><li>A container for the application itself (named ‘server’ in the code sample next to this text).</li><li>A container to run the Consul agent. This agent is a service local to the application and the Envoy proxy to perform service query resolution, health checking, and some control plane tasks for our service mesh. Note that an agent per task-definition is not the only pattern for a service mesh you could for instance run an agent per EC2 host. The following ports are exposed: <br>- 8500: Consul HTTP API<br>- 8502: Consul gRPC for xDS communication with the Envoy proxy<br>- 8301: LAN Serf traffic for Consul node communication</li><li>A container to run the Envoy proxy. This is the service that performs all the data plane operations for our service mesh. All traffic will be forwarded via the proxy which has a certificate to be able to communicate with other proxies that are part of the same mesh. The proxy can also enforce service intentions (which we will cover later) and perform layer 7 tasks such as service splitting and routing. This container is using an image from one of my colleagues which includes the Consul agent, and it is this container that will register the application service to Consul. Note the Environment variables provided pointing Envoy to the Consul agent running on localhost. <br>Port 21000 is exposed for the Envoy container. This is the first port in a range 21000–21255 from which ports are picked for the public listener of the proxy. This can be statically defined as part of the Consul configuration. As we are using a new ENI for each ECS service, we can stick with 21000 only. <br>Both the Consul agent and the Envoy containers are using volume mounts from the EC2 instance to provide configuration files that are generated as part of the Terraform run.</li></ol><p><strong>ECS Service: </strong>A map to link together the task definition, cluster, subnet, and security groups. At the service level is also where the number of instances of a task is required. Note that the code will create 3 instances of the server app and 1 instance of the client app by default. You can change these numbers but may hit the limit of ENIs available per EC2 instance.</p><h4>Other Resources</h4><p>There are also security groups and IAM policies defined as part of the test environment. These are policies to allow the EC2 instances to perform actions as part of the ECS cluster, as well as connectivity between the Consul server and agents, and finally connectivity policies to allow HTTP/S and SSH access into the servers. These security controls would be refined and tightened for a production environment.</p><h3>Testing the service mesh</h3><h4>Step 1: Check Consul</h4><p>To see the service mesh in action, follow the instructions at the Github repository to instantiate the AWS infrastructure with Terraform. Once you have your Consul GUI address, paste the link into your browser and take a look.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OhuszFFPkOhLodA-ku5SQA.png" /><figcaption>Consul main dashboard</figcaption></figure><p>We can see that two services have registered that correspond to the two tasks defined in ECS. Consul also registers itself as a service.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0OxKep8JMWWA1aDIOTdnsQ.png" /><figcaption>Consul service dashboard</figcaption></figure><p>Clicking on the http-server service, we can see there are three instances of the service and we can see the IP address and port for the service. The green checks show that this service is passing two types of health check. Click on one of the instances for more detail.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H1hi-dvDyWYAEVctB442Pg.png" /><figcaption>Consul service detail</figcaption></figure><p>Here we can see more detail on the health checks for our service. We have a service check that was defined in the configuration file used to register the application (take a look in consul-ecs-aws/configs/server.hcl). We also have a health check running on the Consul agent itself. Serf is the protocol used for communication between Consul nodes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fX5eJdX82UXzNwJoli0yOw.png" /><figcaption>Consul service proxy detail</figcaption></figure><p>Clicking on the Proxy Info menu item for the http-server instance shows that our Envoy proxy is up and passing health checks as well.</p><h4>Step 2: Test the application</h4><p>Testing our application using the service mesh involves running a simple curl command through the client container.</p><ol><li>Connect to your ECS hosts using SSH. Replace xx.xx.xx.xx with the IP address given by the Terraform output for the ECS servers.</li></ol><pre>ssh -i /path/to/your/privatekey ec2-user@xx.xx.xx.xx</pre><p>2. Inspect the containers running on the host</p><pre>docker ps</pre><p>3. You are looking for a container running the image tutum/curl:latest and it will have a name similar to ‘ecs-serviceMeshAppClient-25-client-e28695a8def7ddc91e00’. Note there is only one client container by default, so you may need to check both ECS hosts. Once you find this container, execute a curl from the container using the following command</p><pre>docker exec -it &lt;replace-me-with-client-container-name&gt; curl 127.0.0.1:8085</pre><p>4. You should see the following response:</p><pre>&quot;hello world&quot;</pre><h4>What in the mesh is happening?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UiuGcwJ_hIXBXBvgmr-O2Q.png" /><figcaption>Communication paths in the service mesh</figcaption></figure><p>The image above shows what is happening for our client application to receive a “Hello world” response from the server. You would have noticed we dialed 127.0.0.1:8085 to reach out to the server. This may seem illogical from a networking point of view. Why not reach out to the server directly on port 80? This is one of the great security benefits of the service mesh. Our server is no longer exposing port 80 or port 443 out to the network, because in our mesh all communications must be authorized and must run over sessions encrypted with mTLS. The only port that is exposed is port 21000 belonging to our Envoy proxy. That proxy will only accept connections from other proxies which present a certificate that has automatically been provisioned by Consul as part of the mesh bootstrapping. Do not underestimate the huge uplift this brings to your microservices architecture with relatively little effort!</p><p>Let’s take a look at the configuration on the client task to allow our application to reach out to the server.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/09fdc7f7b5225623aa2f929f75dd8c79/href">https://medium.com/media/09fdc7f7b5225623aa2f929f75dd8c79/href</a></iframe><p>Notice the “upstreams” definition as part of the proxy configuration. Here we are defining which services we expect the client to reach out to (http-server) and assigning an arbitrary port for the client application to send traffic to locally. Our Envoy proxy will then expose this port on localhost to accept traffic from the application.</p><p>For more on traffic patterns in a service mesh, take a look at the HashiCorp whitepaper <a href="https://www.hashicorp.com/blog/the-life-of-a-packet-through-consul-service-mesh/">“The Life of a Packet through Consul Service Mesh”</a> which gives a detailed summary of packet flows in various mesh scenarios.</p><h4>Step 3: Test authorization</h4><p>We have improved our security posture for this application by only allowing mesh capable services of communicating. Our application does not need any refactoring and is blissfully unaware of the keys, certificates, and libraries that would usually be required to achieve the same result. However we can improve this further.</p><p>In a typical microservices environment you would be connecting tens to hundreds of different services. If these are all part of the same mesh, should they all be allowed to communicate? If we are following the principles of zero trust, then no. Consul provides a mechanism to implement service to service authorization controls.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FjLeSoFZMgHYC2hME5YcQw.png" /><figcaption>Intentions dashboard</figcaption></figure><ol><li>Click on the Intentions top menu item, then click the blue Create button</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Un3KH37A7sbHzK7yCa74AA.png" /><figcaption>Creating an intention via the GUI</figcaption></figure><p>2. Select http-client as the source and http-server as the destination. Leave the radio button on Deny and click Save.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jO2zxf4kcFZ9MfblPnwnsg.png" /><figcaption>Your first intention!</figcaption></figure><p>3. Your intention is now shown and you are ready to test. Run the same curl command from Step 2 part 3. (Making sure you are in the ECS SSH session)</p><pre>docker exec -it &lt;replace-me-with-client-container-name&gt; curl 127.0.0.1:8085</pre><p>You will now no longer see the “hello world” message, instead you should see:</p><pre>curl: (52) Empty reply from server</pre><p>Consul has enforced our intention via the Envoy proxy in the data plane. Note that intentions are always enforced on the destination proxy. You can play with creating and removing these intentions to get a feel for service control in Consul</p><h3>Final thoughts</h3><p>Here I have presented a pattern that could be used to insert a service mesh into your ECS or Fargate environment on AWS. By doing so you get the benefits of a greatly increased security posture with no change to the application code. Our Consul service mesh will track healthy applications and spread requests between them, encrypt all connections, and ensure only authorized applications can call each other over the network.</p><p>The great thing about this mesh is that it can be extended into other environments to keep this security posture maintained as your deployment platforms change. Services that cannot be paired with a proxy such as a managed database can be brought into the mesh with <a href="https://www.consul.io/docs/connect/terminating-gateway">terminating gateways</a>. The same mesh can be extended into a new Kubernetes environment via a <a href="https://www.consul.io/docs/connect/mesh-gateway">mesh gateway</a>, and traffic from outside the mesh can be securely introduced via <a href="https://www.consul.io/docs/connect/ingress-gateway">ingress gateways</a>. As with all HashiCorp products, getting started with Consul is easy. <a href="https://www.consul.io/downloads">Download</a> it yourself and start <a href="https://learn.hashicorp.com/consul">learning</a>!</p><p>Thanks for reading and see you next time!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=23df69949754" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hashicorp-engineering/secure-your-aws-ecs-microservices-with-consul-service-mesh-23df69949754">Secure your AWS ECS Microservices with Consul Service Mesh</a> was originally published in <a href="https://medium.com/hashicorp-engineering">HashiCorp Solutions Engineering Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Terraform for Network Engineers: Should you be implementing Infrastructure as Code?]]></title>
            <link>https://medium.com/hashicorp-engineering/terraform-for-network-engineers-should-you-be-implementing-infrastructure-as-code-73667d27d3b8?source=rss-c8f858ff1bbe------2</link>
            <guid isPermaLink="false">https://medium.com/p/73667d27d3b8</guid>
            <category><![CDATA[hashicorp]]></category>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[netdevops]]></category>
            <category><![CDATA[terraform]]></category>
            <dc:creator><![CDATA[Dan Kirkwood]]></dc:creator>
            <pubDate>Fri, 05 Jun 2020 03:00:14 GMT</pubDate>
            <atom:updated>2020-06-10T01:57:48.755Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6yHaItayoo6RO0dX" /><figcaption>Photo by <a href="https://unsplash.com/@ripato?utm_source=medium&amp;utm_medium=referral">Ricardo Gomez Angel</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In my role as a Solutions Engineer at <a href="http://www.hashicorp.com/">HashiCorp</a>, every day I get to talk with our users and customers about how our products fit into their workflows. One of the most common questions I hear is around <a href="http://terraform.io/">Terraform</a> management of particular infrastructure areas.</p><p>This blog answers that question for one area in particular: The network. It assumes basic networking and automation tooling knowledge. (If you are looking for a more general explanation of Terraform and Infrastructure as Code, take a look at this <a href="https://medium.com/hashicorp-engineering/terraform-for-the-non-technical-6dd92e5dde7c">article</a> from my colleague Sean Carolan.)</p><h3>A day in the life of a network ticket</h3><p>To understand Infrastructure as Code (IaC) and the difference it makes to network operations, let us consider the following request:</p><blockquote>I need a subnet!</blockquote><p>A simple enough request on the surface. The first thing that probably would happen here would be an exchange over email, a ticket with comments or discussion over your chosen internal IM platform with the following questions:</p><ul><li>What kind of workloads will reside on this subnet?</li><li>How many hosts will it hold?</li><li>What kind of traffic will ingress and egress from the subnet?</li><li>Does it need internet access?</li></ul><p>And so on.</p><p>Once this information is known, one or multiple operators would need to interact with a number of systems to fulfil the request, for example:</p><ol><li>Check an IP Address Management (IPAM) tool for available address space</li><li>Consult existing route tables to make sure your subnet meets summarisation constraints</li><li>Find the router or route table that will own the route, and configure the subnet</li><li>Configure the L3 gateway interface</li><li>Configure the VLAN in your L2 domain via VLAN definition and trunk links</li><li>Configure the VM port group or L2 interfaces for the access layer</li><li>Configure the firewall to ensure access to/from the subnet to other resources</li></ol><p>At this point I am going to pause and ask you to think about this process at your organisation. Do the steps above become a ticket? Maybe multiple tickets? <br>How many people have the knowledge to complete this task end to end? How often do they get something wrong along the way? How often does someone catch that something went wrong before an application is deployed that has connectivity problems? How consistent is this process across your on-premise and cloud environments? Is it consistent across networking overlays and underlays?</p><p>I hope it is obvious here that some kind of automation would be beneficial for this repetitive task. As a network engineer you have many automation tools at your disposal, whether they are vendor provided or home-grown. To understand why Terraform is a good fit, I have broken down some common challenges with fulfilling this request through common vendor or home-grown automation tools. I have also included examples of how Terraform helps to overcome those challenges</p><h3>The challenges Terraform will help you overcome in network automation</h3><h4>Complexity</h4><p>The first challenge is that many different vendor systems are involved for a single logical request, requiring knowledge of each CLI / GUI or API.</p><p>Terraform offers a single easy to read, machine parseable language called Hashicorp Configuration Language (HCL) which is consistent no matter which technology you are interacting with. Vendors and the Terraform community also maintain providers which are the API interaction point with your infrastructure. Terraform code for a subnet can be a single file which describes everything we need to satisfy the request.</p><p>The outcome here is that operators do not need to learn how to interact with each API separately and can spend time provisioning infrastructure. Team members have a single view of the subnet request that is easy to read and understand. In the example below, we use HCL to create a subnet across three cloud environments. Note that HCL does not try to abstract away from the service model of each cloud. Terraform does not force you down the path of the lowest common denominator when interacting with cloud resources.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/25d587c8ee457c027a2896f04cca1feb/href">https://medium.com/media/25d587c8ee457c027a2896f04cca1feb/href</a></iframe><h4>Safe data handling</h4><p>The second challenge with setting up your own automation of network changes is that the manual retrieval and translation of attributes, such as the subnet from our IPAM tool, is time consuming and error prone.</p><p>Terraform includes simple syntax for passing data between resources in the same request. The requested subnet from the IPAM tool can be referred to as ipam.subnet on the L3 interface, on the firewall, in security groups and so on. <br>With this in place we have less time spent doing manual copy-past actions.</p><p>This in turn lowers the risk of operator error, one of the main causes of network outages. In the example below, we use Terraform to claim an IP address from Infoblox, and then pass that IP address to a configuration block for a vSphere virtual machine.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a27b952a82aa93f306940c6d0d9a00b1/href">https://medium.com/media/a27b952a82aa93f306940c6d0d9a00b1/href</a></iframe><h4>Order of operations</h4><p>Network operators need to follow an order of operations to complete this request which is likely specialist or tribal knowledge. If this process is documented, time and effort are required to keep the documentation up to date.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BzE4p_GH8aSrYn_N8Fp9fQ.png" /><figcaption>Resource graph for Cisco ACI, showing Terraform computed dependencies and opportunities for parallel operations.</figcaption></figure><p>Terraform is a declarative tool, meaning it will work out the dependencies in this request automatically without the operator needing to know the correct order of operations. As terraform computes the dependencies between resources, it also knows which resources can be created in parallel.</p><p>The great outcome for the business here is that more operators are empowered to complete this request. Less time is spent by the team creating and maintaining documentation. When thinking about operating at scale, Terraform offers out of the box more efficient creation of resources with preconfigured parallelisation.</p><h4>Lifecycle</h4><p>Many operations teams focus on creating resources to meet business needs, but resource lifecycle is often ignored. This leads to stale infrastructure which can starve resources such as IP pools, router CPU or Firewall rule space.</p><p>Terraform will keep track of this subnet after its creation. If the code is changed (lets say the requestor soon needs a /25 instead of a /26) Terraform will work out which elements of infrastructure need to be updated to make the change. The whole subnet can also be removed from every piece of infrastructure where it was provisioned with a simple ‘destroy’ command.</p><p>With a tool which includes lifecycle management as a default, more resources are available to the teams that need them. By reducing the stale infrastructure elements on a platform, the platform becomes easier to understand and maintain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V8eL5ZPYI_mhJQ0gCFTMGA.png" /><figcaption>Knowing which ACLs can be removed from a device due to configuration changes can be challenging</figcaption></figure><h4>Collaboration</h4><p>Infrastructure teams struggle to work collaboratively when using CLI or GUI systems. Scripts and API interactions can lead to code sprawl and lack of visibility into who is making changes. Different capabilities in terms of code or network knowledge mean that not everyone in the team is empowered to make changes when needed.</p><p>Terraform can integrate directly with version control systems or CI/CD pipelines to implement best practice around code hygiene. Terraform code can also be broken into modules, which are published by teams with the domain knowledge (for instance the network team) for consumption by other teams who just need the outcome (for example application teams)</p><p>The outcome here is that infrastructure is more predictable, repeatable and can be tested. The business has a centralised audit trail of changes to an environment. Teams can consume a module without knowing the intricacies of network management.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/47c88708e5b6b0c9ecfa61dedd36a7bc/href">https://medium.com/media/47c88708e5b6b0c9ecfa61dedd36a7bc/href</a></iframe><h4>Increased risk</h4><p>We see in some teams that begin to move fast with automation that by removing the human element from infrastructure provisioning more risk is introduced of either something going wrong at a large scale, or abuse of the automated system.</p><p>Terraform includes a policy as code framework that is customisable around governance and compliance controls. Types of policies include:</p><ul><li>Guardrails for best practice — “Subnets should be under /24 unless approved by the network team”</li><li>Security policy — “Access to workloads in the DataCenter should only be given on ports 22 and 443 and only from trusted entities”</li><li>Operations governance — “No changes to the network after 5pm on Friday and before 8:30am on Monday”</li></ul><p>Sentinel helps to lower risk around automated changes. By defining policies in code, they are auditable and enforceable before any change is made. Terraform also enables integration into existing change management processes for elevation and change approval.</p><p>In the screenshot below, some infrastructure provisioned by Terraform is first checked against best practice as defined by the Center for Internet Security (CIS). Only resources in this Google environment that follow best practice will be provisioned. (See the repository of CIS guidelines in our Terraform Foundational Policy library <a href="https://github.com/hashicorp/terraform-foundational-policies-library">here</a>.)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_VYZ0P-AeScb2d9WEolKGA.png" /><figcaption>Terraform policy checks</figcaption></figure><h3>Infrastructure as Code with Terraform sounds great… why am I not using it already?</h3><p>We have seen huge adoption of Terraform within teams who have gone all-in on public cloud. Terraform makes sense in these environments because they are usually very dynamic, and also because the public cloud vendors expose their full functionality via a rich API. (Take a look at the network provisioning capabilities on <a href="https://www.terraform.io/docs/providers/aws/index.html">AWS</a>, <a href="https://www.terraform.io/docs/providers/azurerm/">Azure</a> and <a href="https://www.terraform.io/docs/providers/google/index.html">GCP</a>.)</p><p>The recommended model of managing infrastructure with Terraform is via API, and for the most part Terraform integrations (called ‘providers’) focus on system orchestrators rather than deploying configuration box-by-box. Many network vendors are now offering APIs as first-class integration points as well. Some examples include:</p><ul><li><a href="https://www.terraform.io/docs/providers/aci/index.html">Cisco ACI</a></li><li>VMWare <a href="https://www.terraform.io/docs/providers/nsxt/index.html">NSX-T</a> and <a href="https://www.terraform.io/docs/providers/avi/index.html">Avi</a></li><li><a href="https://www.terraform.io/docs/providers/bigip/index.html">F5 BIG-IP</a></li><li><a href="https://www.terraform.io/docs/providers/panos/index.html">Palo Alto Networks</a></li><li><a href="https://www.terraform.io/docs/providers/aviatrix/index.html">Aviatrix</a></li><li><a href="https://www.terraform.io/docs/providers/checkpoint/index.html">Check Point</a></li><li><a href="https://www.terraform.io/docs/providers/fortios/index.html">Fortinet</a></li></ul><p>While Terraform cannot manage every network today, we have a huge community of vendors and developers constantly releasing new providers. Keep an eye on the <a href="https://www.hashicorp.com/blog/">HashiCorp blog</a> for announcements in this space.</p><h3>How can I get started?</h3><p>You can start managing your network with Terraform today. To work on your local machine, visit our <a href="https://www.terraform.io/downloads.html">downloads page</a>. You can also run Terraform on our SaaS platform which has a <a href="https://app.terraform.io/signup/account">free tier.</a> We also have plenty of well-documented getting started guides at our <a href="https://learn.hashicorp.com/terraform">learn site</a>.</p><p>I hope this blog has shown the possible use cases for Infrastructure as Code in network management, and where Terraform is particularly useful in the safe and reliable automation of infrastructure provisioning. Thanks for reading and see you next time!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=73667d27d3b8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hashicorp-engineering/terraform-for-network-engineers-should-you-be-implementing-infrastructure-as-code-73667d27d3b8">Terraform for Network Engineers: Should you be implementing Infrastructure as Code?</a> was originally published in <a href="https://medium.com/hashicorp-engineering">HashiCorp Solutions Engineering Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>