Skip to content

Commit 5481663

Browse files
authored
Merge pull request microsoft#109 from TomArcherMsft/UserStory1982922
User Story 1982922
2 parents 0016d17 + 03f800d commit 5481663

File tree

8 files changed

+212
-8
lines changed

8 files changed

+212
-8
lines changed

quickstart/101-attestation-provider/readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ This template deploys an [Attestation provider](/azure/attestation/overview) on
1212

1313
| Name | Description | Default |
1414
|-|-|-|
15-
| `resource_group_name_prefix` | (Optional) Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription.| rg |
16-
| `resource_group_location` | (Optional) Azure Region in which to deploy these resources.| eastus |
15+
| `resource_group_name_prefix` | Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription. | rg |
16+
| `resource_group_location` | Location of the resource group. | eastus |
1717
| `attestation_provider_name` | Name of the Attestation provider | attestationprovider007 |
1818

1919
## Example

quickstart/101-resource-group/readme.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ This template deploys an Azure resource group with a random name beginning with
99

1010
## Variables
1111

12-
| Name | Description |
13-
|-|-|
14-
| `resource_group_name_prefix` | (Optional) Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription. Value defaults to: rg|
15-
| `resource_group_location` | (Optional) Azure Region in which to deploy these resources. Value defaults to: eastus |
12+
| Name | Description | Default |
13+
|-|-|-|
14+
| `resource_group_name_prefix` | Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription. | rg |
15+
| `resource_group_location` | Location of the resource group. | eastus |
1616

1717
## Example
1818

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
resource "random_pet" "rg_name" {
2+
prefix = var.resource_group_name_prefix
3+
}
4+
5+
resource "azurerm_resource_group" "rg" {
6+
location = var.resource_group_location
7+
name = random_pet.rg_name.id
8+
}
9+
10+
# Create virtual network
11+
resource "azurerm_virtual_network" "my_terraform_network" {
12+
name = "myVnet"
13+
address_space = ["10.0.0.0/16"]
14+
location = azurerm_resource_group.rg.location
15+
resource_group_name = azurerm_resource_group.rg.name
16+
}
17+
18+
# Create subnet
19+
resource "azurerm_subnet" "my_terraform_subnet" {
20+
name = "mySubnet"
21+
resource_group_name = azurerm_resource_group.rg.name
22+
virtual_network_name = azurerm_virtual_network.my_terraform_network.name
23+
address_prefixes = ["10.0.1.0/24"]
24+
}
25+
26+
# Create public IPs
27+
resource "azurerm_public_ip" "my_terraform_public_ip" {
28+
name = "myPublicIP"
29+
location = azurerm_resource_group.rg.location
30+
resource_group_name = azurerm_resource_group.rg.name
31+
allocation_method = "Dynamic"
32+
}
33+
34+
# Create Network Security Group and rule
35+
resource "azurerm_network_security_group" "my_terraform_nsg" {
36+
name = "myNetworkSecurityGroup"
37+
location = azurerm_resource_group.rg.location
38+
resource_group_name = azurerm_resource_group.rg.name
39+
40+
security_rule {
41+
name = "SSH"
42+
priority = 1001
43+
direction = "Inbound"
44+
access = "Allow"
45+
protocol = "Tcp"
46+
source_port_range = "*"
47+
destination_port_range = "22"
48+
source_address_prefix = "*"
49+
destination_address_prefix = "*"
50+
}
51+
}
52+
53+
# Create network interface
54+
resource "azurerm_network_interface" "my_terraform_nic" {
55+
name = "myNIC"
56+
location = azurerm_resource_group.rg.location
57+
resource_group_name = azurerm_resource_group.rg.name
58+
59+
ip_configuration {
60+
name = "my_nic_configuration"
61+
subnet_id = azurerm_subnet.my_terraform_subnet.id
62+
private_ip_address_allocation = "Dynamic"
63+
public_ip_address_id = azurerm_public_ip.my_terraform_public_ip.id
64+
}
65+
}
66+
67+
# Connect the security group to the network interface
68+
resource "azurerm_network_interface_security_group_association" "example" {
69+
network_interface_id = azurerm_network_interface.my_terraform_nic.id
70+
network_security_group_id = azurerm_network_security_group.my_terraform_nsg.id
71+
}
72+
73+
# Generate random text for a unique storage account name
74+
resource "random_id" "random_id" {
75+
keepers = {
76+
# Generate a new ID only when a new resource group is defined
77+
resource_group = azurerm_resource_group.rg.name
78+
}
79+
80+
byte_length = 8
81+
}
82+
83+
# Create storage account for boot diagnostics
84+
resource "azurerm_storage_account" "my_storage_account" {
85+
name = "diag${random_id.random_id.hex}"
86+
location = azurerm_resource_group.rg.location
87+
resource_group_name = azurerm_resource_group.rg.name
88+
account_tier = "Standard"
89+
account_replication_type = "LRS"
90+
}
91+
92+
# Create (and display) an SSH key
93+
resource "tls_private_key" "example_ssh" {
94+
algorithm = "RSA"
95+
rsa_bits = 4096
96+
}
97+
98+
# Create virtual machine
99+
resource "azurerm_linux_virtual_machine" "my_terraform_vm" {
100+
name = "myVM"
101+
location = azurerm_resource_group.rg.location
102+
resource_group_name = azurerm_resource_group.rg.name
103+
network_interface_ids = [azurerm_network_interface.my_terraform_nic.id]
104+
size = "Standard_DS1_v2"
105+
106+
os_disk {
107+
name = "myOsDisk"
108+
caching = "ReadWrite"
109+
storage_account_type = "Premium_LRS"
110+
}
111+
112+
source_image_reference {
113+
publisher = "Canonical"
114+
offer = "UbuntuServer"
115+
sku = "18.04-LTS"
116+
version = "latest"
117+
}
118+
119+
computer_name = "myvm"
120+
admin_username = "azureuser"
121+
disable_password_authentication = true
122+
123+
admin_ssh_key {
124+
username = "azureuser"
125+
public_key = tls_private_key.example_ssh.public_key_openssh
126+
}
127+
128+
boot_diagnostics {
129+
storage_account_uri = azurerm_storage_account.my_storage_account.primary_blob_endpoint
130+
}
131+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
output "resource_group_name" {
2+
value = azurerm_resource_group.rg.name
3+
}
4+
5+
output "public_ip_address" {
6+
value = azurerm_linux_virtual_machine.my_terraform_vm.public_ip_address
7+
}
8+
9+
output "tls_private_key" {
10+
value = tls_private_key.example_ssh.private_key_pem
11+
sensitive = true
12+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
terraform {
2+
required_version = ">=0.12"
3+
4+
required_providers {
5+
azurerm = {
6+
source = "hashicorp/azurerm"
7+
version = "~>2.0"
8+
}
9+
random = {
10+
source = "hashicorp/random"
11+
version = "~>3.0"
12+
}
13+
tls = {
14+
source = "hashicorp/tls"
15+
version = "~>4.0"
16+
}
17+
}
18+
}
19+
20+
provider "azurerm" {
21+
features {}
22+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Azure resource group
2+
3+
This template deploys a Linux virtual machine (VM) with infrastructure that includes a virtual network, subnet, public IP address, and more.
4+
5+
## Terraform resource types
6+
7+
- [random_pet](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/pet)
8+
- [azurerm_resource_group](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group)
9+
10+
- [azurerm_virtual_network](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_network)
11+
- [azurerm_subnet](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/subnet)
12+
- [azurerm_public_ip](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/public_ip)
13+
- [azurerm_network_security_group](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/network_security_group)
14+
- [azurerm_network_interface](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/network_interface)
15+
- [azurerm_network_interface_security_group_association](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/network_interface_security_group_association)
16+
- [random_id](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/id)
17+
- [azurerm_storage_account](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_account)
18+
- [tls_private_key](https://registry.terraform.io/providers/hashicorp/tls/latest/docs/resources/private_key)
19+
- [azurerm_linux_virtual_machine](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/linux_virtual_machine)
20+
21+
## Variables
22+
23+
| Name | Description | Default |
24+
|-|-|
25+
| `resource_group_name_prefix` | Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription. | rg |
26+
| `resource_group_location` | Location of the resource group. | eastus |
27+
28+
## Example
29+
30+
To see how to run this example, see [Quickstart: Configure a Linux virtual machine in Azure using Terraform](https://docs.microsoft.com/azure/developer/terraform/create-linux-virtual-machine-with-infrastructure).
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
variable "resource_group_location" {
2+
default = "eastus"
3+
description = "Location of the resource group."
4+
}
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-mysql-fs-db/readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ This template deploys an [Azure MySQL Flexible Server Database](https://registry
1919

2020
| Name | Description | Default |
2121
|-|-|-|
22-
| `resource_group_name_prefix` | (Optional) Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription. Value defaults to: rg|
23-
| `resource_group_location` | (Optional) Azure Region in which to deploy these resources. Value defaults to: eastus |
22+
| `resource_group_name_prefix` | Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription. | rg |
23+
| `resource_group_location` | Location of the resource group. | eastus |
2424

2525
## Example
2626

0 commit comments

Comments
 (0)