AzureDevOps-Terraform

所属分类:DevOps
开发工具:HCL
文件大小:247KB
下载次数:0
上传日期:2021-04-06 06:22:54
上 传 者sh-1993
说明:  在Azure中创建中心分支网络,在Azure DevOps中使用基础架构作为代码进行自动化
(Create a Hub-Spoke network in Azure, automated with Infrastructure as Code in Azure DevOps)

文件列表:
Deploy-Terraform.yml (2323, 2021-04-06)
Destroy-Terraform.yml (1051, 2021-04-06)
Terraform (0, 2021-04-06)
Terraform\main.tf (1859, 2021-04-06)
Terraform\modules (0, 2021-04-06)
Terraform\modules\rg (0, 2021-04-06)
Terraform\modules\rg\main.tf (184, 2021-04-06)
Terraform\modules\rg\output.tf (150, 2021-04-06)
Terraform\modules\rg\variables.tf (364, 2021-04-06)
Terraform\modules\vnet (0, 2021-04-06)
Terraform\modules\vnet\hub (0, 2021-04-06)
Terraform\modules\vnet\hub\main.tf (1759, 2021-04-06)
Terraform\modules\vnet\hub\output.tf (254, 2021-04-06)
Terraform\modules\vnet\hub\variables.tf (1081, 2021-04-06)
Terraform\modules\vnet\spoke01 (0, 2021-04-06)
Terraform\modules\vnet\spoke01\main.tf (2240, 2021-04-06)
Terraform\modules\vnet\spoke01\output.tf (32, 2021-04-06)
Terraform\modules\vnet\spoke01\variables.tf (1011, 2021-04-06)
Terraform\modules\vnet\spoke02 (0, 2021-04-06)
Terraform\modules\vnet\spoke02\main.tf (2240, 2021-04-06)
Terraform\modules\vnet\spoke02\output.tf (32, 2021-04-06)
Terraform\modules\vnet\spoke02\variables.tf (1011, 2021-04-06)
Terraform\output.tf (11, 2021-04-06)
Terraform\terraform.tfvars (74, 2021-04-06)
Terraform\variables.tf (395, 2021-04-06)
images (0, 2021-04-06)
images\Pipeline_Deploy.jpg (169068, 2021-04-06)
images\Run_Pipeline.jpg (29566, 2021-04-06)
images\pipelines_library.jpg (16808, 2021-04-06)
images\terraform_backend_config.jpg (83900, 2021-04-06)

# Azure DevOps and Terraform The code found in this repository creates a Hub and Spoke topology in Azure, implemented via Azure DevOps pipelines with Terraform. Microsoft docs: [Hub-spoke topology](https://docs.microsoft.com/en-us/azure/architecture/reference-architectures/hybrid-networking/hub-spoke?tabs=cli) This code can be used for learning purposes or other purposes. It doesn't include all of the steps in detail so some research while deploying it will be needed for beginners but that is the best way to learn :-) Just have fun in the process! --- ## Prepare Your Environment ### - Azure subscription (free will do) Knowledge of Azure and how to create resources is needed. [Get started](https://azure.microsoft.com/en-us/) ### - Azure DevOps organization (free will do) To get started with Azure DevOps, use the same account as your Azure subscription. [Get started](https://azure.microsoft.com/en-us/services/devops/) --- ### Tools for your local machine if you want to make changes to the code: ### VS Code | Name | Installation Method | Install Command | | ----------------------------------------| -----------------------| ---------------------------------------------------| | VS Code | Download & Install | [Download here](https://code.visualstudio.com/) | | Azure Terraform | VS Code extension | Install in VS Code | | Hashicorp
Terraform | VS Code extension | Install in VS Code | ### Terraform | Name | Installation Method | Install Command | | ------------------------ | ---------------------- | ----------------------------------------------------------- | | Terraform | Download & Install | [Download here](https://www.terraform.io/downloads.html) | --- ## Terraform code The Terraform code can be found in the folder `Terraform` and is for anyone that wants to create a Hub and Spoke topology in Azure. *NOTE: I've added the .tfvars file into the repo, which you would normally add in your .gitignore file, to give you minimal struggle to set things up* ## YAML code There are two YAML files for two seperate pipelines in Azure DevOps. One is for validating Terraform and deploying the Infrastructure. The other one is for destroying the infrastructure if needed. ## Set up Azure You will need to set up a resource group and storage account in Azure to store the Terraform state file. You'll need the names of these resources to add them as variables to your pipelines. - Create a resource group - Create a storage account within that resource group - Create a container within that storage account ## Set up Azure DevOps Once you have signed up for Azure DevOps and created an organization, create your project. Check the "Get started" URL above. - Import the code within Azure Repos (select the "Existing Azure Pipelines Yaml file" configuration) - Install the Terraform extension for Azure DevOps: [Get it here](https://marketplace.visualstudio.com/items?itemName=ms-devlabs.custom-terraform-tasks) Create a service connection that enables Azure Pipelines to access your Azure subscription. Azure Pipelines uses this service connection to deploy the Terraform configuration. - Set up a service connection with the type being Azure Resource Manager (automatic) --- ### Setup Azure Pipelines In Azure DevOps go to Pipelines -> Library and create the variable group as shown in the image (backend_config is referenced in the YAML files as a variable group). pipeline variables Add the following variable names and insert your own values (except the \'terraform.tfstate' thats the value you should insert) Terraform Backend - tbc__backend_service_arm - tbc__container_name - tbc__key - tbc__resource_group_name - tbc__storage_account_name --- Now is where the fun stuff comes in to play and where you're going to build the pipeline(s). - In Azure DevOps go to Pipelines and click \'Create pipeline'. - Select Azure Repos cause that is where you stored the code and for the configuration select "Existing Azure Pipelines YAML file". - In the path selection you should have two options. One is the deploy and the other is the destroy file. Select the deploy file and click Ok. - Run your pipeline and watch it automatically rollout your Hub-Spoke network in Azure Run pipeline Watch the stages and steps deploying your code: Pipeline deploy After the deployment has finished, go over to the Azure portal and check out your newly created resources with Terraform. You should have a 'dev-engineering-rg' resource group with the resources created.

近期下载者

相关文件


收藏者