Skip to content

Commit 5c75c4a

Browse files
authored
Merge pull request #88 from microsoft/laragoldstein13-patch-1
Laragoldstein13 patch 1 - IaC mapping info for customers
2 parents 7e3060a + c7131af commit 5c75c4a

File tree

3 files changed

+71
-0
lines changed

3 files changed

+71
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
trigger: none
2+
3+
pool:
4+
vmImage: 'windows-latest'
5+
6+
steps:
7+
- task: TerraformInstaller@0
8+
inputs:
9+
terraformVersion: '1.0.0'
10+
- checkout: self
11+
12+
- task: AzureCLI@2
13+
inputs:
14+
azureSubscription: '<EnterServiceConnection>'
15+
scriptType: 'bash'
16+
scriptLocation: 'inlineScript'
17+
inlineScript: |
18+
az account show
19+
cd ./Modules-Prod
20+
terraform init
21+
terraform plan
22+
terraform apply -auto-approve
23+
24+
- task: MicrosoftSecurityDevOps@1
25+
displayName: 'Microsoft Security DevOps'
26+
task: MicrosoftSecurityDevOps@1
27+
displayName: 'Microsoft Security DevOps'
28+
# If you want to only run iacfilescanner, uncomment the below lines
29+
# inputs:
30+
# tools: 'iacfilescanner'

samples/IaCMapping/main.tf

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
terraform {
2+
required_providers {
3+
azurerm = {
4+
source = "hashicorp/azurerm"
5+
version = "~> 3.0" # adjust this as per your requirements
6+
}
7+
}
8+
}
9+
10+
provider "azurerm" {
11+
features {}
12+
}
13+
14+
resource "azurerm_resource_group" "resourcegroup" {
15+
name = "iacmappingdemo"
16+
location = "Central US"
17+
}
18+
19+
resource "azurerm_storage_account" "terraformaccount1" {
20+
name = "iacmapping1212"
21+
resource_group_name = azurerm_resource_group.resourcegroup.name
22+
location = "Central US"
23+
account_tier = "Standard"
24+
account_replication_type = "GRS"
25+
26+
tags = {
27+
"mapping_tag" = "6189b638-15a5-42ec-b934-0d2b8e035ce1"
28+
}
29+
}

samples/IaCMapping/readme.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
## Introduction
2+
3+
This folder provides samples for using [Infrastructure as Code mapping](https://learn.microsoft.com/azure/defender-for-cloud/iac-template-mapping) within DevOps security in Microsoft Defender for Cloud.
4+
5+
This sample deployment should only be performed in non-production subscriptions with **no other Terraform managed resources**.
6+
7+
Note that we do not choose a backend location to store the state file in this demo. Terraform utilizes a state file to store information about the current state of your managed infrastructure and associated configuration. This file will need to be persisted between different runs of the workflow. The recommended approach is to store this file within an Azure Storage Account or other similar remote backend. Normally, this storage would be provisioned manually or via a separate workflow. The Terraform backend block will need to be updated with your selected storage location (see here for documentation). To learn how to incorporate this, see [here](https://developer.hashicorp.com/terraform/language/settings/backends/azurerm).
8+
9+
## Contents
10+
* [main.tf](main.tf) provisions an Azure Storage account through Terraform with a unique mapping_tag. To use this template, ensure you modify the locations, names, and unique GUID. To generate a GUID, use [this website](https://guidgenerator.com/).
11+
* [azure-pipelines.yml](azure-pipelines.yml) is a sample Azure DevOps pipeline that can be used to provision the Terraform code in main.tf as a resource within Azure. It is important to include the MSDO task in your ADO pipeline.
12+
* Requires [Azure Resource Manager service connection](https://learn.microsoft.com/troubleshoot/azure/devops/overview-of-azure-resource-manager-service-connections#create-an-azure-rm-service-connection) with permissions to an Azure subscription.

0 commit comments

Comments
 (0)