From ec4661907c2912017ecafb7ba9f5d6c4bbf51bda Mon Sep 17 00:00:00 2001 From: githubofkrishnadhas Date: Wed, 31 Jul 2024 02:50:27 +0530 Subject: [PATCH 1/4] updated gitignore to remove main readme and hideenfolder readmes DEVOPS-270 --- .gitignore | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitignore b/.gitignore index 62e65c1..9f1932d 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,8 @@ override.tf.json terraform.rc # Ignore hcl file **/*.hcl + +# Ignore terraform docs generated readme +.git\README.md +.github\README.md +README.md \ No newline at end of file From 6184e3a9cb0c44972cf8397426dd28d2a4fcff30 Mon Sep 17 00:00:00 2001 From: githubofkrishnadhas Date: Wed, 31 Jul 2024 02:50:45 +0530 Subject: [PATCH 2/4] DEVOPS-270 updated terraform-docs conf file --- .terraform-docs.yml | 70 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 .terraform-docs.yml diff --git a/.terraform-docs.yml b/.terraform-docs.yml new file mode 100644 index 0000000..18242f9 --- /dev/null +++ b/.terraform-docs.yml @@ -0,0 +1,70 @@ +formatter: "markdown table" # this is required +version: "0.18" +header-from: main.tf +footer-from: "" +recursive: + enabled: true + path: "." + # - "api-management" +recursive-include-main: false +# enabled: false +sections: + hide: [] + show: [] + hide-all: false # deprecated in v0.13.0, removed in v0.15.0 + show-all: true # deprecated in v0.13.0, removed in v0.15.0 +content: |- + {{ .Requirements }} + ## Usage + Basic usage of this module is as follows: + ```hcl + module "example" { + {{"\t"}} source = "" + {{- if .Module.RequiredInputs }} + {{"\n\t"}} # Required variables + {{- range .Module.RequiredInputs }} + {{"\t"}} {{ .Name }} = {{ .GetValue }} + {{- end }} + {{- end }} + {{- if .Module.OptionalInputs }} + {{"\n\t"}} # Optional variables + {{- range .Module.OptionalInputs }} + {{"\t"}} {{ .Name }} = {{ .GetValue | printf "%s" }} + {{- end }} + {{- end }} + } + ```` + + {{ .Resources }} + + {{ .Inputs }} + + {{ .Outputs }} +output: + file: README.md + mode: inject + template: |- + + {{ .Content }} + +output-values: + enabled: false + from: "" +sort: + enabled: true + by: name +settings: + anchor: true + color: true + default: false + description: true + escape: false + hide-empty: false + html: false + indent: 2 + lockfile: true + read-comments: true + required: true + sensitive: true + type: true + pretty: true From 3bbd72745e34249980c4e5403fc37cc099903b62 Mon Sep 17 00:00:00 2001 From: githubofkrishnadhas Date: Wed, 31 Jul 2024 02:51:03 +0530 Subject: [PATCH 3/4] terraform docs workflow DEVOPS-270 --- .github/workflows/terraform-docs.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/terraform-docs.yml diff --git a/.github/workflows/terraform-docs.yml b/.github/workflows/terraform-docs.yml new file mode 100644 index 0000000..4126352 --- /dev/null +++ b/.github/workflows/terraform-docs.yml @@ -0,0 +1,27 @@ +name: Generate terraform docs +on: + pull_request: + types: + - closed + branches: + - main + +permissions: + contents: write + +jobs: + generate-terraform-docs: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.ref }} + + - name: Render terraform docs and push changes back to PR + uses: terraform-docs/gh-actions@main + with: + recursive: true + config-file: .terraform-docs.yml + output-file: README.md + output-method: inject + git-push: "true" From 094ff7ea3161da8a42a81adf42fe58a01a29abb1 Mon Sep 17 00:00:00 2001 From: githubofkrishnadhas Date: Wed, 31 Jul 2024 02:51:44 +0530 Subject: [PATCH 4/4] DEVOPS-255 apim tf module --- api-management/apim.tf | 14 +++++++++++ api-management/output.tf | 29 +++++++++++++++++++++++ api-management/variables.tf | 46 +++++++++++++++++++++++++++++++++++++ storage-account/output.tf | 7 ++++++ 4 files changed, 96 insertions(+) create mode 100644 api-management/apim.tf create mode 100644 api-management/output.tf create mode 100644 api-management/variables.tf diff --git a/api-management/apim.tf b/api-management/apim.tf new file mode 100644 index 0000000..44b1dbd --- /dev/null +++ b/api-management/apim.tf @@ -0,0 +1,14 @@ +resource "azurerm_resource_group" "rg" { + name = var.resource_group_name + location = var.location +} + +resource "azurerm_api_management" "apim" { + name = var.api_management_name + location = var.location + resource_group_name = azurerm_resource_group.rg.name + publisher_name = tostring(var.publisher_name) + publisher_email = tostring(var.publisher_email) + + sku_name = "${var.sku_name_part1}_${var.sku_name_part2}" +} \ No newline at end of file diff --git a/api-management/output.tf b/api-management/output.tf new file mode 100644 index 0000000..3e39fa8 --- /dev/null +++ b/api-management/output.tf @@ -0,0 +1,29 @@ +output "azure_resource_group_name" { + description = "Azure resource group name" + value = azurerm_resource_group.rg.name +} + +output "azure_api_management_name" { + description = "Azure API management name" + value = azurerm_api_management.apim.name +} + +output "azure_api_management_location" { + description = "Azure API management location" + value = azurerm_api_management.apim.location +} + +output "azure_api_management_publisher_name" { + description = "Azure API management" + value = azurerm_api_management.apim.publisher_name +} + +output "azure_api_management_publisher_emailids" { + description = "Azure API management publisher emails" + value = azurerm_api_management.apim.publisher_email +} + +output "azure_api_management_sku" { + description = "Azure API management SKU" + value = azurerm_api_management.apim.sku_name +} \ No newline at end of file diff --git a/api-management/variables.tf b/api-management/variables.tf new file mode 100644 index 0000000..01a6366 --- /dev/null +++ b/api-management/variables.tf @@ -0,0 +1,46 @@ +variable "resource_group_name" { + type = string + description = "Azure Storage Account Rg" +} + +variable "location" { + type = string + description = "Azure storage account location" +} + +variable "api_management_name" { + description = "Azure api management name" + type = string +} + +variable "publisher_name" { + description = "Publisher of API" + type = list(string) + validation { + condition = can(index(var.publisher_name, 0)) + error_message = "A value is required for Publisher name." + } +} + +variable "publisher_email" { + description = "Email ID of API publishers" + type = list(string) + validation { + condition = can(index(var.publisher_email, 0)) + error_message = "At least one Publisher email is required." + } +} + +variable "sku_name_part1" { + description = "SKU name of API management " + type = string + validation { + condition = contains(["Consumption","Developer","Basic","Standard", "Premium"], var.sku_name_part1) + error_message = "SKU name should be one among Consumption, Developer,Basic,Standard,Premium." + } +} + +variable "sku_name_part2" { + description = "Sku capacity part" + type = string +} \ No newline at end of file diff --git a/storage-account/output.tf b/storage-account/output.tf index 07f72c7..26b910d 100644 --- a/storage-account/output.tf +++ b/storage-account/output.tf @@ -1,27 +1,34 @@ output "azurerm_resource_group" { + description = "Azure resource group name" value = azurerm_resource_group.storage_rg.name } output "storage_account_name" { + description = "Azure storage account name" value = azurerm_storage_account.storage.name } output "storage_account_location" { + description = "Azure storage account location" value = azurerm_storage_account.storage.location } output "storage_account_delete_retention_policy" { + description = "Azure blob retention policy" value = azurerm_storage_account.storage.blob_properties[0].delete_retention_policy } output "storage_account_tier" { + description = "Azure storage account tier" value = azurerm_storage_account.storage.access_tier } output "storage_account_replication_type" { + description = "Azure storage account replication type" value = azurerm_storage_account.storage.account_replication_type } output "storage_account_tags" { + description = "Azure storage account tags" value = azurerm_storage_account.storage.tags } \ No newline at end of file