initial put
This commit is contained in:
81
quickstart/101-authn-managed-identity/main.tf
Normal file
81
quickstart/101-authn-managed-identity/main.tf
Normal file
@ -0,0 +1,81 @@
|
||||
resource "random_pet" "rg_name" {
|
||||
prefix = var.resource_group_name_prefix
|
||||
}
|
||||
|
||||
resource "azurerm_resource_group" "rg" {
|
||||
name = random_pet.rg_name.id
|
||||
location = var.resource_group_location
|
||||
}
|
||||
|
||||
data "azurerm_subscription" "current" {}
|
||||
|
||||
resource "azurerm_virtual_network" "example" {
|
||||
name = "nanxuvnet06071"
|
||||
address_space = ["10.0.0.0/16"]
|
||||
location = azurerm_resource_group.rg.location
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
}
|
||||
|
||||
resource "azurerm_subnet" "example" {
|
||||
name = "nanxusubnet06071"
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
virtual_network_name = azurerm_virtual_network.example.name
|
||||
address_prefixes = ["10.0.2.0/24"]
|
||||
}
|
||||
|
||||
resource "azurerm_network_interface" "example" {
|
||||
name = "nanxunic06071"
|
||||
location = azurerm_resource_group.rg.location
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
|
||||
ip_configuration {
|
||||
name = "internal"
|
||||
subnet_id = azurerm_subnet.example.id
|
||||
private_ip_address_allocation = "Dynamic"
|
||||
}
|
||||
}
|
||||
|
||||
resource "azurerm_linux_virtual_machine" "example" {
|
||||
name = "nanxuvm06071"
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
location = azurerm_resource_group.rg.location
|
||||
size = "Standard_F2"
|
||||
network_interface_ids = [
|
||||
azurerm_network_interface.example.id,
|
||||
]
|
||||
|
||||
computer_name = "hostname"
|
||||
admin_username = var.username
|
||||
|
||||
admin_ssh_key {
|
||||
username = var.username
|
||||
public_key = azapi_resource_action.ssh_public_key_gen.output.publicKey
|
||||
}
|
||||
|
||||
identity {
|
||||
type = "SystemAssigned"
|
||||
}
|
||||
|
||||
os_disk {
|
||||
caching = "ReadWrite"
|
||||
storage_account_type = "Standard_LRS"
|
||||
}
|
||||
|
||||
source_image_reference {
|
||||
publisher = "Canonical"
|
||||
offer = "0001-com-ubuntu-server-jammy"
|
||||
sku = "22_04-lts"
|
||||
version = "latest"
|
||||
}
|
||||
}
|
||||
|
||||
data "azurerm_role_definition" "contributor" {
|
||||
name = "Contributor"
|
||||
}
|
||||
|
||||
resource "azurerm_role_assignment" "example" {
|
||||
scope = data.azurerm_subscription.current.id
|
||||
role_definition_name = "Contributor"
|
||||
principal_id = azurerm_linux_virtual_machine.example.identity[0].principal_id
|
||||
}
|
||||
|
Reference in New Issue
Block a user