-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #103 from Lakshan-Banneheke/api-policy-fragment
Api policy fragment modules
- Loading branch information
Showing
9 changed files
with
290 additions
and
0 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
modules/azurerm/API-Management-Policy-Fragment-With-Failover/api_policy_fragment_primary.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). | ||
* | ||
* WSO2 LLC. licenses this file to you under the Apache License, | ||
* Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
resource "azurerm_api_management_policy_fragment" "api_policy_fragment_primary" { | ||
api_management_id = var.primary_api_management_id | ||
name = join("-", [var.abbreviation, var.name]) | ||
format = var.file_format | ||
value = templatefile(var.xml_template_file_path, var.xml_template_vars) | ||
} |
24 changes: 24 additions & 0 deletions
24
...les/azurerm/API-Management-Policy-Fragment-With-Failover/api_policy_fragment_secondary.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). | ||
* | ||
* WSO2 LLC. licenses this file to you under the Apache License, | ||
* Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
resource "azurerm_api_management_policy_fragment" "api_policy_fragment_secondary" { | ||
api_management_id = var.secondary_api_management_id | ||
name = join("-", [var.abbreviation, var.name]) | ||
format = var.file_format | ||
value = templatefile(var.xml_template_file_path, var.xml_template_vars) | ||
} |
32 changes: 32 additions & 0 deletions
32
modules/azurerm/API-Management-Policy-Fragment-With-Failover/outputs.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). | ||
* | ||
* WSO2 LLC. licenses this file to you under the Apache License, | ||
* Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
output "primary_policy_fragment_id" { | ||
value = azurerm_api_management_policy_fragment.api_policy_fragment_primary.id | ||
depends_on = [azurerm_api_management_policy_fragment.api_policy_fragment_primary] | ||
} | ||
|
||
output "secondary_policy_fragment_id" { | ||
value = azurerm_api_management_policy_fragment.api_policy_fragment_secondary.id | ||
depends_on = [azurerm_api_management_policy_fragment.api_policy_fragment_secondary] | ||
} | ||
|
||
output "policy_fragment_name" { | ||
value = azurerm_api_management_policy_fragment.api_policy_fragment_primary.name | ||
depends_on = [azurerm_api_management_policy_fragment.api_policy_fragment_primary] | ||
} |
55 changes: 55 additions & 0 deletions
55
modules/azurerm/API-Management-Policy-Fragment-With-Failover/variables.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). | ||
* | ||
* WSO2 LLC. licenses this file to you under the Apache License, | ||
* Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
variable "abbreviation" { | ||
description = "Abbreviation for the API Policy Fragment" | ||
type = string | ||
default = "api-policy-fragment" | ||
} | ||
|
||
variable "name" { | ||
description = "Name of the API Policy Fragment" | ||
type = string | ||
} | ||
|
||
variable "primary_api_management_id" { | ||
description = "ID of the Primary API Management Service where the API Policy Fragment is to be created." | ||
type = string | ||
} | ||
|
||
variable "secondary_api_management_id" { | ||
description = "ID of the Secondary API Management Service where the API Policy Fragment is to be created." | ||
type = string | ||
} | ||
|
||
variable "file_format" { | ||
description = "Format of the API Policy Fragment" | ||
type = string | ||
default = "rawxml" | ||
} | ||
|
||
variable "xml_template_file_path" { | ||
description = "The path to the policy XML template file" | ||
type = string | ||
} | ||
|
||
variable "xml_template_vars" { | ||
description = "The variables to pass to the policy XML template" | ||
type = any | ||
default = {} | ||
} |
27 changes: 27 additions & 0 deletions
27
modules/azurerm/API-Management-Policy-Fragment-With-Failover/versions.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). | ||
* | ||
* WSO2 LLC. licenses this file to you under the Apache License, | ||
* Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
terraform { | ||
required_version = ">= 0.14.10" | ||
required_providers { | ||
azurerm = { | ||
source = "hashicorp/azurerm" | ||
version = ">= 3.80.0" | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
modules/azurerm/API-Management-Policy-Fragment/api_management_policy_fragment.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). | ||
* | ||
* WSO2 LLC. licenses this file to you under the Apache License, | ||
* Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
resource "azurerm_api_management_policy_fragment" "api_management_policy_fragment" { | ||
api_management_id = var.api_management_id | ||
name = join("-", [var.abbreviation, var.name]) | ||
format = var.file_format | ||
value = templatefile(var.xml_template_file_path, var.xml_template_vars) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). | ||
* | ||
* WSO2 LLC. licenses this file to you under the Apache License, | ||
* Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
output "id" { | ||
value = azurerm_api_management_policy_fragment.api_management_policy_fragment.id | ||
depends_on = [azurerm_api_management_policy_fragment.api_management_policy_fragment] | ||
} | ||
|
||
output "name" { | ||
value = azurerm_api_management_policy_fragment.api_management_policy_fragment.name | ||
depends_on = [azurerm_api_management_policy_fragment.api_management_policy_fragment] | ||
} |
50 changes: 50 additions & 0 deletions
50
modules/azurerm/API-Management-Policy-Fragment/variables.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). | ||
* | ||
* WSO2 LLC. licenses this file to you under the Apache License, | ||
* Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
variable "abbreviation" { | ||
description = "Abbreviation for the API Policy Fragment" | ||
type = string | ||
default = "api-policy-frag" | ||
} | ||
|
||
variable "name" { | ||
description = "Name of the API Policy Fragment" | ||
type = string | ||
} | ||
|
||
variable "api_management_id" { | ||
description = "ID of the API Management Service where the API Policy Fragment is to be created." | ||
type = string | ||
} | ||
|
||
variable "file_format" { | ||
description = "Format of the API Policy Fragment" | ||
type = string | ||
default = "xml" | ||
} | ||
|
||
variable "xml_template_file_path" { | ||
description = "The path to the policy XML template file" | ||
type = string | ||
} | ||
|
||
variable "xml_template_vars" { | ||
description = "The variables to pass to the policy XML template" | ||
type = any | ||
default = {} | ||
} |
27 changes: 27 additions & 0 deletions
27
modules/azurerm/API-Management-Policy-Fragment/versions.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). | ||
* | ||
* WSO2 LLC. licenses this file to you under the Apache License, | ||
* Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
terraform { | ||
required_version = ">= 0.14.10" | ||
required_providers { | ||
azurerm = { | ||
source = "hashicorp/azurerm" | ||
version = ">= 3.80.0" | ||
} | ||
} | ||
} |