Skip to content

Commit

Permalink
feat: Add variable to control APIM subscription header/query string n…
Browse files Browse the repository at this point in the history
…ame (#344)
  • Loading branch information
Krusty93 authored Aug 30, 2024
1 parent e64f39b commit 61c239b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions api_management_api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ No modules.
| <a name="input_revision"></a> [revision](#input\_revision) | n/a | `string` | `"1"` | no |
| <a name="input_revision_description"></a> [revision\_description](#input\_revision\_description) | n/a | `string` | `null` | no |
| <a name="input_service_url"></a> [service\_url](#input\_service\_url) | n/a | `string` | n/a | yes |
| <a name="input_subscription_key_names"></a> [subscription\_key\_names](#input\_subscription\_key\_names) | Override the default name of the header and query string containing the subscription key header | <pre>object({<br> header = string<br> query = string<br> })</pre> | `null` | no |
| <a name="input_subscription_required"></a> [subscription\_required](#input\_subscription\_required) | Should this API require a subscription key? | `bool` | `false` | no |
| <a name="input_version_set_id"></a> [version\_set\_id](#input\_version\_set\_id) | The ID of the Version Set which this API is associated with. | `string` | `null` | no |
| <a name="input_xml_content"></a> [xml\_content](#input\_xml\_content) | The XML Content for this Policy as a string | `string` | `null` | no |
Expand Down
7 changes: 7 additions & 0 deletions api_management_api/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ resource "azurerm_api_management_api" "this" {
content_value = var.content_value
}

dynamic "subscription_key_parameter_names" {
for_each = var.subscription_key_names == null ? [] : ["dummy"]
content {
header = var.subscription_key_names.header
query = var.subscription_key_names.query
}
}
}

resource "azurerm_api_management_api_policy" "this" {
Expand Down
9 changes: 9 additions & 0 deletions api_management_api/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,12 @@ variable "version_set_id" {
description = "The ID of the Version Set which this API is associated with."
default = null
}

variable "subscription_key_names" {
type = object({
header = string
query = string
})
description = "Override the default name of the header and query string containing the subscription key header"
default = null
}

0 comments on commit 61c239b

Please sign in to comment.