New sample
This commit is contained in:
parent
c2a3a784d8
commit
66edc2e080
25
quickstart/101-azure-api-management-create/main.tf
Normal file
25
quickstart/101-azure-api-management-create/main.tf
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
resource "random_pet" "rg_name" {
|
||||||
|
prefix = var.resource_group_name_prefix
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "azurerm_resource_group" "rg" {
|
||||||
|
name = random_pet.rg_name.id
|
||||||
|
location = var.resource_group_location
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "random_string" "name" {
|
||||||
|
length = 13
|
||||||
|
lower = true
|
||||||
|
numeric = false
|
||||||
|
special = false
|
||||||
|
upper = false
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "azurerm_api_management" "api" {
|
||||||
|
name = "apiservice${random_string.name.result}"
|
||||||
|
location = azurerm_resource_group.rg.location
|
||||||
|
resource_group_name = azurerm_resource_group.rg.name
|
||||||
|
publisher_email = var.publisher_email
|
||||||
|
publisher_name = var.publisher_name
|
||||||
|
sku_name = "${var.sku}_${var.sku_count}"
|
||||||
|
}
|
1
quickstart/101-azure-api-management-create/outputs.tf
Normal file
1
quickstart/101-azure-api-management-create/outputs.tf
Normal file
@ -0,0 +1 @@
|
|||||||
|
|
16
quickstart/101-azure-api-management-create/providers.tf
Normal file
16
quickstart/101-azure-api-management-create/providers.tf
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
terraform {
|
||||||
|
required_version = ">=0.12"
|
||||||
|
required_providers {
|
||||||
|
azurerm = {
|
||||||
|
source = "hashicorp/azurerm"
|
||||||
|
version = "~>2.0"
|
||||||
|
}
|
||||||
|
random = {
|
||||||
|
source = "hashicorp/random"
|
||||||
|
version = "~>3.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
provider "azurerm" {
|
||||||
|
features {}
|
||||||
|
}
|
20
quickstart/101-azure-api-management-create/readme.md
Normal file
20
quickstart/101-azure-api-management-create/readme.md
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
# Azure API Management service
|
||||||
|
|
||||||
|
This template deploys an Azure API Management service.
|
||||||
|
|
||||||
|
## 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_api_management](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/api_management)
|
||||||
|
|
||||||
|
## Variables
|
||||||
|
|
||||||
|
| Name | Description | Default |
|
||||||
|
|-|-|-|
|
||||||
|
| `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 |
|
||||||
|
| `publisher_email` | Email address of the owner of the service. | |
|
||||||
|
| `publisher_name` | Name of the owner of the service. | |
|
||||||
|
| `sku` | Pricing tier of this API Management service | Developer |
|
||||||
|
| `sku_count` | Instance size of this API Management service. | 1 |
|
47
quickstart/101-azure-api-management-create/variables.tf
Normal file
47
quickstart/101-azure-api-management-create/variables.tf
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
variable "resource_group_location" {
|
||||||
|
default = "eastus"
|
||||||
|
description = "Location for all resources."
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "resource_group_name_prefix" {
|
||||||
|
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 "publisher_email" {
|
||||||
|
description = "The email address of the owner of the service"
|
||||||
|
type = string
|
||||||
|
validation {
|
||||||
|
condition = length(var.publisher_email) > 0
|
||||||
|
error_message = "The publisher_email must contain at least one character."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "publisher_name" {
|
||||||
|
description = "The name of the owner of the service"
|
||||||
|
type = string
|
||||||
|
validation {
|
||||||
|
condition = length(var.publisher_name) > 0
|
||||||
|
error_message = "The publisher_name must contain at least one character."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "sku" {
|
||||||
|
description = "The pricing tier of this API Management service"
|
||||||
|
default = "Developer"
|
||||||
|
type = string
|
||||||
|
validation {
|
||||||
|
condition = contains(["Developer", "Standard", "Premium"], var.sku)
|
||||||
|
error_message = "The sku must be one of the following: Developer, Standard, Premium."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "sku_count" {
|
||||||
|
description = "The instance size of this API Management service."
|
||||||
|
default = 1
|
||||||
|
type = number
|
||||||
|
validation {
|
||||||
|
condition = contains([1, 2], var.sku_count)
|
||||||
|
error_message = "The sku_count must be one of the following: 1, 2."
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user