Merge pull request #158 from TomArcherMsft/UserStory60501-azure-api-management-create
User Story 60501: Azure API Management
This commit is contained in:
commit
ae25ed44ce
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" "azurerm_api_management_name" {
|
||||
length = 13
|
||||
lower = true
|
||||
numeric = false
|
||||
special = false
|
||||
upper = false
|
||||
}
|
||||
|
||||
resource "azurerm_api_management" "api" {
|
||||
name = "apiservice${random_string.azurerm_api_management_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}"
|
||||
}
|
7
quickstart/101-azure-api-management-create/outputs.tf
Normal file
7
quickstart/101-azure-api-management-create/outputs.tf
Normal file
@ -0,0 +1,7 @@
|
||||
output "resource_group_name" {
|
||||
value = azurerm_resource_group.rg.name
|
||||
}
|
||||
|
||||
output "api_management_service_name" {
|
||||
value = azurerm_api_management.api.name
|
||||
}
|
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 = ">=1.0"
|
||||
required_providers {
|
||||
azurerm = {
|
||||
source = "hashicorp/azurerm"
|
||||
version = "~>3.0"
|
||||
}
|
||||
random = {
|
||||
source = "hashicorp/random"
|
||||
version = "~>3.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
provider "azurerm" {
|
||||
features {}
|
||||
}
|
21
quickstart/101-azure-api-management-create/readme.md
Normal file
21
quickstart/101-azure-api-management-create/readme.md
Normal file
@ -0,0 +1,21 @@
|
||||
# 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)
|
||||
- [random_string](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/string)
|
||||
- [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. | test@contoso.com |
|
||||
| `publisher_name` | Name of the owner of the service. | publisher |
|
||||
| `sku` | Pricing tier of this API Management service | Developer |
|
||||
| `sku_count` | Instance size of this API Management service. | 1 |
|
51
quickstart/101-azure-api-management-create/variables.tf
Normal file
51
quickstart/101-azure-api-management-create/variables.tf
Normal file
@ -0,0 +1,51 @@
|
||||
variable "resource_group_location" {
|
||||
type = string
|
||||
default = "eastus"
|
||||
description = "Location for all resources."
|
||||
}
|
||||
|
||||
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 "publisher_email" {
|
||||
default = "test@contoso.com"
|
||||
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" {
|
||||
default = "publisher"
|
||||
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