Skip to content

Commit e3c66ca

Browse files
committed
Sort all variables, outputs, arguments and blocks in resource block.
Adjust code file's style. Add `numeric = false` for `random_string.name` in `201-mysql-fs-db` module as the name is used as `azurerm_mysql_flexible_server.default`'s `administrator_login` and the login name doesn't support a name start with number. Add minimum constraints for `random_password.password` in `201-mysql-fs-db` module as the password required a minimum complexity.
1 parent 65cb9c7 commit e3c66ca

File tree

17 files changed

+113
-122
lines changed

17 files changed

+113
-122
lines changed

quickstart/101-attestation-provider/main.tf

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@ resource "random_pet" "rg_name" {
33
}
44

55
resource "azurerm_resource_group" "rg" {
6-
name = random_pet.rg_name.id
76
location = var.resource_group_location
7+
name = random_pet.rg_name.id
88
}
99

1010
resource "azurerm_attestation_provider" "corp_attestation" {
11-
name = var.attestation_provider_name
12-
resource_group_name = azurerm_resource_group.rg.name
13-
location = azurerm_resource_group.rg.location
14-
11+
location = azurerm_resource_group.rg.location
12+
name = var.attestation_provider_name
13+
resource_group_name = azurerm_resource_group.rg.name
1514
policy_signing_certificate_data = file(var.policy_file)
1615
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
output "resource_group_name" {
22
value = azurerm_resource_group.rg.name
3-
}
3+
}

quickstart/101-attestation-provider/providers.tf

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ terraform {
66
source = "hashicorp/azurerm"
77
version = "~>2.0"
88
}
9-
109
random = {
1110
source = "hashicorp/random"
1211
version = "~>3.0"
@@ -16,4 +15,4 @@ terraform {
1615

1716
provider "azurerm" {
1817
features {}
19-
}
18+
}
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
variable "resource_group_name_prefix" {
2-
default = "rg"
3-
description = "Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription."
1+
variable "attestation_provider_name" {
2+
default = "attestationprovider007"
3+
}
4+
5+
variable "policy_file" {
6+
default = "~/.certs/cert.pem"
47
}
58

69
variable "resource_group_location" {
710
default = "eastus"
811
description = "Location of the resource group."
912
}
1013

11-
variable "policy_file" {
12-
default = "~/.certs/cert.pem"
13-
}
14-
15-
variable "attestation_provider_name" {
16-
default = "attestationprovider007"
14+
variable "resource_group_name_prefix" {
15+
default = "rg"
16+
description = "Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription."
1717
}

quickstart/101-resource-group/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ resource "random_pet" "rg_name" {
33
}
44

55
resource "azurerm_resource_group" "rg" {
6-
name = random_pet.rg_name.id
76
location = var.resource_group_location
8-
}
7+
name = random_pet.rg_name.id
8+
}

quickstart/101-resource-group/providers.tf

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ terraform {
66
source = "hashicorp/azurerm"
77
version = "~>2.0"
88
}
9-
109
random = {
1110
source = "hashicorp/random"
1211
version = "~>3.0"
@@ -16,4 +15,4 @@ terraform {
1615

1716
provider "azurerm" {
1817
features {}
19-
}
18+
}
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
variable "resource_group_name_prefix" {
2-
default = "rg"
3-
description = "Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription."
4-
}
5-
61
variable "resource_group_location" {
72
default = "eastus"
83
description = "Location of the resource group."
94
}
5+
6+
variable "resource_group_name_prefix" {
7+
default = "rg"
8+
description = "Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription."
9+
}

quickstart/201-k8s-cluster-with-tf-and-aks/main.tf

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,66 +4,62 @@ resource "random_pet" "rg_name" {
44
}
55

66
resource "azurerm_resource_group" "rg" {
7-
name = random_pet.rg_name.id
87
location = var.resource_group_location
8+
name = random_pet.rg_name.id
99
}
1010

1111
resource "random_id" "log_analytics_workspace_name_suffix" {
1212
byte_length = 8
1313
}
1414

1515
resource "azurerm_log_analytics_workspace" "test" {
16+
location = var.log_analytics_workspace_location
1617
# The WorkSpace name has to be unique across the whole of azure, not just the current subscription/tenant.
1718
name = "${var.log_analytics_workspace_name}-${random_id.log_analytics_workspace_name_suffix.dec}"
18-
location = var.log_analytics_workspace_location
1919
resource_group_name = azurerm_resource_group.rg.name
2020
sku = var.log_analytics_workspace_sku
2121
}
2222

2323
resource "azurerm_log_analytics_solution" "test" {
24-
solution_name = "ContainerInsights"
2524
location = azurerm_log_analytics_workspace.test.location
2625
resource_group_name = azurerm_resource_group.rg.name
27-
workspace_resource_id = azurerm_log_analytics_workspace.test.id
26+
solution_name = "ContainerInsights"
2827
workspace_name = azurerm_log_analytics_workspace.test.name
28+
workspace_resource_id = azurerm_log_analytics_workspace.test.id
2929

3030
plan {
31-
publisher = "Microsoft"
3231
product = "OMSGallery/ContainerInsights"
32+
publisher = "Microsoft"
3333
}
3434
}
3535

3636
resource "azurerm_kubernetes_cluster" "k8s" {
37-
name = var.cluster_name
3837
location = azurerm_resource_group.rg.location
38+
name = var.cluster_name
3939
resource_group_name = azurerm_resource_group.rg.name
4040
dns_prefix = var.dns_prefix
41+
tags = {
42+
Environment = "Development"
43+
}
4144

45+
default_node_pool {
46+
name = "agentpool"
47+
vm_size = "Standard_D2_v2"
48+
node_count = var.agent_count
49+
}
4250
linux_profile {
4351
admin_username = "ubuntu"
4452

4553
ssh_key {
4654
key_data = file(var.ssh_public_key)
4755
}
4856
}
49-
50-
default_node_pool {
51-
name = "agentpool"
52-
node_count = var.agent_count
53-
vm_size = "Standard_D2_v2"
57+
network_profile {
58+
network_plugin = "kubenet"
59+
load_balancer_sku = "standard"
5460
}
55-
5661
service_principal {
5762
client_id = var.aks_service_principal_app_id
5863
client_secret = var.aks_service_principal_client_secret
5964
}
60-
61-
network_profile {
62-
load_balancer_sku = "standard"
63-
network_plugin = "kubenet"
64-
}
65-
66-
tags = {
67-
Environment = "Development"
68-
}
6965
}
Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
output "resource_group_name" {
2-
value = azurerm_resource_group.rg.name
1+
output "client_certificate" {
2+
value = azurerm_kubernetes_cluster.k8s.kube_config[0].client_certificate
3+
sensitive = true
34
}
45

56
output "client_key" {
67
value = azurerm_kubernetes_cluster.k8s.kube_config[0].client_key
78
sensitive = true
89
}
910

10-
output "client_certificate" {
11-
value = azurerm_kubernetes_cluster.k8s.kube_config[0].client_certificate
11+
output "cluster_ca_certificate" {
12+
value = azurerm_kubernetes_cluster.k8s.kube_config[0].cluster_ca_certificate
1213
sensitive = true
1314
}
1415

15-
output "cluster_ca_certificate" {
16-
value = azurerm_kubernetes_cluster.k8s.kube_config[0].cluster_ca_certificate
16+
output "cluster_password" {
17+
value = azurerm_kubernetes_cluster.k8s.kube_config[0].password
1718
sensitive = true
1819
}
1920

@@ -22,8 +23,8 @@ output "cluster_username" {
2223
sensitive = true
2324
}
2425

25-
output "cluster_password" {
26-
value = azurerm_kubernetes_cluster.k8s.kube_config[0].password
26+
output "host" {
27+
value = azurerm_kubernetes_cluster.k8s.kube_config[0].host
2728
sensitive = true
2829
}
2930

@@ -32,8 +33,6 @@ output "kube_config" {
3233
sensitive = true
3334
}
3435

35-
output "host" {
36-
value = azurerm_kubernetes_cluster.k8s.kube_config[0].host
37-
sensitive = true
38-
}
39-
36+
output "resource_group_name" {
37+
value = azurerm_resource_group.rg.name
38+
}

quickstart/201-k8s-cluster-with-tf-and-aks/providers.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ terraform {
66
source = "hashicorp/azurerm"
77
version = "~>3.0"
88
}
9-
109
random = {
1110
source = "hashicorp/random"
1211
version = "~>3.0"

0 commit comments

Comments
 (0)