Merge pull request #109 from TomArcherMsft/UserStory1982922
User Story 1982922
This commit is contained in:
commit
5481663a4b
@ -12,8 +12,8 @@ This template deploys an [Attestation provider](/azure/attestation/overview) on
|
||||
|
||||
| Name | Description | Default |
|
||||
|-|-|-|
|
||||
| `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 |
|
||||
| `resource_group_location` | (Optional) Azure Region in which to deploy these resources.| eastus |
|
||||
| `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 |
|
||||
| `resource_group_location` | Location of the resource group. | eastus |
|
||||
| `attestation_provider_name` | Name of the Attestation provider | attestationprovider007 |
|
||||
|
||||
## Example
|
||||
|
@ -9,10 +9,10 @@ This template deploys an Azure resource group with a random name beginning with
|
||||
|
||||
## Variables
|
||||
|
||||
| Name | Description |
|
||||
|-|-|
|
||||
| `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|
|
||||
| `resource_group_location` | (Optional) Azure Region in which to deploy these resources. Value defaults to: eastus |
|
||||
| Name | Description | Default |
|
||||
|-|-|-|
|
||||
| `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 |
|
||||
| `resource_group_location` | Location of the resource group. | eastus |
|
||||
|
||||
## Example
|
||||
|
||||
|
131
quickstart/101-vm-with-infrastructure/main.tf
Normal file
131
quickstart/101-vm-with-infrastructure/main.tf
Normal file
@ -0,0 +1,131 @@
|
||||
resource "random_pet" "rg_name" {
|
||||
prefix = var.resource_group_name_prefix
|
||||
}
|
||||
|
||||
resource "azurerm_resource_group" "rg" {
|
||||
location = var.resource_group_location
|
||||
name = random_pet.rg_name.id
|
||||
}
|
||||
|
||||
# Create virtual network
|
||||
resource "azurerm_virtual_network" "my_terraform_network" {
|
||||
name = "myVnet"
|
||||
address_space = ["10.0.0.0/16"]
|
||||
location = azurerm_resource_group.rg.location
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
}
|
||||
|
||||
# Create subnet
|
||||
resource "azurerm_subnet" "my_terraform_subnet" {
|
||||
name = "mySubnet"
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
virtual_network_name = azurerm_virtual_network.my_terraform_network.name
|
||||
address_prefixes = ["10.0.1.0/24"]
|
||||
}
|
||||
|
||||
# Create public IPs
|
||||
resource "azurerm_public_ip" "my_terraform_public_ip" {
|
||||
name = "myPublicIP"
|
||||
location = azurerm_resource_group.rg.location
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
allocation_method = "Dynamic"
|
||||
}
|
||||
|
||||
# Create Network Security Group and rule
|
||||
resource "azurerm_network_security_group" "my_terraform_nsg" {
|
||||
name = "myNetworkSecurityGroup"
|
||||
location = azurerm_resource_group.rg.location
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
|
||||
security_rule {
|
||||
name = "SSH"
|
||||
priority = 1001
|
||||
direction = "Inbound"
|
||||
access = "Allow"
|
||||
protocol = "Tcp"
|
||||
source_port_range = "*"
|
||||
destination_port_range = "22"
|
||||
source_address_prefix = "*"
|
||||
destination_address_prefix = "*"
|
||||
}
|
||||
}
|
||||
|
||||
# Create network interface
|
||||
resource "azurerm_network_interface" "my_terraform_nic" {
|
||||
name = "myNIC"
|
||||
location = azurerm_resource_group.rg.location
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
|
||||
ip_configuration {
|
||||
name = "my_nic_configuration"
|
||||
subnet_id = azurerm_subnet.my_terraform_subnet.id
|
||||
private_ip_address_allocation = "Dynamic"
|
||||
public_ip_address_id = azurerm_public_ip.my_terraform_public_ip.id
|
||||
}
|
||||
}
|
||||
|
||||
# Connect the security group to the network interface
|
||||
resource "azurerm_network_interface_security_group_association" "example" {
|
||||
network_interface_id = azurerm_network_interface.my_terraform_nic.id
|
||||
network_security_group_id = azurerm_network_security_group.my_terraform_nsg.id
|
||||
}
|
||||
|
||||
# Generate random text for a unique storage account name
|
||||
resource "random_id" "random_id" {
|
||||
keepers = {
|
||||
# Generate a new ID only when a new resource group is defined
|
||||
resource_group = azurerm_resource_group.rg.name
|
||||
}
|
||||
|
||||
byte_length = 8
|
||||
}
|
||||
|
||||
# Create storage account for boot diagnostics
|
||||
resource "azurerm_storage_account" "my_storage_account" {
|
||||
name = "diag${random_id.random_id.hex}"
|
||||
location = azurerm_resource_group.rg.location
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
account_tier = "Standard"
|
||||
account_replication_type = "LRS"
|
||||
}
|
||||
|
||||
# Create (and display) an SSH key
|
||||
resource "tls_private_key" "example_ssh" {
|
||||
algorithm = "RSA"
|
||||
rsa_bits = 4096
|
||||
}
|
||||
|
||||
# Create virtual machine
|
||||
resource "azurerm_linux_virtual_machine" "my_terraform_vm" {
|
||||
name = "myVM"
|
||||
location = azurerm_resource_group.rg.location
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
network_interface_ids = [azurerm_network_interface.my_terraform_nic.id]
|
||||
size = "Standard_DS1_v2"
|
||||
|
||||
os_disk {
|
||||
name = "myOsDisk"
|
||||
caching = "ReadWrite"
|
||||
storage_account_type = "Premium_LRS"
|
||||
}
|
||||
|
||||
source_image_reference {
|
||||
publisher = "Canonical"
|
||||
offer = "UbuntuServer"
|
||||
sku = "18.04-LTS"
|
||||
version = "latest"
|
||||
}
|
||||
|
||||
computer_name = "myvm"
|
||||
admin_username = "azureuser"
|
||||
disable_password_authentication = true
|
||||
|
||||
admin_ssh_key {
|
||||
username = "azureuser"
|
||||
public_key = tls_private_key.example_ssh.public_key_openssh
|
||||
}
|
||||
|
||||
boot_diagnostics {
|
||||
storage_account_uri = azurerm_storage_account.my_storage_account.primary_blob_endpoint
|
||||
}
|
||||
}
|
12
quickstart/101-vm-with-infrastructure/outputs.tf
Normal file
12
quickstart/101-vm-with-infrastructure/outputs.tf
Normal file
@ -0,0 +1,12 @@
|
||||
output "resource_group_name" {
|
||||
value = azurerm_resource_group.rg.name
|
||||
}
|
||||
|
||||
output "public_ip_address" {
|
||||
value = azurerm_linux_virtual_machine.my_terraform_vm.public_ip_address
|
||||
}
|
||||
|
||||
output "tls_private_key" {
|
||||
value = tls_private_key.example_ssh.private_key_pem
|
||||
sensitive = true
|
||||
}
|
22
quickstart/101-vm-with-infrastructure/providers.tf
Normal file
22
quickstart/101-vm-with-infrastructure/providers.tf
Normal file
@ -0,0 +1,22 @@
|
||||
terraform {
|
||||
required_version = ">=0.12"
|
||||
|
||||
required_providers {
|
||||
azurerm = {
|
||||
source = "hashicorp/azurerm"
|
||||
version = "~>2.0"
|
||||
}
|
||||
random = {
|
||||
source = "hashicorp/random"
|
||||
version = "~>3.0"
|
||||
}
|
||||
tls = {
|
||||
source = "hashicorp/tls"
|
||||
version = "~>4.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
provider "azurerm" {
|
||||
features {}
|
||||
}
|
30
quickstart/101-vm-with-infrastructure/readme.md
Normal file
30
quickstart/101-vm-with-infrastructure/readme.md
Normal file
@ -0,0 +1,30 @@
|
||||
# Azure resource group
|
||||
|
||||
This template deploys a Linux virtual machine (VM) with infrastructure that includes a virtual network, subnet, public IP address, and more.
|
||||
|
||||
## Terraform resource types
|
||||
|
||||
- [random_pet](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/pet)
|
||||
- [azurerm_resource_group](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group)
|
||||
|
||||
- [azurerm_virtual_network](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_network)
|
||||
- [azurerm_subnet](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/subnet)
|
||||
- [azurerm_public_ip](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/public_ip)
|
||||
- [azurerm_network_security_group](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/network_security_group)
|
||||
- [azurerm_network_interface](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/network_interface)
|
||||
- [azurerm_network_interface_security_group_association](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/network_interface_security_group_association)
|
||||
- [random_id](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/id)
|
||||
- [azurerm_storage_account](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_account)
|
||||
- [tls_private_key](https://registry.terraform.io/providers/hashicorp/tls/latest/docs/resources/private_key)
|
||||
- [azurerm_linux_virtual_machine](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/linux_virtual_machine)
|
||||
|
||||
## Variables
|
||||
|
||||
| Name | Description | Default |
|
||||
|-|-|
|
||||
| `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 |
|
||||
| `resource_group_location` | Location of the resource group. | eastus |
|
||||
|
||||
## Example
|
||||
|
||||
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).
|
9
quickstart/101-vm-with-infrastructure/variables.tf
Normal file
9
quickstart/101-vm-with-infrastructure/variables.tf
Normal file
@ -0,0 +1,9 @@
|
||||
variable "resource_group_location" {
|
||||
default = "eastus"
|
||||
description = "Location of the resource group."
|
||||
}
|
||||
|
||||
variable "resource_group_name_prefix" {
|
||||
default = "rg"
|
||||
description = "Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription."
|
||||
}
|
@ -19,8 +19,8 @@ This template deploys an [Azure MySQL Flexible Server Database](https://registry
|
||||
|
||||
| Name | Description | Default |
|
||||
|-|-|-|
|
||||
| `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|
|
||||
| `resource_group_location` | (Optional) Azure Region in which to deploy these resources. Value defaults to: eastus |
|
||||
| `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 |
|
||||
| `resource_group_location` | Location of the resource group. | eastus |
|
||||
|
||||
## Example
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user