Skip to content

Commit

Permalink
Merge pull request #103 from Lakshan-Banneheke/api-policy-fragment
Browse files Browse the repository at this point in the history
Api policy fragment modules
  • Loading branch information
Lakshan-Banneheke authored Sep 10, 2024
2 parents 515c775 + 8cd0a29 commit 1b05c60
Show file tree
Hide file tree
Showing 9 changed files with 290 additions and 0 deletions.
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)
}
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)
}
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]
}
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 = {}
}
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"
}
}
}
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)
}
27 changes: 27 additions & 0 deletions modules/azurerm/API-Management-Policy-Fragment/outputs.tf
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 modules/azurerm/API-Management-Policy-Fragment/variables.tf
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 modules/azurerm/API-Management-Policy-Fragment/versions.tf
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"
}
}
}

0 comments on commit 1b05c60

Please sign in to comment.