Skip to content

Commit e9352fd

Browse files
committed
updating documentation
1 parent 60f052b commit e9352fd

File tree

2 files changed

+128
-53
lines changed

2 files changed

+128
-53
lines changed

README.md

Lines changed: 127 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,42 @@
22

33
Azure Key Vault is a tool for securely storing and accessing secrets. A secret is anything that you want to tightly control access to, such as API keys, passwords, or certificates. A vault is a logical group of secrets.
44

5-
This Terraform Module creates a Key Vault also adds required access policies for AD users and groups. This also sends all logs to log analytic workspace and storage.
5+
This Terraform Module creates a Key Vault also adds required access policies for azure AD users, groups and azure AD service principals. This also enables private endpoint and sends all logs to log analytic workspace or storage.
6+
7+
## Resources Supported
8+
9+
* [Acess Polices for AD users, groups and SPN](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/key_vault_access_policy)
10+
* [Secrets](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/key_vault_secret)
11+
* [Certifiate Contacts](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/key_vault#contact)
12+
* [Private Endpoints](https://www.terraform.io/docs/providers/azurerm/r/private_endpoint.html)
13+
* [Private DNS zone for `privatelink` A records](https://www.terraform.io/docs/providers/azurerm/r/private_dns_zone.html)
14+
* [Azure Log Dignostics](https://www.terraform.io/docs/providers/azurerm/r/network_security_group.html)
615

716
## Module Usage
817

9-
```hcl
18+
```terraform
19+
# Azurerm Provider configuration
20+
provider "azurerm" {
21+
features {}
22+
}
23+
1024
module "key-vault" {
1125
source = "kumarvna/key-vault/azurerm"
12-
version = "2.1.0"
26+
version = "2.2.0"
1327
14-
# Resource Group and Key Vault pricing tier details
28+
# By default, this module will not create a resource group and expect to provide
29+
# a existing RG name to use an existing resource group. Location will be same as existing RG.
30+
# set the argument to `create_resource_group = true` to create new resrouce.
1531
resource_group_name = "rg-shared-westeurope-01"
1632
key_vault_name = "demo-project-shard"
1733
key_vault_sku_pricing_tier = "premium"
1834
1935
# Once `Purge Protection` has been Enabled it's not possible to Disable it
20-
# Deleting the Key Vault with `Purge Protection` enabled will schedule the Key Vault to be deleted
36+
# Deleting the Key Vault with `Purge Protection` enabled will schedule the Key Vault to be deleted
2137
# The default retention period is 90 days, possible values are from 7 to 90 days
2238
# use `soft_delete_retention_days` to set the retention period
2339
enable_purge_protection = false
24-
25-
# Adding Key vault logs to Azure monitoring and Log Analytics space
26-
# to enable key-vault logs, either one of log_analytics_workspace_id or storage_account_id required
27-
log_analytics_workspace_id = var.log_analytics_workspace_id
28-
storage_account_id = var.storage_account_id
40+
# soft_delete_retention_days = 90
2941
3042
# Access policies for users, you can provide list of Azure AD users and set permissions.
3143
# Make sure to use list of user principal names of Azure AD users.
@@ -38,24 +50,41 @@ module "key-vault" {
3850
storage_permissions = ["backup", "get", "list", "recover"]
3951
},
4052
41-
# Access policies for AD Groups, enable this feature to provide list of Azure AD groups and set permissions.
53+
# Access policies for AD Groups
54+
# enable this feature to provide list of Azure AD groups and set permissions.
4255
{
43-
azure_ad_group_names = ["ADGroupName1", "ADGroupName2"]
44-
secret_permissions = ["get", "list", "set"]
56+
azure_ad_group_names = ["ADGroupName1", "ADGroupName2"]
57+
key_permissions = ["get", "list"]
58+
secret_permissions = ["get", "list"]
59+
certificate_permissions = ["get", "import", "list"]
60+
storage_permissions = ["backup", "get", "list", "recover"]
4561
},
4662
63+
# Access policies for Azure AD Service Principlas
64+
# enable this feature to provide list of Azure AD SPN and set permissions.
65+
{
66+
azure_ad_service_principal_names = ["azure-ad-dev-sp1", "azure-ad-dev-sp2"]
67+
key_permissions = ["get", "list"]
68+
secret_permissions = ["get", "list"]
69+
certificate_permissions = ["get", "import", "list"]
70+
storage_permissions = ["backup", "get", "list", "recover"]
71+
}
4772
]
4873
4974
# Create a required Secrets as per your need.
50-
# When you Add `usernames` with empty password this module creates a strong random password
51-
# use .tfvars file to manage the secrets as variables to avoid security issues.
75+
# When you Add `usernames` with empty password this module creates a strong random password
76+
# use .tfvars file to manage the secrets as variables to avoid security issues.
5277
secrets = {
5378
"message" = "Hello, world!"
5479
"vmpass" = ""
5580
}
5681
57-
# Adding TAG's to your Azure resources (Required)
58-
# ProjectName and Env are already declared above, to use them here or create a varible.
82+
# (Optional) To enable Azure Monitoring for Azure Application Gateway
83+
# (Optional) Specify `storage_account_id` to save monitoring logs to storage.
84+
log_analytics_workspace_id = var.log_analytics_workspace_id
85+
#storage_account_id = var.storage_account_id
86+
87+
# Adding additional TAG's to your Azure resources
5988
tags = {
6089
ProjectName = "demo-project"
6190
Env = "dev"
@@ -75,7 +104,7 @@ Default action is set to `Allow` when no network rules matched. A `virtual_netwo
75104
```hcl
76105
module "key-vault" {
77106
source = "kumarvna/key-vault/azurerm"
78-
version = "2.1.0"
107+
version = "2.2.0"
79108
80109
# .... omitted
81110
@@ -123,54 +152,100 @@ When purge protection is on, a vault or an object in the deleted state cannot be
123152

124153
> The default retention period is 90 days for the soft-delete and the purge protection retention policy uses the same interval. Once set, the retention policy interval cannot be changed.
125154
126-
## Recommended naming and tagging conventions
155+
## Certificate contacts
127156

128-
Well-defined naming and metadata tagging conventions help to quickly locate and manage resources. These conventions also help associate cloud usage costs with business teams via chargeback and show back accounting mechanisms.
157+
Certificate contacts contain contact information to send notifications triggered by certificate lifetime events. The contacts information is shared by all the certificates in the key vault. A notification is sent to all the specified contacts for an event for any certificate in the key vault.
129158

130-
> ### Resource naming
159+
```terraform
160+
module "key-vault" {
161+
source = "kumarvna/key-vault/azurerm"
162+
version = "2.2.0"
131163
132-
An effective naming convention assembles resource names by using important resource information as parts of a resource's name. For example, using these [recommended naming conventions](https://docs.microsoft.com/en-us/azure/cloud-adoption-framework/ready/azure-best-practices/naming-and-tagging#example-names), a public IP resource for a production SharePoint workload is named like this: `pip-sharepoint-prod-westus-001`.
164+
# .... omitted
133165
134-
> ### Metadata tags
166+
# The contacts information is shared by all the certificates in the key vault.
167+
# A notification is sent to all the specified contacts for an event for any certificate in the key vault.
168+
# This field can only be set once user has `managecontacts` certificate permission.
169+
certificate_contacts = [
170+
{
171+
172+
name = "User1"
173+
phone = "1010101010"
174+
},
175+
{
176+
177+
name = "User2"
178+
phone = "2020202020"
179+
},
180+
]
135181
136-
When applying metadata tags to the cloud resources, you can include information about those assets that couldn't be included in the resource name. You can use that information to perform more sophisticated filtering and reporting on resources. This information can be used by IT or business teams to find resources or generate reports about resource usage and billing.
182+
# ....omitted
137183
138-
The following list provides the recommended common tags that capture important context and information about resources. Use this list as a starting point to establish your tagging conventions.
184+
}
185+
```
139186

140-
Tag Name|Description|Key|Example Value|Required?
141-
--------|-----------|---|-------------|---------|
142-
Project Name|Name of the Project for the infra is created. This is mandatory to create a resource names.|ProjectName|{Project name}|Yes
143-
Application Name|Name of the application, service, or workload the resource is associated with.|ApplicationName|{app name}|Yes
144-
Approver|Name Person responsible for approving costs related to this resource.|Approver|{email}|Yes
145-
Business Unit|Top-level division of your company that owns the subscription or workload the resource belongs to. In smaller organizations, this may represent a single corporate or shared top-level organizational element.|BusinessUnit|FINANCE, MARKETING,{Product Name},CORP,SHARED|Yes
146-
Cost Center|Accounting cost center associated with this resource.|CostCenter|{number}|Yes
147-
Disaster Recovery|Business criticality of this application, workload, or service.|DR|Mission Critical, Critical, Essential|Yes
148-
Environment|Deployment environment of this application, workload, or service.|Env|Prod, Dev, QA, Stage, Test|Yes
149-
Owner Name|Owner of the application, workload, or service.|Owner|{email}|Yes
150-
Requester Name|User that requested the creation of this application.|Requestor| {email}|Yes
151-
Service Class|Service Level Agreement level of this application, workload, or service.|ServiceClass|Dev, Bronze, Silver, Gold|Yes
152-
Start Date of the project|Date when this application, workload, or service was first deployed.|StartDate|{date}|No
153-
End Date of the Project|Date when this application, workload, or service is planned to be retired.|EndDate|{date}|No
187+
## Private Endpoint - Integrate Key Vault with Azure Private Link
154188

155-
> This module allows you to manage the above metadata tags directly or as a variable using `variables.tf`. All Azure resources which support tagging can be tagged by specifying key-values in argument `tags`. Tag `ResourceName` is added automatically to all resources.
189+
Azure Private Endpoint is a network interface that connects you privately and securely to a service powered by Azure Private Link. Private Endpoint uses a private IP address from your VNet, effectively bringing the service into your VNet.
156190

157-
```hcl
191+
With Private Link, Microsoft offering the ability to associate a logical server to a specific private IP address (also known as private endpoint) within the VNet. Clients can connect to the Private endpoint from the same VNet, peered VNet in same region, or via VNet-to-VNet connection across regions. Additionally, clients can connect from on-premises using ExpressRoute, private peering, or VPN tunneling.
192+
193+
By default, this feature not enabled on this module. To create private link with private endpoints set the variable `enable_private_endpoint` to `true` and provide `virtual_network_name`, `private_subnet_address_prefix` with a valid values. You can also use the existing private DNS zone to create DNS records. To use this feature, set the `existing_private_dns_zone` with a valid existing private DNS zone name.
194+
195+
```terraform
158196
module "key-vault" {
159197
source = "kumarvna/key-vault/azurerm"
160-
version = "2.1.0"
198+
version = "2.2.0"
161199
162-
# ... omitted
200+
# .... omitted
163201
164-
tags = {
165-
ProjectName = "demo-project"
166-
Env = "dev"
167-
168-
BusinessUnit = "CORP"
169-
ServiceClass = "Gold"
170-
}
171-
}
202+
# Creating Private Endpoint requires, VNet name and address prefix to create a subnet
203+
# By default this will create a `privatelink.vaultcore.azure.net` DNS zone.
204+
# To use existing private DNS zone specify `existing_private_dns_zone` with valid zone name
205+
enable_private_endpoint = true
206+
virtual_network_name = "vnet-shared-hub-westeurope-001"
207+
private_subnet_address_prefix = ["10.1.5.0/27"]
208+
# existing_private_dns_zone = "demo.example.com"
209+
210+
# ....omitted
211+
212+
}
172213
```
173214

215+
If you want to use eixsting VNet and Subnet to create a private endpoints, set a variable `enable_private_endpoint` to `true` and provide `existing_vnet_id`, `existing_subnet_id` with a valid resource ids. You can also use the existing private DNS zone to create DNS records. To use this feature, set the `existing_private_dns_zone` with a valid existing private DNS zone name.
216+
217+
```terraform
218+
module "key-vault" {
219+
source = "kumarvna/key-vault/azurerm"
220+
version = "2.2.0"
221+
222+
# .... omitted
223+
224+
# Creating Private Endpoint requires, VNet name and address prefix to create a subnet
225+
# By default this will create a `privatelink.vaultcore.azure.net` DNS zone.
226+
# To use existing private DNS zone specify `existing_private_dns_zone` with valid zone name
227+
enable_private_endpoint = true
228+
existing_vnet_id = data.azurerm_virtual_network.example.id
229+
existing_subnet_id = data.azurerm_subnet.example.id
230+
# existing_private_dns_zone = "demo.example.com"
231+
232+
# ....omitted
233+
234+
}
235+
```
236+
237+
For more details: [Integrate Key Vault with Azure Private Link](https://docs.microsoft.com/en-us/azure/key-vault/general/private-link-service?tabs=portal)
238+
239+
## Recommended naming and tagging conventions
240+
241+
Applying tags to your Azure resources, resource groups, and subscriptions to logically organize them into a taxonomy. Each tag consists of a name and a value pair. For example, you can apply the name `Environment` and the value `Production` to all the resources in production.
242+
For recommendations on how to implement a tagging strategy, see Resource naming and tagging decision guide.
243+
244+
>**Important** :
245+
Tag names are case-insensitive for operations. A tag with a tag name, regardless of the casing, is updated or retrieved. However, the resource provider might keep the casing you provide for the tag name. You'll see that casing in cost reports. **Tag values are case-sensitive.**
246+
247+
An effective naming convention assembles resource names by using important resource information as parts of a resource's name. For example, using these [recommended naming conventions](https://docs.microsoft.com/en-us/azure/cloud-adoption-framework/ready/azure-best-practices/naming-and-tagging#example-names), a public IP resource for a production SharePoint workload is named like this: `pip-sharepoint-prod-westus-001`.
248+
174249
## Requirements
175250

176251
Name | Version
@@ -184,7 +259,7 @@ azurerm | >= 2.59.0
184259
|------|---------|
185260
azurerm | >= 2.59.0
186261
random | >= 3.1.0
187-
azuread | >= 1.4.0
262+
azuread | >= 2.7.0
188263

189264
## Inputs
190265

examples/keyvault_private_end_point_with_existing_VNet_Subnet/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Terraform Module to create a Key Vault also adds required access policies for azure AD users, groups and azure AD service principals. This module also creates private endpoint and sends all logs to log analytic workspace or storage.
44

5-
## Module Usage to enable privaite endpoint
5+
## Module Usage to enable privaite endpoint using existing VNet and Subnet
66

77
```hcl
88
# Azurerm Provider configuration

0 commit comments

Comments
 (0)