diff --git a/quickstart/101-azure-resource-manager-managed-applications/README.md b/quickstart/101-azure-resource-manager-managed-applications/README.md new file mode 100644 index 000000000..29c1e3c96 --- /dev/null +++ b/quickstart/101-azure-resource-manager-managed-applications/README.md @@ -0,0 +1,27 @@ +# Azure Managed Application Definition +This template deploys an Azure Managed Application Definition. + +## 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_managed_application_definition](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/managed_application_definition) + +## 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 | +| `managed_application_definition_name` | Name of the Managed Application Definition resource. The value will be randomly generated if blank. | "" | +| `managed_application_definition_lock_level` | The Managed Application Lock Level. Possible values are `CanNotDelete` and `ReadOnly`. | CanNotDelete | +| `managed_application_definition_display_name` | The Managed Application Definition display name. | "" | +| `managed_application_definition_description` | The Managed Application Definition description. | "" | +| `managed_application_definition_package_file_uri` | The Managed Application Definition package file URI. | "" | +| `managed_application_definition_service_principal_id` | The Managed Application Definition service principal ID. | "" | +| `managed_application_definition_role_definition_id` | The Managed Application Definition role definition ID. | "" | +| `managed_application_definition_create_ui_definition` | The Managed Application Definition create UI definition. | "" | +| `managed_application_definition_main_template` | The Managed Application Definition main template. | "" | + +## Example \ No newline at end of file diff --git a/quickstart/101-azure-resource-manager-managed-applications/main.tf b/quickstart/101-azure-resource-manager-managed-applications/main.tf new file mode 100644 index 000000000..d69edeeaf --- /dev/null +++ b/quickstart/101-azure-resource-manager-managed-applications/main.tf @@ -0,0 +1,35 @@ +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" "azurerm_managed_application_definition_name" { + length = 13 + lower = true + numeric = false + special = false + upper = false +} + +resource "azurerm_managed_application_definition" "example" { + name = coalesce(var.managed_application_definition_name, "mad-${random_string.azurerm_managed_application_definition_name.result}") + resource_group_name = azurerm_resource_group.rg.name + location = azurerm_resource_group.rg.location + lock_level = var.managed_application_definition_lock_level + display_name = var.managed_application_definition_display_name + description = var.managed_application_definition_description + package_file_uri = var.managed_application_definition_package_file_uri + + authorization { + service_principal_id = var.managed_application_definition_service_principal_id + role_definition_id = var.managed_application_definition_role_definition_id + } + + create_ui_definition = var.managed_application_definition_create_ui_definition + + main_template = var.managed_application_definition_main_template +} \ No newline at end of file diff --git a/quickstart/101-azure-resource-manager-managed-applications/outputs.tf b/quickstart/101-azure-resource-manager-managed-applications/outputs.tf new file mode 100644 index 000000000..cadd44c7f --- /dev/null +++ b/quickstart/101-azure-resource-manager-managed-applications/outputs.tf @@ -0,0 +1,39 @@ +output "resource_group_name" { + value = azurerm_resource_group.rg.name +} + +output "managed_application_definition_name" { + value = azurerm_managed_application_definition.example.name +} + +output "managed_application_definition_lock_level" { + value = azurerm_managed_application_definition.example.lock_level +} + +output "managed_application_definition_display_name" { + value = azurerm_managed_application_definition.example.display_name +} + +output "managed_application_definition_description" { + value = azurerm_managed_application_definition.example.description +} + +output "managed_application_definition_package_file_uri" { + value = azurerm_managed_application_definition.example.package_file_uri +} + +output "managed_application_definition_service_principal_id" { + value = azurerm_managed_application_definition.example.authorization[0].service_principal_id +} + +output "managed_application_definition_role_definition_id" { + value = azurerm_managed_application_definition.example.authorization[0].role_definition_id +} + +output "managed_application_definition_create_ui_definition" { + value = azurerm_managed_application_definition.example.create_ui_definition +} + +output "managed_application_definition_main_template" { + value = azurerm_managed_application_definition.example.main_template +} \ No newline at end of file diff --git a/quickstart/101-azure-resource-manager-managed-applications/providers.tf b/quickstart/101-azure-resource-manager-managed-applications/providers.tf new file mode 100644 index 000000000..058b68717 --- /dev/null +++ b/quickstart/101-azure-resource-manager-managed-applications/providers.tf @@ -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 {} +} \ No newline at end of file diff --git a/quickstart/101-azure-resource-manager-managed-applications/variables.tf b/quickstart/101-azure-resource-manager-managed-applications/variables.tf new file mode 100644 index 000000000..60d1d983c --- /dev/null +++ b/quickstart/101-azure-resource-manager-managed-applications/variables.tf @@ -0,0 +1,69 @@ +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 "managed_application_definition_name" { + type = string + description = "The name of the Managed Application Definition resource. The value will be randomly generated if blank." + default = "" +} + +variable "managed_application_definition_lock_level" { + type = string + default = "CanNotDelete" + validation { + condition = contains(["CanNotDelete", "ReadOnly"], var.managed_application_definition_lock_level) + error_message = "The lock level value must be one of the following: CanNotDelete, ReadOnly." + } + description = "The Managed Application Lock Level." +} + +variable "managed_application_definition_display_name" { + type = string + description = "The Managed Application Definition display name." + default = "" +} + +variable "managed_application_definition_description" { + type = string + description = "The Managed Application Definition description." + default = "" +} + +variable "managed_application_definition_package_file_uri" { + type = string + description = "The Managed Application Definition package file URI." + default = "" +} + +variable "managed_application_definition_service_principal_id" { + type = string + description = "The Managed Application Definition service principal ID." + default = "" +} + +variable "managed_application_definition_role_definition_id" { + type = string + description = "The Managed Application Definition role definition ID." + default = "" +} + +variable "managed_application_definition_create_ui_definition" { + type = string + description = "The Managed Application Definition create UI definition." + default = "" +} + +variable "managed_application_definition_main_template" { + type = string + description = "The Managed Application Definition main template." + default = "" +} \ No newline at end of file