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-managed-applications #395

Open
wants to merge 1 commit 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
Original file line number Diff line number Diff line change
@@ -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
35 changes: 35 additions & 0 deletions quickstart/101-azure-resource-manager-managed-applications/main.tf
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
@@ -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
}
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,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 = ""
}
Loading