Skip to content

Commit 8b9b660

Browse files
authored
Add api_management_api data module (#28)
1 parent b536e2e commit 8b9b660

File tree

3 files changed

+71
-0
lines changed

3 files changed

+71
-0
lines changed

api_management_api/main.tf

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
terraform {
2+
required_version = "~> 1.3"
3+
4+
required_providers {
5+
azurerm = {
6+
source = "hashicorp/azurerm"
7+
version = "=3.40.0"
8+
}
9+
}
10+
backend "azurerm" {}
11+
}
12+
13+
provider "azurerm" {
14+
features {}
15+
}
16+
17+
data "azurerm_subscription" "current" {
18+
}
19+
20+
data "azurerm_api_management_api" "api" {
21+
name = var.name
22+
api_management_name = var.api_management_name
23+
resource_group_name = var.resource_group_name
24+
revision = var.api_revision
25+
}
26+
27+
data "azuread_application" "app_registration" {
28+
count = var.app_registration_name != null ? 1 : 0
29+
display_name = var.app_registration_name
30+
}

api_management_api/outputs.tf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
output "resource_group_name" {
2+
value = var.resource_group_name
3+
}
4+
5+
output "api_management_name" {
6+
value = var.api_management_name
7+
}
8+
9+
output "id" {
10+
value = data.azurerm_api_management_api.api.id
11+
}
12+
13+
output "client_id" {
14+
value = var.app_registration_name != null ? data.azuread_application.app_registration[0].client_id : null
15+
}

api_management_api/variables.tf

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
variable "name" {
2+
type = string
3+
description = "API name"
4+
}
5+
6+
variable "api_management_name" {
7+
type = string
8+
description = "API management name"
9+
}
10+
11+
variable "resource_group_name" {
12+
type = string
13+
description = "name of the Resource group where APIM_Management is located"
14+
}
15+
16+
variable "api_revision" {
17+
type = string
18+
description = "revision of the API"
19+
default = "1"
20+
}
21+
22+
variable "app_registration_name" {
23+
type = string
24+
description = "app registration name, that is responsible for authorizing the API"
25+
default = null
26+
}

0 commit comments

Comments
 (0)