Skip to content

Commit c869720

Browse files
Merge pull request #2 from devwithkrishna/feature/tf-module-for-api-mgmt
Feature/tf module for api mgmt
2 parents 3507741 + 094ff7e commit c869720

File tree

7 files changed

+198
-0
lines changed

7 files changed

+198
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Generate terraform docs
2+
on:
3+
pull_request:
4+
types:
5+
- closed
6+
branches:
7+
- main
8+
9+
permissions:
10+
contents: write
11+
12+
jobs:
13+
generate-terraform-docs:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
ref: ${{ github.event.pull_request.head.ref }}
19+
20+
- name: Render terraform docs and push changes back to PR
21+
uses: terraform-docs/gh-actions@main
22+
with:
23+
recursive: true
24+
config-file: .terraform-docs.yml
25+
output-file: README.md
26+
output-method: inject
27+
git-push: "true"

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,8 @@ override.tf.json
3434
terraform.rc
3535
# Ignore hcl file
3636
**/*.hcl
37+
38+
# Ignore terraform docs generated readme
39+
.git\README.md
40+
.github\README.md
41+
README.md

.terraform-docs.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
formatter: "markdown table" # this is required
2+
version: "0.18"
3+
header-from: main.tf
4+
footer-from: ""
5+
recursive:
6+
enabled: true
7+
path: "."
8+
# - "api-management"
9+
recursive-include-main: false
10+
# enabled: false
11+
sections:
12+
hide: []
13+
show: []
14+
hide-all: false # deprecated in v0.13.0, removed in v0.15.0
15+
show-all: true # deprecated in v0.13.0, removed in v0.15.0
16+
content: |-
17+
{{ .Requirements }}
18+
## Usage
19+
Basic usage of this module is as follows:
20+
```hcl
21+
module "example" {
22+
{{"\t"}} source = "<module-path>"
23+
{{- if .Module.RequiredInputs }}
24+
{{"\n\t"}} # Required variables
25+
{{- range .Module.RequiredInputs }}
26+
{{"\t"}} {{ .Name }} = {{ .GetValue }}
27+
{{- end }}
28+
{{- end }}
29+
{{- if .Module.OptionalInputs }}
30+
{{"\n\t"}} # Optional variables
31+
{{- range .Module.OptionalInputs }}
32+
{{"\t"}} {{ .Name }} = {{ .GetValue | printf "%s" }}
33+
{{- end }}
34+
{{- end }}
35+
}
36+
````
37+
38+
{{ .Resources }}
39+
40+
{{ .Inputs }}
41+
42+
{{ .Outputs }}
43+
output:
44+
file: README.md
45+
mode: inject
46+
template: |-
47+
<!-- BEGIN_AUTOMATED_TF_DOCS_BLOCK -->
48+
{{ .Content }}
49+
<!-- END_AUTOMATED_TF_DOCS_BLOCK -->
50+
output-values:
51+
enabled: false
52+
from: ""
53+
sort:
54+
enabled: true
55+
by: name
56+
settings:
57+
anchor: true
58+
color: true
59+
default: false
60+
description: true
61+
escape: false
62+
hide-empty: false
63+
html: false
64+
indent: 2
65+
lockfile: true
66+
read-comments: true
67+
required: true
68+
sensitive: true
69+
type: true
70+
pretty: true

api-management/apim.tf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
resource "azurerm_resource_group" "rg" {
2+
name = var.resource_group_name
3+
location = var.location
4+
}
5+
6+
resource "azurerm_api_management" "apim" {
7+
name = var.api_management_name
8+
location = var.location
9+
resource_group_name = azurerm_resource_group.rg.name
10+
publisher_name = tostring(var.publisher_name)
11+
publisher_email = tostring(var.publisher_email)
12+
13+
sku_name = "${var.sku_name_part1}_${var.sku_name_part2}"
14+
}

api-management/output.tf

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
output "azure_resource_group_name" {
2+
description = "Azure resource group name"
3+
value = azurerm_resource_group.rg.name
4+
}
5+
6+
output "azure_api_management_name" {
7+
description = "Azure API management name"
8+
value = azurerm_api_management.apim.name
9+
}
10+
11+
output "azure_api_management_location" {
12+
description = "Azure API management location"
13+
value = azurerm_api_management.apim.location
14+
}
15+
16+
output "azure_api_management_publisher_name" {
17+
description = "Azure API management"
18+
value = azurerm_api_management.apim.publisher_name
19+
}
20+
21+
output "azure_api_management_publisher_emailids" {
22+
description = "Azure API management publisher emails"
23+
value = azurerm_api_management.apim.publisher_email
24+
}
25+
26+
output "azure_api_management_sku" {
27+
description = "Azure API management SKU"
28+
value = azurerm_api_management.apim.sku_name
29+
}

api-management/variables.tf

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
variable "resource_group_name" {
2+
type = string
3+
description = "Azure Storage Account Rg"
4+
}
5+
6+
variable "location" {
7+
type = string
8+
description = "Azure storage account location"
9+
}
10+
11+
variable "api_management_name" {
12+
description = "Azure api management name"
13+
type = string
14+
}
15+
16+
variable "publisher_name" {
17+
description = "Publisher of API"
18+
type = list(string)
19+
validation {
20+
condition = can(index(var.publisher_name, 0))
21+
error_message = "A value is required for Publisher name."
22+
}
23+
}
24+
25+
variable "publisher_email" {
26+
description = "Email ID of API publishers"
27+
type = list(string)
28+
validation {
29+
condition = can(index(var.publisher_email, 0))
30+
error_message = "At least one Publisher email is required."
31+
}
32+
}
33+
34+
variable "sku_name_part1" {
35+
description = "SKU name of API management "
36+
type = string
37+
validation {
38+
condition = contains(["Consumption","Developer","Basic","Standard", "Premium"], var.sku_name_part1)
39+
error_message = "SKU name should be one among Consumption, Developer,Basic,Standard,Premium."
40+
}
41+
}
42+
43+
variable "sku_name_part2" {
44+
description = "Sku capacity part"
45+
type = string
46+
}

storage-account/output.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,34 @@
11
output "azurerm_resource_group" {
2+
description = "Azure resource group name"
23
value = azurerm_resource_group.storage_rg.name
34
}
45

56
output "storage_account_name" {
7+
description = "Azure storage account name"
68
value = azurerm_storage_account.storage.name
79
}
810

911
output "storage_account_location" {
12+
description = "Azure storage account location"
1013
value = azurerm_storage_account.storage.location
1114
}
1215

1316
output "storage_account_delete_retention_policy" {
17+
description = "Azure blob retention policy"
1418
value = azurerm_storage_account.storage.blob_properties[0].delete_retention_policy
1519
}
1620

1721
output "storage_account_tier" {
22+
description = "Azure storage account tier"
1823
value = azurerm_storage_account.storage.access_tier
1924
}
2025

2126
output "storage_account_replication_type" {
27+
description = "Azure storage account replication type"
2228
value = azurerm_storage_account.storage.account_replication_type
2329
}
2430

2531
output "storage_account_tags" {
32+
description = "Azure storage account tags"
2633
value = azurerm_storage_account.storage.tags
2734
}

0 commit comments

Comments
 (0)