-
Notifications
You must be signed in to change notification settings - Fork 15
/
main.tf
69 lines (54 loc) · 1.87 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Configure the Microsoft Azure Provider
provider "azurerm" {
#features{}
version = "~> 1.42"
}
terraform {
}
# Create a resource group if it doesn’t exist
resource "azurerm_resource_group" "main" {
name = format("%s-resourcegroup-%s",var.prefix,random_id.randomId.hex)
location = var.region
tags = {
environment = var.environment
}
}
# Create storage account for boot diagnostics
resource "azurerm_storage_account" "mystorageaccount" {
name = format("%sdiagstorage%s",var.prefix,random_id.randomId.hex)
resource_group_name = azurerm_resource_group.main.name
location = azurerm_resource_group.main.location
account_tier = "Standard"
account_replication_type = "LRS"
tags = {
environment = var.environment
}
}
# Create Network Security Group and rule
resource "azurerm_network_security_group" "securitygroup" {
name = format("%s-securitygroup-%s",var.prefix,random_id.randomId.hex)
location = var.region
resource_group_name = azurerm_resource_group.main.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 = "*"
}
tags = {
environment = var.environment
}
}
# Generate random text for a unique storage account name
resource "random_id" "randomId" {
# keepers = {
# # Generate a new ID only when a new resource group is defined
# resource_group = azurerm_resource_group.resourcegroup.name
# }
byte_length = 2
}