<?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 Adhip Gupta on Medium]]></title>
        <description><![CDATA[Stories by Adhip Gupta on Medium]]></description>
        <link>https://medium.com/@adhip12?source=rss-d666399a1d9d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*wtrXDTBTKa1WRnvB0geqIA.jpeg</url>
            <title>Stories by Adhip Gupta on Medium</title>
            <link>https://medium.com/@adhip12?source=rss-d666399a1d9d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 22:58:40 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@adhip12/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[Arne Slot’ Liverpool: Genuine contenders or a false dawn]]></title>
            <link>https://medium.com/@adhip12/arne-slot-liverpool-genuine-contenders-or-a-false-dawn-32f69cbbb902?source=rss-d666399a1d9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/32f69cbbb902</guid>
            <category><![CDATA[football-analytics]]></category>
            <category><![CDATA[soccer]]></category>
            <category><![CDATA[premier-league]]></category>
            <category><![CDATA[liverpool]]></category>
            <dc:creator><![CDATA[Adhip Gupta]]></dc:creator>
            <pubDate>Mon, 11 Nov 2024 00:14:53 GMT</pubDate>
            <atom:updated>2024-11-21T04:03:55.817Z</atom:updated>
            <content:encoded><![CDATA[<h3>Arne Slot’s Liverpool: Genuine contenders or a false dawn</h3><p>At the end of the tenth gameweek of the Premier League season, Liverpool sits on top the PL table with 25 points, with a remarkable start under new manager Arne Slot. Much has been said about Liverpool’s evolution in style, with Slot implementing a more pragmatic and balanced approach compared to Jurgen Klopp’s last season. But do the statistics back up what fans have seen on the pitch?</p><p>Liverpool after game week 10 led with a two-point advantage over Manchester City and have the league’s best defensive record, having conceded only six goals. This early success points to some shifts in their gameplay. Let’s dive deeper into the numbers and compare this season’s Liverpool to last season to see if the data reveals a change in style or approach.</p><h3>In the Expected World</h3><p>The expected goals and goals against stats in 2023/24 vs 2024/25</p><h4>2023/24</h4><ul><li>Highest xG/90 in the PL: 2.31 ( npxG: 2.12 )</li><li>3rd lowest xGA/90: 1.2</li><li>3rd lowest PSxG ( xGOT )/90 : 1.05 ( This refers to the post shot xG against for on target shots )</li></ul><h4>2024/25</h4><ul><li>4th highest xG/90: 1.83 ( npxG: 1.66 )</li><li>Lowest xGA/90: 0.7</li><li>Lowest PSxG/90: 0.87</li></ul><p>It’s evident from the above stats that even though Liverpool have been solid in defense and are conceding less, they haven’t been creating as many chances either.</p><h3>Reduced attacking output</h3><p>A closer look at Liverpool’s attacking numbers reveals a significant drop in output. The stats for Shots per 90 minutes and Shot-Creating Actions indicate that Liverpool’s attack isn’t as productive as it was last season.</p><p>2023/24</p><ul><li>Highest Shot Creating Actions/90: 36</li><li>Highest Shots/90: 20.55</li><li>Touches in Attacking 3rd: 207</li></ul><p>2024/25</p><ul><li><strong>6th highest</strong> Shot Creating Actions/90: 25.44</li><li><strong>12th highest</strong> Shots/90: 12.3</li><li>Touches in Attacking 3rd: 168</li></ul><p>While Liverpool’s overall shot production has declined, they continue to lead in creating “Big Chances Created”. This season, they’re averaging <strong>3 big chances per game</strong> (30 total) compared to <strong>2.68 per game</strong> (102 total) last season.</p><h3>The narrative around control</h3><p>From Arne Slot’s first few games, it became evident that Liverpool’s approach had shifted, with pundits and experts discussing their ability to control games better than Jurgen Klopp’s gegenpressing style. The stats above show a more defensively sound Liverpool, yet Slot’s definition of “control” is more in line with Mikel Arteta or José Mourinho than that of Pep Guardiola’s possession-based approach. Arne Slot’s Liverpool is more than happy to concede possession and soak pressure when needed, rather than defend with the ball. We have seen that against Crystal Palace, Chelsea, and Brighton, and shutting shop after scoring the tying goal against Arsenal.</p><p>Liverpool’s pressing intensity numbers show us how Arne Slot has tweaked his style. In 2023/24, Liverpool under Klopp were the best at regaining and disrupting possession at <strong>~10.5 seconds</strong> versus <strong>~13 seconds</strong> this season. <a href="https://x.com/DataAnalyticEPL/status/1851944911328710958">(https://x.com/DataAnalyticEPL/status/1851944911328710958)</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OyYQW8iSRDks8kO3" /><figcaption>Pressing Intensity 2023/24</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*y6vQVvhBHy2Iy88i" /><figcaption>Pressing Intensity 2024/25</figcaption></figure><p>Let’s look at some other stats that corroborate this change in style:</p><ul><li>Possession is down 4% from 61.7% to 57% this season.</li><li>Total passes as a result of reduced possession has gone down from 641 passes per game to 583.</li><li>Total progressive distance/90 ( all passes excluding backward and sideways passing ) down from 3123 to 2894</li><li><strong>Number of touches in the defensive 3rd</strong> have gone up, whereas the mid 3rd and attacking 3rd touches have gone down.</li></ul><h4>Zones of Control in 2023/24 vs 2024/25</h4><p>The maps below show how Liverpool still control most areas of the pitch, but have conceded control in some key wide areas compared to last season.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/454/1*PH6kNKud7ZlK7lL_9NYY2Q.png" /><figcaption>Control Map 2023/24. Blocks colored blue is where Liverpool have more possession.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dh-kLfc29z_483JoZEGv5w.png" /><figcaption>Blocks colored purple is where Liverpool have more possesion.</figcaption></figure><p>Arne Slot and Liverpool have relied on their defensive prowess to keep opponents out. Defensively, the number of shots that Liverpool are conceding has reduced from <strong>10.87 shots per game</strong> last season to <strong>9.44</strong> <strong>shots per game</strong> this season. The distance of the shots has slightly increased <strong>from 17.3 yards to 18 yards.</strong> Liverpool this season have conceded lesser big chances — 4th lowest xG/Shot at <strong>0.08 versus 0.11</strong> last season where they were in 15th place.</p><h3>My take</h3><p>Last season, Liverpool’s defense under Jurgen Klopp was often criticized for leaving itself exposed in transition, with frequent situations where center backs were in 2v2 and 3v3 situations. Slot’s approach has clearly prioritized pragmatism and balance, and it has delivered defensive improvement. However, Liverpool’s reduced attacking output has been evident, particularly against well-organized defenses as seen against Nottingham Forest and Arsenal.</p><p>This era under Slot is certainly not a false dawn and his tactical tweaks have certainly helped Liverpool continue their charge after Jurgen’s reign. However, if Liverpool are to continue on this run, it would be critical that Arne Slot has a Plan B in attack when needed, and is able to find different ways to break organized defenses, without compromising on his defensive principles!</p><h3>References</h3><ul><li><a href="https://fbref.com/">Football Statistics and History | FBref.com</a></li><li><a href="https://x.com/DataAnalyticEPL">x.com</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=32f69cbbb902" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[KPIs — The common pitfalls]]></title>
            <link>https://medium.com/@adhip12/kpis-the-common-pitfalls-c8329d13f6f4?source=rss-d666399a1d9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/c8329d13f6f4</guid>
            <category><![CDATA[product-management]]></category>
            <category><![CDATA[kpi]]></category>
            <category><![CDATA[business-strategy]]></category>
            <category><![CDATA[product]]></category>
            <dc:creator><![CDATA[Adhip Gupta]]></dc:creator>
            <pubDate>Mon, 11 Jul 2022 18:48:14 GMT</pubDate>
            <atom:updated>2022-07-11T18:48:14.237Z</atom:updated>
            <content:encoded><![CDATA[<h3>KPIs — The common pitfalls</h3><p><strong>Even though there is a lot of good literature and resources on KPIs on the internet, I have seen people having misconceptions around how they define and use KPIs for products. In this post, I would like to go over some common mistakes that Product Managers make while defining KPI’s.</strong></p><p>Before I start talking about the mistakes, lets look at the definition of a Key Performance Indicators.</p><blockquote>From KPI.org :<em> Key Performance Indicators (KPIs) are the </em>critical <em>(key) indicators of </em>progress <em>toward an </em>intended result<em>.</em></blockquote><p>In other words, the right KPI’s would allow someone to measure the success of a product or a business based on it’s objective or goal.</p><p>For the purpose of this article, let’s take an Ice Cream Store that sells different flavors of ice cream as our case study, which has hired you to set their KPIs.</p><p>How would you set the KPI’s for an Ice Cream shop? Let’s look at some of the common mistakes that PMs make while defining KPIs.</p><h3>Setting KPIs that aren’t related to the objective</h3><p>Every organization, product or new feature in an existing product should have been developed keeping an objective in mind. Some of the common high level objectives are Acquisition, Engagement/Retention, Monetization etc.</p><p>Taking the example of the Ice Cream shop, if it had just opened, it would run promotions to get as many customers as possible to the shop ( Acquisition ). As it’s grows, it would introduce different flavors and options ( Retention ). Finally, once it becomes a household name it would look at increasing prices or coming up with bundle deals to increase profitability ( Monetization ).</p><p>The KPIs should be set to match the objective of the product or organization. Setting the KPIs that focus on revenue and profit when the product is in its growth phase and is looking to acquire more customers isn’t viable.</p><p>If you set the KPI to measure Average profitability or Average Sale per customer while focusing on increasing customers, it wouldn’t be a true indicator of <em>success </em>and will not reflect the <em>intended result</em>.</p><h3>Metrics are not the same as KPIs</h3><p>People confuse metrics with KPIs, they are related but aren’t the same. Let’s come up with a few metrics for the Ice Cream shop:</p><ol><li>Number of customers entering the store per day / per week.</li><li>Flavors of ice cream sold per day / per week.</li><li>Unique customers per week.</li><li>Average Sale per week.</li><li>Total number of cups used.</li></ol><p>Now, if the ice cream shop sets the above metrics as as KPIs and has the following numbers:</p><ol><li><em>Customers entering the shop every week: 50</em></li><li><em>Unique flavors of ice cream sold every day: 10</em></li><li><em>Unique customers per week: 30</em></li><li><em>Total number of cups used</em>: 100</li></ol><p>Going back to the definition: “<em>critical </em>(key) <em>indicators </em>of <em>progress </em>toward an <em>intended result”.</em></p><p>The KPIs above doesn’t include information that will help us identify <em>“progress”. </em>And for the “<em>total number of cups sold</em>” isn’t really a <em>key </em>factor in determining success.</p><p>This is where you can either add a “<em>Target</em>” value, and/or add a “<em>timeframe” </em>and compare it to the previous timeframe.</p><ol><li><em>Customers entering the shop this week: 50 (up 10% from last week)</em></li><li><em>Unique Flavors of ice cream sold this week &gt; 10 : 8 ( down 20% )</em></li><li><em>Unique customers entering the store every week : 10 (up 20% from last week)</em></li></ol><h3>KPIs that don’t help you adapt.</h3><p>KPIs aren’t only a measure of success, but also at the same time a indicator of what could be going wrong. A negative change in one or many KPIs should alert you about an issue, and you should then be able to take steps to mitigate it.</p><p>Going back to the Ice cream shop example, and let’s assume the <em>objective </em>of the shop is to attract more customers.</p><p>KPI: <em>“Customers entering the shop this week: 20 ( down 40% from last week)”.</em></p><p>As the shop owner, this dramatic drop will alert the shop owner that something is not right.</p><ol><li><em>Did the online promotion Ad expire?</em> Action: Let’s renew it.</li><li><em>Did another store open with competitive prices?</em> Action: Modify prices</li><li><em>Was there a bad review online?</em> Action: Mitigate and explain.</li></ol><p>KPI’s that don’t allow you to take action aren’t going to provide any valuable input to the overall success of the product. They could be good metrics to track, but they shouldn’t be performance indicators for the product or an organization.</p><p>In conclusion, always make sure that KPIs are always related to the objectives, have a way to compare and contrast with historical results, and are actionable!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c8329d13f6f4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Liverpool FC’s defensive inconsistencies could be it’s Achilles' heel.]]></title>
            <link>https://medium.com/@adhip12/liverpool-fcs-defensive-inconsistencies-could-be-it-s-achilles-heel-dc18bb0e92bf?source=rss-d666399a1d9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/dc18bb0e92bf</guid>
            <category><![CDATA[premier-league]]></category>
            <category><![CDATA[champions-league]]></category>
            <category><![CDATA[soccer]]></category>
            <category><![CDATA[football]]></category>
            <category><![CDATA[liverpool]]></category>
            <dc:creator><![CDATA[Adhip Gupta]]></dc:creator>
            <pubDate>Wed, 06 Apr 2022 01:04:50 GMT</pubDate>
            <atom:updated>2022-04-06T04:50:11.532Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Liverpool will play 8 games across 3 competitions in April, and our results in this “make or break” month will decide if we win any more silverware this season. Nonetheless, it is for the first time in Jurgen Klopp’s managerial stint at Liverpool that we find ourselves in a situation where we can potentially win it all. Despite our defensive frailties we are still in the running for the coveted quadruple.</em></p><p>The team started the season with some routine wins against Norwich and Burnley, had a slight hiccup as we drew to a 10 man Chelsea team, and continued with wins in the next two games. Four wins out of five, sitting joint top with Chelsea at 13 points, Salah scoring for fun, it was gearing up to be a three horse race for the Premier League. However, it was in games starting mid-September that Liverpool’s lapses in concentration and defensive errors became seemingly obvious and evident.</p><p>Liverpool have kept 18 clean sheets in the Premier League this season, but in certain games against teams that have shown attacking intent we have faltered and conceded control. Let’s analyze some of these games in the Premier League and Champions League this season.</p><h3>Atletico Madrid vs Liverpool</h3><p>The Champions League game against Atletico Madrid, Liverpool dominated the first 20 mins and deservedly went 2–0 up, but as soon as Atletico turned up their game and searched for goals we conceded chances. The first goal came off a set piece situation as Keita was beaten in a 1v1 situation and Griezmann scored.</p><p>Virgil Van Dijk below is caught ball watching in front of the half way line and isn’t aware of Griezmann making a run behind him. A simple ball over the top creates a 1v1 situation with Alisson who makes an excellent save and bails out Van Dijk.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*pTmjukaPdSUvYyR4qZWyJw.jpeg" /><figcaption>Virgil Van Dijk unaware off the on-side run by Griezmann</figcaption></figure><p>Van Dijk wasn’t as lucky six minutes later, as he was again caught off guard with Griezmann’s run and had his back to the ball which allowed Griezmann to run past him and score the goal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*a9rIxWirB83NxYy8BVFKhg.jpeg" /><figcaption>Van Dijk has his back to the ball as he is unaware of Griezmann’s positioning.</figcaption></figure><p>In the second half, Atletico started the game in the ascendancy and created another great chance which Alisson saved. Fortunately for us, Griezmann was shown a red card soon after and Liverpool dominated the game and went on to win.</p><h3>Liverpool vs Brighton</h3><p>This Brighton equalizing goal to make 2–2 is a prime example of Liverpool having these lapses in concentration where we don’t press well and our positioning isn’t up to the mark. Brighton went from their own 3rd and scored against a set defense in 3 passes.</p><ol><li>Sanchez’s pass to Cucurella from inside his own 3rd bypassed 5 Liverpool players.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*R57mjLPe-7iuTo6mfg3h0w.jpeg" /><figcaption>Sanchez doesn’t have any pressure on the ball and can find Cucurella.</figcaption></figure><p>2. Cucurella’s pass to Lallana leaves him 3v2 with Trossard and MacAllister on either side against Van Dijk and Robertson</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*NTUT7y59ub5en4NL0ZpQjA.jpeg" /></figure><p>3. And a pass later, Trossard is 2v1 and scores the goal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*UwPhw0-VV68ZuNuCKhAfHQ.jpeg" /></figure><h3>Crystal Palace vs Liverpool</h3><p>In this game, Liverpool were 2–0 up in the 32nd minute and Palace didn’t have a single shot until the 38th minute. But it all started with a misplaced pass from Matip in our own third, had Alisson making a great save on Olise’s shot and more chances followed.</p><h4>Clear cut chances</h4><p>Firmino gave the ball away in a congested midfield which was recovered by Olise who slid in Mateta.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*H6Kk0ekmxhd8z1C9llfdAA.jpeg" /><figcaption>Firmino’s errant pass gives Olise space to run.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*lEij4lq5wt0l2UXH6HL6oQ.jpeg" /><figcaption>Olise’s through ball to Mateta.</figcaption></figure><p>Mateta went around Alisson but shot wide at a gaping goal in front of him.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OTyjDNUBqOoKHO-7" /></figure><p>Gallagher (below) missed an open header from 5 yards, and Mateta had another easy chance to score in the opening minutes of the 2nd half.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*jQykx_TlrRPeD27b0sPBfA.jpeg" /></figure><h4>Finally conceded…</h4><p>Crystal Palace deservedly converted their next chance to make it 2–1 in the 54th minute. Virgil Van Dijk is trying to hold the line and play offside, and stops running, but is unaware of the run being made behind him.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*BInk_pjZJ_Fc52DRX2FtTw.jpeg" /></figure><p>After the pass is made, we have two Crystal Palace players in a 2v1 situation against Alisson and Edouard puts the ball in an open net.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*b2kRdb3tCcKl7yKu" /></figure><h3>Similar games</h3><p>There are many such examples especially against better quality teams. Earlier in the season against AC Milan at Anfield, where we went 2–1 down after being a goal up. Chelsea in the League Cup final created some excellent chances in both halves and it could have easily been a different score line and result. West Ham in the Premier League, where we held onto a slender 1–0 thanks to Lanzini and Fornals squandering away easy chances.</p><p>There is a common theme to all these games — dominate from the start, play some exceptional football, score goals, concede control and chances to the opposition team and give them a way back into the game.</p><h3>Let’s go win it all</h3><p>Every team makes defensive mistakes and no team is perfect, but the stakes have never been higher as we play these do or die games in April. Liverpool will be competing against world class teams and if we don’t defend better we will be in a tough situation. I do agree that ever since the turn of the year our overall defensive structure has improved, and we have conceded less number of goals and chances. However, we do still have these lapses in concentration at times. We need to be better than our 2019/20 world class levels as we approach this run in.</p><p>We play Manchester City at the Etihad which could ultimately decide who wins the Premier League. A week later we will play them again in an FA cup semis. And then, we have important PL games against Manchester United and Spurs, each of whom will be vying for the Top4 spot. Finally, we will more than likely face Bayern Munich in the Champions League semi-finals.</p><p>Our attack has been on another level and it has bailed us out by scoring some crucial goals this season. But as you must have heard many times before “It is attacks that win you games, it is defenses that win you titles”. And now it’s about winning games that win you titles. Let’s hope and wish that our defense can make this a year a special one for the entire fanbase.</p><p>YNWA!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dc18bb0e92bf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Starting your Multi-Cloud Journey with Terraform (Part II)]]></title>
            <link>https://medium.com/@adhip12/starting-your-multi-cloud-journey-with-terraform-part-ii-b45b8117123b?source=rss-d666399a1d9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/b45b8117123b</guid>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[multi-cloud]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Adhip Gupta]]></dc:creator>
            <pubDate>Fri, 14 Aug 2020 19:37:33 GMT</pubDate>
            <atom:updated>2020-08-14T19:37:33.126Z</atom:updated>
            <content:encoded><![CDATA[<h4>In the last post we created the basic building blocks in AWS and Azure including the VPCs, VNETs and the VMs inside them. You can go through the first part <a href="https://medium.com/@adhip12/starting-your-multi-cloud-journey-with-terraform-part-1-b240155036d8">here</a>. In this post we will complete our deployment by creating the cloud native VPN resources using Terraform.</h4><blockquote>You can view the Terraform resources and modules that we have created in the last post and this post in this <a href="https://github.com/adhipgupta/multicloud-terraform">github repo</a>.</blockquote><h3>AWS VPN</h3><p>From the topology below, we have already created the VPC, Subnet and the EC2 instances. Now let’s focus on creating the Virtual Private Gateway and the corresponding customer gateways.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/310/1*eSSESOrfqIC5BMKo1_f5zw.png" /></figure><h4>vpn.tf</h4><p><strong>Notes</strong></p><ol><li>This example uses static route VPN without BGP, so we would be creating an <em>aws_vpn_connection_route and aws_route </em>to add static routes in AWS. In Azure this is done automatically by the infrastructure.</li><li><em>var.remote_gws</em> : Is a list of the Public IPs ( endpoints ) to which the VPN connections need to be created. The public IPs are also combined with the remote local CIDR that would be advertised by the local end. The <em>remote_gws </em>for AWS in our example is the output variable from the Azure VNET module.</li></ol><pre>locals {<br>  all_remote_cidrs = distinct([for i in var.remote_gws: i[1]])<br>}</pre><pre>//Customer Gateway records the remote peers IPs<br>resource &quot;aws_customer_gateway&quot; &quot;cgw&quot; {<br>  count      = length(var.remote_gws)<br>  bgp_asn    = var.bgp_asn<br>  ip_address = var.remote_gws[count.index][0]<br>  type       = &quot;ipsec.1&quot;<br>}</pre><pre>//VPN Gateway from which all connections will be created<br>resource &quot;aws_vpn_gateway&quot; &quot;vpn_gateway&quot; {<br>  vpc_id = var.vpc_id<br>  tags   = {<br>    Name = &quot;Multi Cloud VPN Gateway&quot;<br>  }<br>}</pre><pre>//IPsec VPN connections<br>resource &quot;aws_vpn_connection&quot; &quot;vpnConn&quot; {<br>  count               = length(aws_customer_gateway.cgw.*.id)<br>  customer_gateway_id = aws_customer_gateway.cgw.*.id[count.index]<br> vpn_gateway_id       =  aws_vpn_gateway.vpn_gateway.id<br>  type                = &quot;ipsec.1&quot;<br>  static_routes_only  = true<br>}</pre><pre>//We are using Static Routes to share local subnet info.<br>resource &quot;aws_vpn_connection_route&quot; &quot;vpnConnectionRoute&quot; {<br>  count                  = length(aws_vpn_connection.vpnConn.*.id)<br>  destination_cidr_block = var.remote_gws[count.index][1]<br>  vpn_connection_id      = <br>                         aws_vpn_connection.vpnConn[count.index].id<br>}<br><br>resource &quot;aws_route&quot; &quot;remoteRoute&quot; {<br>  count                  = length(local.all_remote_cidrs)<br>  route_table_id         = var.route_table_id<br>  destination_cidr_block = local.all_remote_cidrs[count.index]<br>  gateway_id             = aws_vpn_gateway.vpn_gateway.id<br>}</pre><h4>variables.tf</h4><pre>variable &quot;bgp_asn&quot; {<br>  description = &quot;List of BGP ASNs of the remote end.&quot;<br>}<br>variable &quot;route_table_id&quot; {<br>  description = &quot;Local route table ID in the VPC&quot;<br>}<br>variable &quot;vpc_id&quot; {<br>  description = &quot;VPC ID to which the VPN Gateway is connected to&quot;<br>}<br>variable &quot;vpc_cidr&quot; {<br>  description = &quot;VPC CIDR&quot;<br>}<br>variable &quot;remote_gws&quot; {<br>  description = &quot;The list of all Remote Peers for VPN connectivity&quot;<br>}</pre><h4>output.tf</h4><p>The output.tf file has the following:</p><ol><li>aws_tunnel_info_address : AWS creates two tunnels (tunne1 and tunnel2) for every VPN connection. This output variable combines all the VPN connections created in this module into a single list. This list of connections is further combined with the <em>vpc_cidr using </em><a href="https://www.terraform.io/docs/configuration/functions/setproduct.html">setproduct</a> to associate the VPN connections with its VPC Cidr.</li><li>aws_tunnel_info_psk: This output variable holds the pre-shared keys for all the Ipsec tunnels created in the module.</li></ol><p>These variables will be used as inputs in the Azure VPN module to complete the configuration for the other end of the VPN connection.</p><pre>output &quot;aws_tunnel_info_address&quot; {<br>  value = <br>     setproduct(concat(aws_vpn_connection.vpnConn.*.tunnel1_address,  <br>      aws_vpn_connection.vpnConn.*.tunnel2_address), [var.vpc_cidr])<br>}<br><br>output &quot;aws_tunnel_info_psk&quot; {<br>  value = concat(aws_vpn_connection.vpnConn.*.tunnel1_preshared_key, <br>                 aws_vpn_connection.vpnConn.*.tunnel2_preshared_key)<br>}</pre><h3>Azure VPN</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/280/1*2KQXJatJS6HMkrvMvu7M-w.png" /></figure><p>The VPN module will focus on creating the VPN tunnel connections, which would be used by the Virtual Network Gateway to establish Ipsec/IKE connections with the remote peers ( AWS in this case ).</p><p>The VPN module creates the following:</p><ol><li><em>azure_local_network_gateway</em> : The remote peers to which we need an Ipsec connection.</li><li><em>azure_virtual_network_gateway_connection</em>: The Ipsec tunnel connection to the above created <em>azure_local_network_gateway.</em></li></ol><p><strong>Notes</strong></p><ol><li><em>var.remote_vpnconns : </em>An output from the AWS module ( defined above ) which lists the number of remote connections</li><li><em>var.aws_tunnel_info_address and var.aws_tunnel_info_psk</em>: These variables are given the output from the AWS module, and store the endpoint address and pre-shared key for the connection.</li><li><em>var.vng_id</em>: The output from the Azure VNET module providing the id for the Virtual Network Gateway.</li></ol><pre>resource &quot;azurerm_local_network_gateway&quot; &quot;remotePeers&quot; {<br>  count = length(var.remote_vpnconns)<br>  name                = format(&quot;azureGw-%d&quot;, count.index)<br>  location            = var.rg_location<br>  resource_group_name = var.rg_name<br><br>  gateway_address = var.remote_vpnconns[count.index][0]<br>  address_space = [var.remote_vpnconns[count.index][1]]<br>}<br><br>resource &quot;azurerm_virtual_network_gateway_connection&quot; &quot;tunnels&quot; {<br>  count               = length(var.remote_vpnconns)<br>  name                = format(&quot;tunnel-%d&quot;, count.index)<br>  location            = var.rg_location<br>  resource_group_name = var.rg_name<br><br>  type                       = &quot;IPsec&quot;<br>  virtual_network_gateway_id = var.vng_id<br>  local_network_gateway_id   = <br>          azurerm_local_network_gateway.remotePeers[count.index].id<br><br>  shared_key = var.remote_psk[count.index]<br>}</pre><h4>variables.tf</h4><p>The <em>variables.tf</em> defines the variables required by this module</p><pre>variable &quot;rg_name&quot; {<br>  description = &quot;Azure Resource Group Name&quot;<br>}<br>variable &quot;rg_location&quot; {<br>  description = &quot;Azure Resource Group Location &quot;<br>}<br>variable &quot;remote_vpnconns&quot; {<br>  description = &quot;List of Remote VPN connections&quot;<br>}<br>variable &quot;vng_id&quot; {<br>  description = &quot;Azure Network Gateway ID&quot;<br>}<br>variable &quot;remote_psk&quot; {<br>  description = &quot;List pre shared keys for the remote Ipsec connections&quot;<br>}</pre><h4>main.tf ( Updated )</h4><p>The <em>main.tf</em> file above now has all the modules we would like to create. As you can see, using Terraform modules we are able to create around 25 resources in AWS and Azures by abstracting out the details.</p><pre>provider &quot;azurerm&quot; {<br>  skip_provider_registration = true<br>  features {}<br>}</pre><pre>provider &quot;aws&quot; {<br>  region = &quot;us-east-1&quot;<br>}</pre><pre>module &quot;awsVpc&quot; {<br>  source = &quot;./modules/aws/vpc/&quot;<br>  cidr =  &quot;10.0.0.0/16&quot;<br>  subnet_names = {&quot;10.0.0.0/24&quot;:&quot;awsSubnet1&quot;}<br>  subnet_zones = {&quot;10.0.0.0/24&quot;:&quot;us-east-1b&quot;}<br>  tags = {<br>    &quot;Name&quot; = &quot;awsMultiCloudVpc1&quot;<br>  }<br>  public_key = var.public_key<br>  ami = &quot;ami-0b161e951484253ab&quot;<br>}<br><br>module &quot;awsVpn&quot; {<br>  source = &quot;./modules/aws/vpn/&quot;<br>  remote_gws = module.azureRg.azure_gw_info<br>  route_table_id = module.awsVpc.route_table_id<br>  vpc_cidr = &quot;10.0.0.0/16&quot;<br>  vpc_id = module.awsVpc.vpc_id<br>  bgp_asn = 65000<br>}<br><br>module &quot;azureVpn&quot; {<br>  source = &quot;./modules/azure/vpn/&quot;<br>  rg_location = module.azureRg.rg_location<br>  rg_name = module.azureRg.rg_name<br>  remote_vpnconns = module.awsVpn.aws_tunnel_info_address<br>  remote_psk = module.awsVpn.aws_tunnel_info_psk<br>  vng_id = module.azureRg.azure_vng_id<br>}</pre><p>Using Terraform modules makes it much easier to create repeatable templates making the process of automating deployments a breeze. After your module folders have been defined, you can easily create a simple python script to convert high level inputs from the user ( such as number of vpn connections, region and vpc cidr block) and create the above template.</p><h4>Let’s Deploy</h4><p>We will be using terraform init to initialize these new modules, and deploy using terraform apply. The truncated version of the output of theapply command shows the various resources that would be deployed.</p><pre>adhip:multicloud-terraform adhip$ terraform apply -target=module.awsVpn<br>var.password<br>  Enter a value:</pre><pre>var.public_key<br>  Enter a value:</pre><pre>var.username<br>  Enter a value:</pre><pre>An execution plan has been generated and is shown below.<br>Resource actions are indicated with the following symbols:<br>  + create</pre><pre>Terraform will perform the following actions:</pre><pre># module.awsVpn.aws_customer_gateway.cgw[0] will be created<br># module.awsVpn.aws_route.remoteRoute[0] will be created<br># module.awsVpn.aws_vpn_connection.vpnConn[0] will be created<br># module.awsVpn.aws_vpn_connection_route.vpnConnectionRoute[0] will be created<br># module.awsVpn.aws_vpn_gateway.vpn_gateway will be created<br># module.azureVpn.azurerm_local_network_gateway.remotePeers[0] will be created<br># module.azureVpn.azurerm_local_network_gateway.remotePeers[1] will be created<br>#module.azureVpn.azurerm_virtual_network_gateway_connection.tunnels[0] will be created<br>#module.azureVpn.azurerm_virtual_network_gateway_connection.tunnels[1] will be created</pre><pre>Plan: 9 to add, 0 to change, 0 to destroy.</pre><p>After the resources have been deployed, the Azure and AWS consoles confirm that the Ipsec Connections/tunnels have been successfully created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GPvO6dzKm9QoWKB41gN2EA.png" /><figcaption>AWS Ipsec Connections are up.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GKqiIWCTUHzjGs6B7ezOgQ.png" /><figcaption>Azure Ipsec Connections show as Connected.</figcaption></figure><h4>The Traffic Test</h4><p>Now that the tunnels are up, we can SSH on to one of the instances and try pinging the other end’s Private IP address through the VPN tunnel.</p><pre>adhip:multicloud-terraform adhip$ ssh ec2-user@18.209.55.173<br>The authenticity of host &#39;18.209.55.173 (18.209.55.173)&#39; can&#39;t be established.<br>ECDSA key fingerprint is SHA256:4ZH7C3/L6/X4fVH6iJzQipj9b7RZPS36upTPUPeOp8M.<br>Are you sure you want to continue connecting (yes/no)? yes<br>Warning: Permanently added &#39;18.209.55.173&#39; (ECDSA) to the list of known hosts.<br>Last login: Sun Aug  9 01:48:14 2020 from c-73-189-36-193.hsd1.ca.comcast.net</pre><pre>__|  __|_  )<br>       _|  (     /   Amazon Linux 2 AMI<br>      ___|\___|___|</pre><pre><a href="https://aws.amazon.com/amazon-linux-2/">https://aws.amazon.com/amazon-linux-2/</a><br>16 package(s) needed for security, out of 89 available<br>Run &quot;sudo yum update&quot; to apply all updates.<br>[ec2-user@ip-10-0-0-250 ~]$ ping 100.0.0.4<br>PING 100.0.0.4 (100.0.0.4) 56(84) bytes of data.<br>64 bytes from 100.0.0.4: icmp_seq=1 ttl=64 time=71.2 ms<br>64 bytes from 100.0.0.4: icmp_seq=2 ttl=64 time=71.9 ms<br>64 bytes from 100.0.0.4: icmp_seq=3 ttl=64 time=71.6 ms<br>64 bytes from 100.0.0.4: icmp_seq=4 ttl=64 time=71.5 ms<br>64 bytes from 100.0.0.4: icmp_seq=5 ttl=64 time=73.1 ms<br>^C<br>--- 100.0.0.4 ping statistics ---<br>5 packets transmitted, 5 received, 0% packet loss, time 4005ms<br>rtt min/avg/max/mdev = 71.216/71.905/73.177/0.734 ms<br>[ec2-user@ip-10-0-0-250 ~]$</pre><p>You can see above that we can send traffic through the Ipsec VPN Tunnel from the AWS instance to the Azure instance’s private IP address. Let’s take this a step further and try doing an iPerf traffic test across the two clouds.</p><p>The AWS instance already had iperf3 installed, so I just have to install iperf3 on the Azure instance and start the iperf server there.</p><pre>arastra@multicloud-azurevm1:~$ sudo apt update<br>arastra@multicloud-azurevm1:~$ sudo apt-get install iperf3<br>arastra@multicloud-azurevm1:~$ iperf3 -s -p 5001<br></pre><p>On the AWS instance I will start the iperf client, and you see that traffic is being transferred from one end to the other.</p><pre>[ec2-user@ip-10-0-0-250 ~]$ iperf3 -c 100.0.0.4 -p 5001<br>Connecting to host 100.0.0.4, port 5001<br>[  4] local 10.0.0.250 port 39322 connected to 100.0.0.4 port 5001<br>[ ID] Interval           Transfer     Bandwidth       Retr  Cwnd<br>[  4]   0.00-1.00   sec  6.41 MBytes  53.7 Mbits/sec  152    475 KBytes       <br>[  4]   1.00-2.00   sec  4.57 MBytes  38.3 Mbits/sec    2    363 KBytes       <br>[  4]   2.00-3.00   sec  4.57 MBytes  38.3 Mbits/sec    0    386 KBytes       <br>[  4]   3.00-4.00   sec  5.68 MBytes  47.6 Mbits/sec    0    398 KBytes       <br>[  4]   4.00-5.00   sec  4.69 MBytes  39.3 Mbits/sec    0    403 KBytes       <br>[  4]   5.00-6.00   sec  5.86 MBytes  49.2 Mbits/sec    0    403 KBytes       <br>[  4]   6.00-7.00   sec  5.55 MBytes  46.6 Mbits/sec    0    403 KBytes       <br>[  4]   7.00-8.00   sec  4.69 MBytes  39.3 Mbits/sec    0    405 KBytes       <br>[  4]   8.00-9.00   sec  5.99 MBytes  50.2 Mbits/sec    0    413 KBytes       <br>[  4]   9.00-10.00  sec  5.68 MBytes  47.6 Mbits/sec    0    430 KBytes       <br>- - - - - - - - - - - - - - - - - - - - - - - - -<br>[ ID] Interval           Transfer     Bandwidth       Retr<br>[  4]   0.00-10.00  sec  53.7 MBytes  45.0 Mbits/sec  154             sender<br>[  4]   0.00-10.00  sec  51.2 MBytes  42.9 Mbits/sec                  receiver</pre><pre>iperf Done.</pre><p>We can also see the packets Data In and Data Out counters are being updated on the Azure portal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8B2fgL9NmKh83IBmGFlGSw.png" /><figcaption>The Tunnel counters on the Azure Portal</figcaption></figure><p>This concludes part II of the series. We are now able to successfully deploy Ipsec tunnels across clouds and send traffic between instances. This is a great prototype and proof of concept for connecting applications and exchanging traffic securely across clouds. And this can easily be extended to deploy multiple regions and clouds in a full mesh network.</p><p>In the last post, I will go over some optimizations that we could make in the Terraform modules code, and try out BGP instead of using static routes. And add some tips and tricks that would be useful for your future deployments.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b45b8117123b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Starting your Multi-Cloud journey with Terraform (Part 1)]]></title>
            <link>https://medium.com/@adhip12/starting-your-multi-cloud-journey-with-terraform-part-1-b240155036d8?source=rss-d666399a1d9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/b240155036d8</guid>
            <category><![CDATA[multi-cloud]]></category>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[terraform]]></category>
            <dc:creator><![CDATA[Adhip Gupta]]></dc:creator>
            <pubDate>Sun, 09 Aug 2020 20:51:30 GMT</pubDate>
            <atom:updated>2020-08-18T23:48:11.459Z</atom:updated>
            <content:encoded><![CDATA[<h3>Starting your Multi-Cloud journey with Terraform (Part I)</h3><h4>Multi-Cloud has become a reality as many more enterprises now have deployments across two or more clouds. In this series, we will go over how Terraform can help you deploy and manage the lifecycle of your resources across clouds. At the end of this series, we will be have a secure VPN connection using native AWS and Azure cloud solutions. This is the first of a three part series in which we will cover creating Azure and AWS resources.</h4><h3>Introduction</h3><p>Terraform is an Infrastructure as Code (IaaC) configuration and deployment tool that enables users to deploy infrastructure on any cloud, be it the well-known Cloud Service Providers (AWS, Azure and GCP etc.) or on-premises private cloud infrastructure ( VMware, OpenStack etc. ). If you haven’t used Terraform before, I would strongly suggest going through some tutorials to <a href="https://medium.com/@devopslearning/introduction-to-terraform-part-1-30bca7efa436">familiarize yourself with Terraform</a>.</p><p>Over the last five years, there has been a meteoric rise in businesses that are looking to adapt public clouds to lead their digital transformation. Moving to the cloud has not only reduced the infrastructure costs for these enterprises but the agility that the cloud environment provides has also been a massive help in giving them a competitive edge.</p><p>Most of the enterprises who own or lease data centers to host their applications, usually start with a hybrid cloud model to execute their cloud first strategy. Hybrid cloud enables them to distribute applications and compute units across public and private cloud based on the type of application. For example, a temporary and highly compute intensive big data application which needs a beefier machine can take advantage of the highly scalable and elastic cloud environments rather than spending the money to buy dedicated hardware for the same. On the other hand, sensitive data can still be stored on-premises and workloads in the cloud can then use VPN and dedicated connections to securely access this data.</p><p>In the recent past we have seen a shift in enterprises trying to avoid vendor lock-in, and have the flexibility to pick and choose the best in class solutions from multiple vendors. And although it provides the opportunity for enterprises to use different products, it becomes a nightmare to manage and govern.</p><p>When enterprises were using a single public cloud, IT and network administrators already had a tough job to keep themselves current with the CSPs that were constantly adding more services and tools. This becomes harder and disruptive when they need to be proficient in multiple cloud environments. For example, your knowledge about AWS CloudFormation will no longer help you in deploying infrastructure in Azure or GCP.</p><p>This is where Terraform can help provision and manage your deployments across clouds. It provides an abstraction layer between the user and the cloud. The user can envision a unified infrastructure spread across the private and public cloud and not disparate components on different platforms.</p><h3><strong>Multi-Cloud Connectivity</strong></h3><p>At the end of this three part series you should be more comfortable with using Terraform to deploy resources across multiple clouds. And use its modules and inherent dependency graphs to deploy dependent resources. We would be creating an AWS VPC with EC2 instances, an Azure VNET with VMs, and their cloud native VPN Gateways to create a secure IPsec VPN connection between the two clouds as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BfuFnPAnH2RUwpgk6_U1mA.png" /><figcaption>Connecting AWS and Azure through their VPN Gateway’s.</figcaption></figure><h3>Azure and AWS</h3><p>The diagram below dives into all the major components that would be deployed for Azure and AWS. In this post we will be focussing on creating the VPCs, VNETs and the VMs.</p><p>We would be using Terraform modules to group resources together and provide users an abstraction layer over the actual resources being created. And we will be creating Terraform modules in a way which will let you expand and scale your deployments by adding only extra variables instead of making changes to each resource separately.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mz26rb2_26SXikueeom2Yg.png" /><figcaption>The details of the Azure and AWS Resources that will be deployed.</figcaption></figure><h4>Azure VNET Module</h4><p>We start by creating a <em>modules/</em> folder and an <em>azure/vnet</em> subdirectory within it. In this folder, we create vnet.tf, variables.tf and output.tf files.</p><h4>vnet.tf</h4><p>We create a <em>vnet.tf </em>file which defines the following resources: <em>azurerm_resource_group, azurerm_virtual_network, azurerm_subnet, azurerm_public_ip, azurerm_virtual_network_gateway.</em></p><p><strong>Notes</strong></p><ol><li><em>var.subnet_list</em> : Based on the length of the list, the <em>count</em> variable will create subnets.</li><li><em>azurerm_subnet.gw_subnet </em>: The Virtual Network gateway needs a subnet named “GatewaySubnet” to be associated within its <em>ip_configurations</em></li><li>The <em>public_ip</em> for the Virtual Network Gateway on Azure has to be “Dynamic”.</li><li><em>ip_configurations</em> for Network Gateway: Associate the public_ip, that we created, to the network gateway. This will be used to create the Ipsec tunnel later.</li></ol><pre>resource &quot;azurerm_resource_group&quot; &quot;rg&quot; {<br>  name     = var.rg_name<br>  location = var.rg_location<br>}</pre><pre>resource &quot;azurerm_virtual_network&quot; &quot;vnet&quot; {<br>  name                = var.vnet_name<br>  location            = azurerm_resource_group.rg.location<br>  resource_group_name = azurerm_resource_group.rg.name<br>  address_space       = var.vnet_cidr<br>}</pre><pre>resource &quot;azurerm_subnet&quot; &quot;subnet&quot; {<br>  count                = length(var.subnet_list)<br>  name                 = var.subnet_names[count.index]<br>  resource_group_name  = azurerm_resource_group.rg.name<br>  virtual_network_name = azurerm_virtual_network.vnet.name<br>  address_prefix       = var.subnet_list[count.index]<br>}</pre><pre>resource &quot;azurerm_subnet&quot; &quot;gw_subnet&quot; {<br>  name                 = &quot;GatewaySubnet&quot;<br>  resource_group_name  = azurerm_resource_group.rg.name<br>  virtual_network_name = azurerm_virtual_network.vnet.name<br>  address_prefix       = var.gw_subnet_cidr<br>}</pre><pre>resource &quot;azurerm_public_ip&quot; &quot;public_ips&quot; {<br>  count               = 1<br>  name                = format(&quot;publicIp%d&quot;, count.index)<br>  location            = azurerm_resource_group.rg.location<br>  resource_group_name = azurerm_resource_group.rg.name<br>  allocation_method = &quot;Dynamic&quot;<br>}</pre><pre>resource &quot;azurerm_virtual_network_gateway&quot; &quot;virtual_network_gateway&quot; {<br>  name                = &quot;virtual_network_gateway&quot;<br>  location            = var.rg_location<br>  resource_group_name = var.rg_name</pre><pre>  type          = &quot;Vpn&quot;<br>  vpn_type      = &quot;RouteBased&quot;<br>  sku           = &quot;VpnGw1&quot;<br>  enable_bgp    = true</pre><pre>  ip_configuration {<br>    name  = azurerm_public_ip.public_ips[0].name<br>    public_ip_address_id  = azurerm_public_ip.public_ips[0].id<br>    private_ip_address_allocation = &quot;Dynamic&quot;<br>    subnet_id  = azurerm_subnet.gw_subnet.id<br>  }<br>}</pre><pre>resource &quot;azurerm_public_ip&quot; &quot;vm_public_ip&quot; {<br>  name                = &quot;publicIpVm1&quot;<br>  location            = azurerm_resource_group.rg.location<br>  resource_group_name = azurerm_resource_group.rg.name<br>  allocation_method = &quot;Static&quot;<br>}<br><br>resource &quot;azurerm_network_interface&quot; &quot;intf1&quot; {<br>  name                = &quot;intf1&quot;<br>  location            = azurerm_resource_group.rg.location<br>  resource_group_name = azurerm_resource_group.rg.name<br><br>  ip_configuration {<br>    name                          = &quot;internal&quot;<br>    subnet_id                     = azurerm_subnet.subnet[0].id<br>    private_ip_address_allocation = &quot;Dynamic&quot;<br>    public_ip_address_id = azurerm_public_ip.vm_public_ip.id<br>  }<br>}<br><br>resource &quot;azurerm_virtual_machine&quot; &quot;host&quot; {<br>  name                          = &quot;host-vm1&quot;<br>  location                      = var.rg_location<br>  resource_group_name           = var.rg_name<br>  network_interface_ids         = <br>                                [azurerm_network_interface.intf1.id]<br>  vm_size                       = &quot;Standard_D1_v2&quot;<br>  delete_os_disk_on_termination = true</pre><pre>  storage_image_reference {<br>    publisher = &quot;Canonical&quot;<br>    offer     = &quot;UbuntuServer&quot;<br>    sku       = &quot;16.04.0-LTS&quot;<br>    version   = &quot;latest&quot;<br>  }<br><br>  storage_os_disk {<br>    name              = &quot;host1vm1disk1&quot;<br>    caching           = &quot;ReadWrite&quot;<br>    create_option     = &quot;FromImage&quot;<br>    managed_disk_type = &quot;Standard_LRS&quot;<br>  }<br><br>  os_profile {<br>    computer_name  = &quot;vm1&quot;<br>    admin_username = var.username<br>    admin_password = var.password<br>  }<br>  os_profile_linux_config {<br>    disable_password_authentication = false<br>  }<br>}</pre><h4>variables.tf</h4><p>The <strong><em>variables.tf</em></strong> define the variables that we expect as input from the user:</p><pre>variable &quot;rg_name&quot; {<br>  description = &quot;Azure Resource Group Name&quot;<br>}<br>variable &quot;rg_location&quot; {<br>  description = &quot;Azure Resource Group Location &quot;<br>}<br>variable &quot;vnet_cidr&quot; {<br>  description = &quot;VNET Cidr block&quot;<br>}<br>variable &quot;vnet_name&quot; {<br>  description = &quot;VNET Name&quot;<br>}<br>variable &quot;subnet_names&quot; {<br>  description = &quot;List of Subnet names&quot;<br>}<br>variable &quot;subnet_list&quot; {<br>  description = &quot;List of Subnet prefixes&quot;<br>}<br>variable &quot;gw_subnet_cidr&quot; {<br>  description = &quot;Azure VPN Gateway needs a dedicated subnet. CIDR block for that subnet&quot;<br>}</pre><h4>output.tf</h4><p>The <strong><em>output.tf </em></strong>file defines the outputs for this module that can be used as an input to other modules.</p><pre>output &quot;azure_gw_info&quot; {<br>  value = setproduct(azurerm_public_ip.public_ips.*.ip_address, <br>                     var.vnet_cidr )<br>}</pre><pre>output &quot;azure_vng_id&quot; {<br>  value = azurerm_virtual_network_gateway.virtual_network_gateway.id<br>}<br>output &quot;rg_location&quot; {<br>  value = azurerm_resource_group.rg.location<br>}</pre><pre>output &quot;rg_name&quot; {<br>  value = azurerm_resource_group.rg.name<br>}</pre><pre>output &quot;vpn_gw_subnet_cidr&quot; {<br>  value = azurerm_subnet.gw_subnet.id<br>}</pre><h3>main.tf</h3><p>The main.tf file is created in the same parent directory in which the modules/ folder was created. It will be referencing the VNET module defined above, and takes the following inputs:</p><ol><li>Source: The path to the vnet directory</li><li>Resource Group and VNET info: location, name and CIDR</li><li>Subnet information: Subnet names and prefixes</li><li>Gateway Subnet CIDR</li></ol><pre>provider &quot;azurerm&quot; {<br>  skip_provider_registration = true<br>  features {}<br>}</pre><pre>module &quot;azureRg&quot; {<br>  source = &quot;./modules/azure/vnet/&quot;<br>  rg_location = &quot;westus2&quot;<br>  rg_name = &quot;multiCloud-Azure&quot;<br>  vnet_cidr = [&quot;100.0.0.0/16&quot;]<br>  subnet_list = [&quot;100.0.0.0/24&quot;]<br>  subnet_names = [&quot;AzureGwsubnet1&quot;]<br>  vnet_name = &quot;AzureVnet1&quot;<br>  gw_subnet_cidr = &quot;100.0.1.0/24&quot;<br>}</pre><h4>AWS VPC Module</h4><p>Similar to the Azure VNET module we will also create an AWS VPC module. The VPC module below creates the following: VPC, Subnets, routes and route tables, route table associations, and an Internet Gateway.</p><h4>vpc.tf</h4><pre>resource &quot;aws_vpc&quot; &quot;vpc&quot; {<br>  cidr_block = var.cidr<br>  tags = var.tags<br>}</pre><pre>resource &quot;aws_subnet&quot; &quot;subnet&quot; {<br>  count             = length(var.subnet_names)<br>  vpc_id            = aws_vpc.vpc.id<br>  cidr_block        = element(keys(var.subnet_names), count.index)<br>  availability_zone = element(values(var.subnet_zones), count.index)<br>  tags = {<br>    &quot;Name&quot; = element(values(var.subnet_names), count.index)<br>  }<br>}</pre><pre>resource &quot;aws_internet_gateway&quot; &quot;igw&quot; {<br>  vpc_id = aws_vpc.vpc.id</pre><pre>}<br>resource &quot;aws_route_table&quot; &quot;route_table&quot; {<br>  vpc_id = aws_vpc.vpc.id<br>}</pre><pre>resource &quot;aws_route&quot; &quot;defaultRoute&quot; {<br>  route_table_id         = aws_route_table.route_table.id<br>  destination_cidr_block = &quot;0.0.0.0/0&quot;<br>  gateway_id             = aws_internet_gateway.igw.id<br>}</pre><pre>resource &quot;aws_route_table_association&quot; &quot;route_table_association&quot; {<br>  subnet_id      = aws_subnet.subnet[0].id<br>  route_table_id = aws_route_table.route_table.id<br>}</pre><h4>variables.tf</h4><pre>variable &quot;subnet_zones&quot; {<br>  description = &quot;Subnet to Availability Zone map&quot;<br>  type        = map(string)<br>}<br>variable &quot;subnet_names&quot; {<br>  description = &quot;Subnet to name map&quot;<br>  type        = map(string)<br>}<br>variable &quot;region&quot; {<br>  default = &quot;&quot;<br>}<br>variable &quot;cidr&quot; {<br>  description = &quot;VPC Cidr&quot;<br>}<br>variable &quot;tags&quot; {<br>  default = {}<br>}<br>variable &quot;ami&quot; {<br>  description = &quot;AMI for the VM&quot;<br>}<br>variable &quot;public_key&quot; {<br>  description = &quot;Public key material to create keyPair&quot;<br>}</pre><h4>output.tf</h4><p>The <em>output.tf</em> defines the output variables for this module and returns the <em>vpc_cidr, </em>vpc and <em>route table ids</em> required by the VPN module ( Used later to create VPN resources )</p><pre>output &quot;route_table_id&quot; {<br>  value = aws_route_table.route_table.id<br>}</pre><pre>output &quot;vpc_cidr&quot; {<br>  value = aws_vpc.vpc.cidr_block<br>}</pre><pre>output &quot;vpc_id&quot; {<br>  value = aws_vpc.vpc.id<br>}<br></pre><h4>Main.tf (Updated)</h4><p>We add the AWS provider and the AWS VPC module to the already created main.tf file in the parent directory.</p><pre>provider &quot;azurerm&quot; {<br>  skip_provider_registration = true<br>  features {}<br>}<br><br>provider &quot;aws&quot; {<br>  region = &quot;us-east-1&quot;<br>}<br><br>module &quot;azureRg&quot; {<br>  source = &quot;./modules/azure/vnet/&quot;<br>  rg_location = &quot;westus2&quot;<br>  rg_name = &quot;multiCloud-Azure&quot;<br>  vnet_cidr = [&quot;100.0.0.0/16&quot;]<br>  subnet_list = [&quot;100.0.0.0/24&quot;]<br>  subnet_names = [&quot;AzureGwsubnet1&quot;]<br>  vnet_name = &quot;AzureVnet1&quot;<br>  gw_subnet_cidr = &quot;100.0.1.0/24&quot;<br>}<br><br>module &quot;awsVpc&quot; {<br>  source = &quot;./modules/aws/vpc/&quot;<br>  cidr =  &quot;10.0.0.0/16&quot;<br>  subnet_names = {&quot;10.0.0.0/24&quot;:&quot;awsSubnet1&quot;}<br>  subnet_zones = {&quot;10.0.0.0/24&quot;:&quot;us-east-1b&quot;}<br>  tags = {<br>    &quot;Name&quot; = &quot;awsMultiCloudVpc1&quot;<br>  }<br>}</pre><h4>Let’s Deploy</h4><blockquote>Make sure to set the correct environment variables with the <a href="https://registry.terraform.io/providers/hashicorp/aws/latest/docs">AWS</a> and <a href="https://www.terraform.io/docs/providers/azurerm/index.html">Azure</a> credentials before you apply.</blockquote><p>Terraform provides us with four simple commands to manage resources: init , plan, apply, and destroy.</p><p>The terraform apply output below shows 18 resources that would be created across AWS and Azure including VPC, VNET, VMs, Virtual Network Gateways and route tables. A truncated version of the terraform apply is shown below :</p><pre>adhip:multicloud-terraform adhip$ terraform apply<br>var.password<br>  Enter a value: </pre><pre>var.public_key<br>  Enter a value:</pre><pre>var.username<br>  Enter a value:</pre><pre>Refreshing Terraform state in-memory prior to plan...<br>The refreshed state will be used to calculate this plan, but will not be<br>persisted to local or remote state storage.</pre><pre>------------------------------------------------------------------------</pre><pre>An execution plan has been generated and is shown below.<br>Resource actions are indicated with the following symbols:<br>  + create</pre><pre>Terraform will perform the following actions:</pre><pre># module.awsVpc.aws_instance.vm will be created<br># module.awsVpc.aws_internet_gateway.igw will be created<br># module.awsVpc.aws_key_pair.keypair will be created<br># module.awsVpc.aws_route.defaultRoute will be created<br># module.awsVpc.aws_route_table.route_table will be created<br># module.awsVpc.aws_route_table_association.route_table_association will be created<br># module.awsVpc.aws_security_group.allowSSHIpsecIcmp will be created<br># module.awsVpc.aws_subnet.subnet[0] will be created<br># module.awsVpc.aws_vpc.vpc will be created<br># module.azureRg.azurerm_network_interface.intf1 will be created<br># module.azureRg.azurerm_public_ip.public_ips[0] will be created<br># module.azureRg.azurerm_public_ip.vm_public_ip will be created<br># module.azureRg.azurerm_resource_group.rg will be created<br># module.azureRg.azurerm_subnet.gw_subnet will be created<br># module.azureRg.azurerm_subnet.subnet[0] will be created<br># module.azureRg.azurerm_virtual_machine.host will be created<br># module.azureRg.azurerm_virtual_network.vnet will be created<br>module.azureRg.azurerm_virtual_network_gateway.virtual_network_gateway will be created</pre><pre>Plan: 18 to add, 0 to change, 0 to destroy.</pre><pre>Do you want to perform these actions?<br>  Terraform will perform the actions described above.<br>  Only &#39;yes&#39; will be accepted to approve.</pre><pre>Enter a value: yes</pre><blockquote>Note, that I have deployed the Azure VM using a username/password, whereas the AWS VM has been deployed using an SSH key. You can always change the Azure VM to use SSH keys as well.</blockquote><p>After you enter the <em>username</em>, <em>password</em> and <em>public_key</em>, Terraform will create the above resources. After the deployment is complete let’s use the terraform state show to get the instance details</p><blockquote>The Azure Virtual Network Gateway deployment takes around 30 minutes to complete!!!</blockquote><pre>Apply complete! Resources: 18 added, 0 changed, 0 destroyed.</pre><pre>adhip:multicloud-terraform adhip$ <em>terraform state show </em>module.awsVpc.aws_instance.vm<br># module.awsVpc.aws_instance.vm:<br>resource &quot;aws_instance&quot; &quot;vm&quot; {<br>  public_ip                    = &quot;54.175.60.88&quot;<br>}</pre><pre>adhip$ <em>terraform state show </em>module.azureRg.azurerm_public_ip.vm_public_ip<br># module.azureRg.azurerm_public_ip.vm_public_ip:<br>resource &quot;azurerm_public_ip&quot; &quot;vm_public_ip&quot; {<br>    allocation_method       = &quot;Static&quot;<br>    ip_address              = &quot;52.229.52.210&quot;<br>}</pre><p>Let’s SSH into the AWS instance and ping the Azure Public IP. You will see that the two instances are reachable over the public internet and the latency confirms that they have been deployed in separate regions.</p><pre>adhip:multicloud-terraform adhip$ ssh ec2-user@54.175.60.88<br>Last login: Wed Feb  5 04:17:18 2020 from 162.210.130.3</pre><pre>__|  __|_  )<br>       _|  (     /   Amazon Linux 2 AMI<br>      ___|\___|___|</pre><pre><a href="https://aws.amazon.com/amazon-linux-2/">https://aws.amazon.com/amazon-linux-2/</a><br>16 package(s) needed for security, out of 89 available<br>Run &quot;sudo yum update&quot; to apply all updates.</pre><pre>[ec2-user@ip-10-0-0-250 ~]$ ping 52.229.52.210<br>PING 52.229.52.210 (52.229.52.210) 56(84) bytes of data.<br>64 bytes from 52.229.52.210: icmp_seq=1 ttl=29 time=69.5 ms<br>64 bytes from 52.229.52.210: icmp_seq=2 ttl=29 time=69.7 ms<br>64 bytes from 52.229.52.210: icmp_seq=3 ttl=29 time=69.5 ms<br>^C<br>--- 52.229.52.210 ping statistics ---<br>3 packets transmitted, 3 received, 0% packet loss, time 2003ms<br>rtt min/avg/max/mdev = 69.530/69.598/69.727/0.233 ms<br>[ec2-user@ip-10-0-0-250 ~]$</pre><p>Hurray! We have passed the first test, and now that we have the basic building blocks. In the <a href="https://medium.com/@adhip12/starting-your-multi-cloud-journey-with-terraform-part-ii-b45b8117123b">next post</a>, we will go over creating the VPN resources for both Azure and AWS. And instead of pinging the public IP address, we will be able to ping across the Private IPs confirming that the VPN actually works!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b240155036d8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>