forked from microsoft/MLOpsPython
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Terraform option to environment_setup (microsoft#268)
* setup basic folder and file structure * add tf backend file and bash script to create state storage * basic pipeline for infrastructure with tf - yaml, tf, bash * naming and deleting unnecessary bash script * updated documentation * added to the get_started.md guide * added terraform plan step
- Loading branch information
1 parent
32dd48f
commit 8fb12af
Showing
6 changed files
with
158 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# CI/PR Pipeline that deploys an TF template to create or update the resources needed by the other pipelines. | ||
trigger: | ||
branches: | ||
include: | ||
- master | ||
paths: | ||
include: | ||
- environment_setup/tf-templates/* | ||
pr: | ||
branches: | ||
include: | ||
- master | ||
paths: | ||
include: | ||
- environment_setup/tf-templates/* | ||
|
||
pool: | ||
vmImage: 'ubuntu-latest' | ||
|
||
variables: | ||
- group: devopsforai-aml-vg | ||
|
||
steps: | ||
- task: charleszipp.azure-pipelines-tasks-terraform.azure-pipelines-tasks-terraform-installer.TerraformInstaller@0 | ||
displayName: 'Use Terraform 0.12.24' | ||
inputs: | ||
terraformVersion: 0.12.24 | ||
|
||
- task: charleszipp.azure-pipelines-tasks-terraform.azure-pipelines-tasks-terraform-cli.TerraformCLI@0 | ||
displayName: 'TF init - Deploy MLOps resources to Azure' | ||
inputs: | ||
command: init | ||
commandOptions: '-backend=true -backend-config=$(Build.SourcesDirectory)/environment_setup/tf-templates/backend.tf' | ||
workingDirectory: '$(Build.SourcesDirectory)/environment_setup/tf-templates' | ||
backendType: azurerm | ||
backendServiceArm: $(AZURE_RM_SVC_CONNECTION) | ||
ensureBackend: true | ||
backendAzureRmResourceGroupLocation: $(LOCATION) | ||
backendAzureRmResourceGroupName: $(RESOURCE_GROUP) | ||
backendAzureRmStorageAccountName: 'statestor' | ||
backendAzureRmStorageAccountSku: 'Standard_LRS' | ||
backendAzureRmContainerName: 'tfstate-cont' | ||
backendAzureRmKey: 'mlopsinfra.tfstate' | ||
|
||
- task: charleszipp.azure-pipelines-tasks-terraform.azure-pipelines-tasks-terraform-cli.TerraformCLI@0 | ||
displayName: 'TF validate - Deploy MLOps resources to Azure' | ||
inputs: | ||
command: validate | ||
workingDirectory: '$(Build.SourcesDirectory)/environment_setup/tf-templates' | ||
|
||
- task: charleszipp.azure-pipelines-tasks-terraform.azure-pipelines-tasks-terraform-cli.TerraformCLI@0 | ||
displayName: 'TF plan - Deploy MLOps resources to Azure' | ||
inputs: | ||
command: plan | ||
workingDirectory: '$(Build.SourcesDirectory)/environment_setup/tf-templates' | ||
environmentServiceName: $(AZURE_RM_SVC_CONNECTION) | ||
env: | ||
TF_VAR_BASE_NAME: $(BASE_NAME) | ||
TF_VAR_RESOURCE_GROUP: $(RESOURCE_GROUP) | ||
TF_VAR_WORKSPACE_NAME: $(WORKSPACE_NAME) | ||
|
||
- task: charleszipp.azure-pipelines-tasks-terraform.azure-pipelines-tasks-terraform-cli.TerraformCLI@0 | ||
displayName: 'TF apply - Deploy MLOps resources to Azure' | ||
inputs: | ||
command: apply | ||
workingDirectory: '$(Build.SourcesDirectory)/environment_setup/tf-templates' | ||
environmentServiceName: $(AZURE_RM_SVC_CONNECTION) | ||
env: | ||
TF_VAR_BASE_NAME: $(BASE_NAME) | ||
TF_VAR_RESOURCE_GROUP: $(RESOURCE_GROUP) | ||
TF_VAR_WORKSPACE_NAME: $(WORKSPACE_NAME) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
terraform { | ||
backend "azurerm" { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
provider "azurerm" { | ||
version = "=2.3.0" | ||
features {} | ||
} | ||
|
||
variable BASE_NAME {} | ||
variable RESOURCE_GROUP {} | ||
variable WORKSPACE_NAME {} | ||
|
||
#-------------------------------------------------------------------------------- | ||
|
||
#Set the already-existing resource group | ||
data "azurerm_resource_group" "amlrg" { | ||
name = var.RESOURCE_GROUP | ||
} | ||
|
||
#Set client config for a.o. tenant id | ||
data "azurerm_client_config" "currentconfig" { | ||
} | ||
|
||
#-------------------------------------------------------------------------------- | ||
|
||
# Storage account for AML Service | ||
resource "azurerm_storage_account" "amlstor" { | ||
name = "${var.BASE_NAME}amlsa" | ||
location = data.azurerm_resource_group.amlrg.location | ||
resource_group_name = data.azurerm_resource_group.amlrg.name | ||
account_tier = "Standard" | ||
account_replication_type = "LRS" | ||
} | ||
|
||
# Keyvault for AML Service | ||
resource "azurerm_key_vault" "amlkv" { | ||
name = "${var.BASE_NAME}-AML-KV" | ||
location = data.azurerm_resource_group.amlrg.location | ||
resource_group_name = data.azurerm_resource_group.amlrg.name | ||
tenant_id = data.azurerm_client_config.currentconfig.tenant_id | ||
sku_name = "standard" | ||
} | ||
|
||
# App Insights for AML Service | ||
resource "azurerm_application_insights" "amlai" { | ||
name = "${var.BASE_NAME}-AML-AI" | ||
location = data.azurerm_resource_group.amlrg.location | ||
resource_group_name = data.azurerm_resource_group.amlrg.name | ||
application_type = "web" | ||
} | ||
|
||
# Container registry for AML Service | ||
resource "azurerm_container_registry" "amlacr" { | ||
name = "${var.BASE_NAME}amlcr" | ||
resource_group_name = data.azurerm_resource_group.amlrg.name | ||
location = data.azurerm_resource_group.amlrg.location | ||
sku = "Standard" | ||
admin_enabled = true | ||
} | ||
|
||
# ML Workspace for AML Service, depending on the storage account, Keyvault, App Insights and ACR. | ||
resource "azurerm_machine_learning_workspace" "amlws" { | ||
name = var.WORKSPACE_NAME | ||
location = data.azurerm_resource_group.amlrg.location | ||
resource_group_name = data.azurerm_resource_group.amlrg.name | ||
application_insights_id = azurerm_application_insights.amlai.id | ||
key_vault_id = azurerm_key_vault.amlkv.id | ||
storage_account_id = azurerm_storage_account.amlstor.id | ||
container_registry_id = azurerm_container_registry.amlacr.id | ||
|
||
identity { | ||
type = "SystemAssigned" | ||
} | ||
} |