This repo is created for GitHub Copilot Adoption Program, specifically for DevOps and SRE Hands On!
- VS Code and Terraform
- Create Terraform project using GitHub Copilot from a Scratch.
- VS Code
- GitHub Copilot license
- GitHub Copilot Extension
- GIT CLI
- GitHub Copilot CLI Extension
- VS Speech Extension
- Terraform Extension
@workspace /new create folders and files structures to provision an Azure App Service with terraform over one environment: DEV. All this using the Terraform Azure Provider.
- Click on Create Workspace.
-
The ".tf" files could be different because we are working with gen-ai, if you have problems use bellow ones.
-
main.tf
# We strongly recommend using the required_providers block to set the
# Azure Provider source and version being used
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "=3.0.0"
}
}
}
# Configure the Microsoft Azure Provider
provider "azurerm" {
skip_provider_registration = true # This is only required when the User, Service Principal, or Identity running Terraform lacks the permissions to register Azure Resource Providers.
features {}
}
# Resource group
resource "azurerm_resource_group" "dev" {
name = var.resource_group_name
location = var.location
}
# App service plan
resource "azurerm_app_service_plan" "dev" {
name = var.app_service_plan_name
location = azurerm_resource_group.dev.location
resource_group_name = azurerm_resource_group.dev.name
sku {
tier = "Standard"
size = "S1"
}
}
# App service
resource "azurerm_app_service" "dev" {
name = var.app_service_name
location = azurerm_resource_group.dev.location
resource_group_name = azurerm_resource_group.dev.name
app_service_plan_id = azurerm_app_service_plan.dev.id
site_config {
dotnet_framework_version = "v5.0"
scm_type = "LocalGit"
}
}
# Create an Azure Storage Account
resource "azurerm_storage_account" "dev" {
name = var.storage_account_name
resource_group_name = azurerm_resource_group.dev.name
location = azurerm_resource_group.dev.location
account_tier = "Standard"
account_replication_type = "LRS"
}- variables.tf
# Input variables for the DEV environment
variable "resource_group_name" {
description = "The name of the resource group for the DEV environment"
type = string
}
variable "app_service_name" {
description = "The name of the Azure App Service for the DEV environment"
type = string
}
variable "app_service_plan_name" {
description = "The name of the Azure App Service Plan for the DEV environment"
type = string
}
variable "storage_account_name" {
description = "The name of the Azure Storage Account for the DEV environment"
type = string
}
variable "location" {
description = "The Azure region for the DEV environment"
type = string
}- terraform.tfvars
# Azure Resource Group Name
resource_group_name = "dev-resource-group-traid"
# Azure App Service Name
app_service_name = "dev-app-service-traid"
# Azure App Service Plan Name
app_service_plan_name = "dev-app-service-plan-traid"
# Azure Storage Account Name
storage_account_name = "devstorageaccounttraid"
# Azure Region
location = "West US"@workspace create a README.md Markdown file that document all functions, files and folders.
- Check the generated Markdown File and create a new file with the suggestion
How can I initialize the Terraform configuration for my Azure App Service deployment?
- CHeck Copilot Chat suggestion and try to follow the steps.
Create an Azure Storage Account using Terraform azurerm provider.
terraform init
gh copilot explain "Terraform init"
@workspace Please generate an Azure DevOps Pipeline ".yaml" in order to execute and deploy infrastructure with the files used here as reference.
