{"id":287,"date":"2023-05-28T13:38:25","date_gmt":"2023-05-28T13:38:25","guid":{"rendered":"https:\/\/archicode.be\/?p=287"},"modified":"2023-10-27T15:14:13","modified_gmt":"2023-10-27T13:14:13","slug":"infrastructure-as-code-and-source-controle","status":"publish","type":"post","link":"https:\/\/archicode.be\/index.php\/2023\/05\/28\/infrastructure-as-code-and-source-controle\/","title":{"rendered":"Infrastructure as Code and source controle"},"content":{"rendered":"\n<p>For those who don&#8217;t what is this about, Infrastructure as Code is a set of files when executed with the right tool, will create resources such as storage account, databases, virtual network etc.  It is mostly associated with the cloud.  As I&#8217;ve been working lately with Terraform, I really enjoyed it and I thought it was worth a blog post.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Premise<\/h2>\n\n\n\n<p>As a developer, all you focus on is the code of your application.  You launch it locally in order to debug it and this works fine until you&#8217;re done with it.  Then you need to deploy it and for this to happen, you need to specify which type of resource do you need and have them created in the production environment.  It was common before to ask the sysadmin to create the needed resource and also to deploy your code, but with the advent of the cloud and the Continuous Integration\/Continuous Deployment, the need to script as many of those steps as possible became more pressing as time went by.<\/p>\n\n\n\n<p>With the advent of the cloud came a paradigm shift where the infrastructure is not in our datacenters anymore nor is our source code.  This helped to create the CI\/CD pattern which allows the automatic build and release of our applications without human intervention (or limited to the approval of the said deployment)<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Source control<\/h2>\n\n\n\n<p>Source control has been a important concept in software development for a very long time.  It allowed a greater control on what is developped and how, the changes can be seen by other developers in the team so it enhances collaboration, and in the case of a on-premises server or in the cloud, the source code is safe even in the event of a computer crash or disk failure on the developer&#8217;s computer.<\/p>\n\n\n\n<p>What we can also say about the source control, is that with it came a lot of different concept like branches and pull requests which makes it easier to review the changes and helps sharing the knowledge of the code among team members.  <\/p>\n\n\n\n<p>Regarding infrastructure, most of it used to be made manually.  A sysadmin could script some of the task to create a new environment or a new infrastructure for a new project or app.  However, this was time consuming.  With infrastructure as code, not only we can source control the scripts that are made to create the infrastructure, but also reuse those scripts for any other similar project which we need to create an infrastructure for.  With the advent of cloud computing, it makes it even easier to create the environments in the cloud since infrastructure as code usually comes with a lot of supported providers to create any resource in the cloud.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Terraform<\/h2>\n\n\n\n<p>Terraform uses yaml files in order to create the infrastructure you need for your project.  With the 3620 different providers, one can reasonably assume that wherever you wish to create your infrastructure, they can do it with terraform.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>terraform {\n  required_providers {\n    azurerm = {\n      source = hashicorp\/azurerm\n      version = \">=2.0\"\n    }\n  }\n\n  provider \"azurerm\" {\n    features {}\n  }\n}\n\nresource \"azurerm_resource_group\" \"example\" {\n  name     = \"my-resource-group\"\n  location = \"westus\"\n}\n<\/code><\/pre>\n\n\n\n<p>In this example, the Terraform YAML file:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Defines the required Azure provider and version.<\/li>\n\n\n\n<li>Specifies the Azure provider and enables any additional features.<\/li>\n\n\n\n<li>Creates an Azure resource group named &#8220;my-resource-group&#8221; in the &#8220;westus&#8221; location.<\/li>\n<\/ol>\n\n\n\n<p><\/p>\n\n\n\n<p><em>That&#8217;s all I have for today, happy terraforming !<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>For those who don&#8217;t what is this about, Infrastructure as Code is a set of files when executed with the right tool, will create resources such as storage account, databases, virtual network etc. It is mostly associated with the cloud. As I&#8217;ve been working lately with Terraform, I really enjoyed it and I thought it&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_newsletter_tier_id":0,"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[1],"tags":[],"class_list":["post-287","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":292,"url":"https:\/\/archicode.be\/index.php\/2023\/10\/26\/my-experience-with-terraform\/","url_meta":{"origin":287,"position":0},"title":"My experience with Terraform.","author":"Hakim","date":"October 26, 2023","format":false,"excerpt":"Terraform is a technology that allows you to deploy your infrastructure using code. It uses YAML as a file format. It needs registered providers to create the desired infra in the right environment. You can create infra on Azure, AWS as well as on premise. When to use it? When\u2026","rel":"","context":"In &quot;Misc&quot;","block_context":{"text":"Misc","link":"https:\/\/archicode.be\/index.php\/category\/misc\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":159,"url":"https:\/\/archicode.be\/index.php\/2020\/06\/24\/feature-flags-using-azure-feature\/","url_meta":{"origin":287,"position":1},"title":"Feature flags using Azure feature","author":"Hakim","date":"June 24, 2020","format":false,"excerpt":"Feature flags are very useful when you develop an application and while you don't want users to use the feature that isn't really ready, you don't want to stay on a side branch for too long as merging and rebasing from the main branch can become quite the chore. Enter\u2026","rel":"","context":"In &quot;.NET&quot;","block_context":{"text":".NET","link":"https:\/\/archicode.be\/index.php\/category\/net\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":137,"url":"https:\/\/archicode.be\/index.php\/2020\/06\/09\/publish-a-xamarin-app-to-app-center-with-azure-pipeline\/","url_meta":{"origin":287,"position":2},"title":"Publish a Xamarin app to App Center with Azure Pipeline.","author":"Hakim","date":"June 9, 2020","format":false,"excerpt":"I've been working on an android app with Xamarin lately and I wanted to deploy it to App Center automatically so I can install it on my mobile to test it as I hate manual deployment. I knew that App Center had a connector to azure devops repositories so you\u2026","rel":"","context":"In &quot;Uncategorised&quot;","block_context":{"text":"Uncategorised","link":"https:\/\/archicode.be\/index.php\/category\/uncategorised\/"},"img":{"alt_text":"","src":"\/wp-content\/uploads\/2020\/06\/image-2-1024x1018.png","width":350,"height":200},"classes":[]},{"id":115,"url":"https:\/\/archicode.be\/index.php\/2019\/10\/02\/how-to-blazor-components-basic\/","url_meta":{"origin":287,"position":3},"title":"How to : Blazor components (basic)","author":"Hakim","date":"October 2, 2019","format":false,"excerpt":"One essential aspect of Blazor are components. They are basically your Blazor code container. This is where you put the UI and the code needed for your UI to behave the way you want it to. You can dissociate the code from the UI but it's not mandatory. For small\u2026","rel":"","context":"In &quot;Uncategorised&quot;","block_context":{"text":"Uncategorised","link":"https:\/\/archicode.be\/index.php\/category\/uncategorised\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":162,"url":"https:\/\/archicode.be\/index.php\/2020\/06\/30\/blazor-server-side-or-web-assembly\/","url_meta":{"origin":287,"position":4},"title":"Blazor : server-side or Web assembly","author":"Hakim","date":"June 30, 2020","format":false,"excerpt":"Blazor is amazing. But if you are wondering which of Web Assembly of Server-Side would suit your project, here's an attempt to explain and help","rel":"","context":"In &quot;.NET&quot;","block_context":{"text":".NET","link":"https:\/\/archicode.be\/index.php\/category\/net\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":324,"url":"https:\/\/archicode.be\/index.php\/2023\/11\/07\/how-to-use-feature-flags-in-blazor\/","url_meta":{"origin":287,"position":5},"title":"How to use Feature Flags in Blazor","author":"Hakim","date":"November 7, 2023","format":false,"excerpt":"Feature flags are a way of controlling the availability and behavior of features in your application without changing the code. They can help you with testing, experimentation, and gradual rollout of new functionality. Blazor is a framework for building interactive web UIs using C# and .NET. In this blog post,\u2026","rel":"","context":"Similar post","block_context":{"text":"Similar post","link":""},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/archicode.be\/wp-content\/uploads\/2023\/11\/4b6f8d86-a588-4313-8cc9-4c41a90aaae5.jpeg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/archicode.be\/wp-content\/uploads\/2023\/11\/4b6f8d86-a588-4313-8cc9-4c41a90aaae5.jpeg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/archicode.be\/wp-content\/uploads\/2023\/11\/4b6f8d86-a588-4313-8cc9-4c41a90aaae5.jpeg?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/archicode.be\/wp-content\/uploads\/2023\/11\/4b6f8d86-a588-4313-8cc9-4c41a90aaae5.jpeg?resize=700%2C400&ssl=1 2x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/archicode.be\/index.php\/wp-json\/wp\/v2\/posts\/287","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/archicode.be\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/archicode.be\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/archicode.be\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/archicode.be\/index.php\/wp-json\/wp\/v2\/comments?post=287"}],"version-history":[{"count":6,"href":"https:\/\/archicode.be\/index.php\/wp-json\/wp\/v2\/posts\/287\/revisions"}],"predecessor-version":[{"id":300,"href":"https:\/\/archicode.be\/index.php\/wp-json\/wp\/v2\/posts\/287\/revisions\/300"}],"wp:attachment":[{"href":"https:\/\/archicode.be\/index.php\/wp-json\/wp\/v2\/media?parent=287"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/archicode.be\/index.php\/wp-json\/wp\/v2\/categories?post=287"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/archicode.be\/index.php\/wp-json\/wp\/v2\/tags?post=287"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}