Skip to content
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
6 changes: 4 additions & 2 deletions quickstart/101-azure-api-management-create-with-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,7 @@ This template deploys an Azure API Management service, containing an API (based
| `resource_group_location` | Location of the resource group. | eastus |
| `open_api_spec_content_format` | The format of the content from which the API Definition should be imported. Possible values are: openapi, openapi+json, openapi+json-link, openapi-link, swagger-json, swagger-link-json, wadl-link-json, wadl-xml, wsdl and wsdl-link. | swagger-link-json |
| `open_api_spec_content_value` | The Content from which the API Definition should be imported. When a content_format of *-link-* is specified this must be a URL, otherwise this must be defined inline. | http://conferenceapi.azurewebsites.net/?format=json |

## Example
| `publisher_email` | Email address of the owner of the service. | [email protected] |
| `publisher_name` | Name of the owner of the service. | publisher |
| `sku_name` | Pricing tier of this API Management service. Must be one of the following values: Basic, BasicV2, Consumption, Developer, Premium, PremiumV2, Standard, StandardV2 | BasicV2 |
| `sku_count` | Instance size of this API Management service. | 1 |
19 changes: 3 additions & 16 deletions quickstart/101-azure-api-management-create-with-api/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,9 @@ resource "azurerm_api_management" "apim_service" {
name = "${random_string.apim_service_name.result}-apim-service"
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name
publisher_name = "Example Publisher"
publisher_email = "[email protected]"
sku_name = "Developer_1"
tags = {
Environment = "Example"
}
policy {
xml_content = <<XML
<policies>
<inbound />
<backend />
<outbound />
<on-error />
</policies>
XML
}
publisher_email = var.publisher_email
publisher_name = var.publisher_name
sku_name = "${var.sku_name}_${var.sku_count}"
}

resource "random_string" "api_name" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~>3.0"
version = "~>4.0"
}
random = {
source = "hashicorp/random"
Expand Down
41 changes: 41 additions & 0 deletions quickstart/101-azure-api-management-create-with-api/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,44 @@ variable "open_api_spec_content_value" {
default = "https://petstore3.swagger.io/api/v3/openapi.json"
description = "The Content from which the API Definition should be imported. When a content_format of *-link-* is specified this must be a URL, otherwise this must be defined inline."
}


variable "publisher_email" {
default = "[email protected]"
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_name" {
description = "The pricing tier of this API Management service"
default = "BasicV2"
type = string
validation {
condition = contains(["Basic", "BasicV2", "Consumption", "Developer", "Premium", "PremiumV2", "Standard", "StandardV2"], var.sku_name)
error_message = "The sku must be one of the following: Basic, BasicV2, Consumption, Developer, Premium, PremiumV2, Standard, StandardV2."
}
}

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."
}
}
2 changes: 1 addition & 1 deletion quickstart/101-azure-api-management-create/providers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~>3.0"
version = "~>4.0"
}
random = {
source = "hashicorp/random"
Expand Down
Loading