Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

101-azure-resource-manager-custom-providers #394

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions quickstart/101-azure-resource-manager-custom-providers/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Azure Template Deployment

This template deploys a custom resource provider with a single resource type. The resource type has a single endpoint that responds to GET requests. The response is the content of the `responseContent` property.

## Terraform resource types

- [random_pet](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/pet)
- [azurerm_resource_group](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group)
- [azurerm_template_deployment](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/template_deployment)

## Variables

| Name | Description | Default value |
|-|-|-|
| `resource_group_name_prefix` | Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription. | rg |
| `resource_group_location` | Location of the resource group. | eastus |

## Example
54 changes: 54 additions & 0 deletions quickstart/101-azure-resource-manager-custom-providers/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
resource "random_pet" "rg_name" {
prefix = var.resource_group_name_prefix
}

resource "azurerm_resource_group" "rg" {
location = var.resource_group_location
name = random_pet.rg_name.id
}

resource "random_string" "name" {
length = 12
lower = true
upper = false
numeric = false
special = false
}
resource "azurerm_template_deployment" "example" {
name = coalesce(var.template_name, random_string.name.id)
resource_group_name = azurerm_resource_group.rg.name
deployment_mode = "Incremental"

template_content = <<TEMPLATE
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"variables": {},
"resources": [
{
"type": "Microsoft.CustomProviders/resourceProviders",
"name": "public/custom.example",
"apiVersion": "2018-09-01-preview",
"location": "${azurerm_resource_group.rg.location}",
"properties": {
"resourceTypes": [
{
"name": "exampleType",
"routingType": "Proxy,Cache",
"endpoints": [
{
"enabled": true,
"route": "{requestPath}",
"httpMethod": "GET",
"response": "{responseContent}"
}
]
}
]
}
}
]
}
TEMPLATE
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
output "resource_group_name" {
value = azurerm_resource_group.rg.name
}

output "template_deployment_name" {
value = azurerm_template_deployment.example.name
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
terraform {
required_version = ">=1.0"

required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~>3.0"
}
random = {
source = "hashicorp/random"
version = "~>3.0"
}
}
}

provider "azurerm" {
features {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
variable "resource_group_name_prefix" {
type = string
default = "rg"
description = "Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription."
}

variable "resource_group_location" {
type = string
default = "eastus"
description = "Location of the resource group."
}

variable "template_name" {
type = string
default = ""
description = "Name of the template deployment."
}
Loading