Silly98 commited on
Commit
39f7e7a
·
verified ·
1 Parent(s): 576e9a2

Delete chatgpt

Browse files
Files changed (1) hide show
  1. chatgpt +0 -223
chatgpt DELETED
@@ -1,223 +0,0 @@
1
- variable "subscription_id" {
2
- type = string
3
- }
4
-
5
- variable "location" {
6
- type = string
7
- default = "eastus"
8
- }
9
-
10
- variable "prefix" {
11
- type = string
12
- default = "cad"
13
- }
14
-
15
- variable "admin_username" {
16
- type = string
17
- default = "azureuser"
18
- }
19
-
20
- variable "ssh_public_key" {
21
- type = string
22
- }
23
-
24
- variable "allowed_ssh_cidr" {
25
- type = string
26
- }
27
-
28
- variable "vm_size" {
29
- type = string
30
- default = "Standard_NC4as_T4_v3"
31
- }
32
-
33
- variable "os_disk_gb" {
34
- type = number
35
- default = 250
36
- }
37
-
38
-
39
-
40
-
41
-
42
-
43
-
44
-
45
-
46
-
47
-
48
-
49
- terraform {
50
- required_version = ">= 1.6.0"
51
- required_providers {
52
- azurerm = {
53
- source = "hashicorp/azurerm"
54
- version = "~> 4.0"
55
- }
56
- random = {
57
- source = "hashicorp/random"
58
- version = "~> 3.6"
59
- }
60
- }
61
- }
62
-
63
- provider "azurerm" {
64
- features {}
65
- subscription_id = var.subscription_id
66
- }
67
-
68
- resource "random_string" "suffix" {
69
- length = 6
70
- upper = false
71
- special = false
72
- }
73
-
74
- locals {
75
- sfx = random_string.suffix.result
76
- rg_name = "rg-${var.prefix}-${local.sfx}"
77
-
78
- # storage account must be 3-24 chars, lowercase + numbers only
79
- st_name = lower(replace("${var.prefix}${local.sfx}st", "-", ""))
80
-
81
- vnet = "vnet-${var.prefix}-${local.sfx}"
82
- subnet = "subnet-${var.prefix}-${local.sfx}"
83
- nsg = "nsg-${var.prefix}-${local.sfx}"
84
- pip = "pip-${var.prefix}-${local.sfx}"
85
- nic = "nic-${var.prefix}-${local.sfx}"
86
- vm = "vm-${var.prefix}-${local.sfx}"
87
- }
88
-
89
- resource "azurerm_resource_group" "rg" {
90
- name = local.rg_name
91
- location = var.location
92
- }
93
-
94
- resource "azurerm_storage_account" "st" {
95
- name = local.st_name
96
- resource_group_name = azurerm_resource_group.rg.name
97
- location = azurerm_resource_group.rg.location
98
- account_tier = "Standard"
99
- account_replication_type = "LRS"
100
- allow_nested_items_to_be_public = false
101
- }
102
-
103
- resource "azurerm_virtual_network" "vnet" {
104
- name = local.vnet
105
- location = azurerm_resource_group.rg.location
106
- resource_group_name = azurerm_resource_group.rg.name
107
- address_space = ["10.10.0.0/16"]
108
- }
109
-
110
- resource "azurerm_subnet" "subnet" {
111
- name = local.subnet
112
- resource_group_name = azurerm_resource_group.rg.name
113
- virtual_network_name = azurerm_virtual_network.vnet.name
114
- address_prefixes = ["10.10.1.0/24"]
115
- }
116
-
117
- resource "azurerm_network_security_group" "nsg" {
118
- name = local.nsg
119
- location = azurerm_resource_group.rg.location
120
- resource_group_name = azurerm_resource_group.rg.name
121
-
122
- security_rule {
123
- name = "allow-ssh"
124
- priority = 100
125
- direction = "Inbound"
126
- access = "Allow"
127
- protocol = "Tcp"
128
- source_port_range = "*"
129
- destination_port_range = "22"
130
- source_address_prefix = var.allowed_ssh_cidr
131
- destination_address_prefix = "*"
132
- }
133
- }
134
-
135
- resource "azurerm_public_ip" "pip" {
136
- name = local.pip
137
- location = azurerm_resource_group.rg.location
138
- resource_group_name = azurerm_resource_group.rg.name
139
- allocation_method = "Static"
140
- sku = "Standard"
141
- }
142
-
143
- resource "azurerm_network_interface" "nic" {
144
- name = local.nic
145
- location = azurerm_resource_group.rg.location
146
- resource_group_name = azurerm_resource_group.rg.name
147
-
148
- ip_configuration {
149
- name = "ipconfig1"
150
- subnet_id = azurerm_subnet.subnet.id
151
- private_ip_address_allocation = "Dynamic"
152
- public_ip_address_id = azurerm_public_ip.pip.id
153
- }
154
- }
155
-
156
- resource "azurerm_network_interface_security_group_association" "nic_nsg" {
157
- network_interface_id = azurerm_network_interface.nic.id
158
- network_security_group_id = azurerm_network_security_group.nsg.id
159
- }
160
-
161
- resource "azurerm_linux_virtual_machine" "vm" {
162
- name = local.vm
163
- resource_group_name = azurerm_resource_group.rg.name
164
- location = azurerm_resource_group.rg.location
165
- size = var.vm_size
166
- admin_username = var.admin_username
167
- network_interface_ids = [azurerm_network_interface.nic.id]
168
-
169
- admin_ssh_key {
170
- username = var.admin_username
171
- public_key = var.ssh_public_key
172
- }
173
-
174
- os_disk {
175
- caching = "ReadWrite"
176
- storage_account_type = "Premium_LRS"
177
- disk_size_gb = var.os_disk_gb # 250 GB
178
- }
179
-
180
- source_image_reference {
181
- publisher = "Canonical"
182
- offer = "0001-com-ubuntu-server-jammy"
183
- sku = "22_04-lts-gen2"
184
- version = "latest"
185
- }
186
- }
187
-
188
-
189
-
190
-
191
-
192
-
193
-
194
-
195
-
196
-
197
-
198
-
199
-
200
-
201
-
202
-
203
- subscription_id = "<YOUR_SUBSCRIPTION_ID>"
204
- location = "eastus"
205
-
206
- ssh_public_key = "ssh-ed25519 AAAA...paste_your_pub_key..."
207
- allowed_ssh_cidr = "YOUR.PUBLIC.IP/32"
208
-
209
- vm_size = "Standard_NC4as_T4_v3"
210
- os_disk_gb = 250
211
-
212
-
213
-
214
-
215
-
216
-
217
-
218
-
219
-
220
- output "resource_group" { value = azurerm_resource_group.rg.name }
221
- output "storage_account" { value = azurerm_storage_account.st.name }
222
- output "public_ip" { value = azurerm_public_ip.pip.ip_address }
223
- output "vm_name" { value = azurerm_linux_virtual_machine.vm.name }