updating terraform
This commit is contained in:
@@ -33,6 +33,13 @@ data "azurerm_ssh_public_key" "sd" {
|
||||
resource_group_name = "terraform"
|
||||
}
|
||||
|
||||
data "http" "my_ip" {
|
||||
url = "https://checkip.amazonaws.com/"
|
||||
}
|
||||
|
||||
locals {
|
||||
my_ip = chomp(data.http.my_ip.response_body)
|
||||
}
|
||||
|
||||
module "compute" {
|
||||
source = "../../modules/compute"
|
||||
@@ -42,4 +49,5 @@ module "compute" {
|
||||
vm_size = "Standard_B1s"
|
||||
admin_username = "azureuser"
|
||||
ssh_public_key = data.azurerm_ssh_public_key.sd.public_key
|
||||
ex_ip = local.my_ip
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
output "my_ip" {
|
||||
value = local.my_ip
|
||||
}
|
||||
@@ -14,13 +14,8 @@ resource "azurerm_network_interface" "nic" {
|
||||
resource "azurerm_network_interface_security_group_association" "example" {
|
||||
network_interface_id = azurerm_network_interface.nic.id
|
||||
network_security_group_id = azurerm_network_security_group.vm_nsg.id
|
||||
}
|
||||
|
||||
resource "azurerm_public_ip" "vm_public" {
|
||||
name = "example-pip"
|
||||
location = var.location
|
||||
resource_group_name = var.resource_group_name
|
||||
allocation_method = "Static"
|
||||
depends_on = [azurerm_network_security_group.vm_nsg]
|
||||
}
|
||||
|
||||
resource "azurerm_network_security_group" "vm_nsg" {
|
||||
@@ -36,11 +31,18 @@ resource "azurerm_network_security_group" "vm_nsg" {
|
||||
protocol = "Tcp"
|
||||
source_port_range = "*"
|
||||
destination_port_range = "22"
|
||||
source_address_prefix = "81.78.69.107"
|
||||
source_address_prefix = var.ex_ip
|
||||
destination_address_prefix = "*"
|
||||
}
|
||||
}
|
||||
|
||||
resource "azurerm_public_ip" "vm_public" {
|
||||
name = "example-pip"
|
||||
location = var.location
|
||||
resource_group_name = var.resource_group_name
|
||||
allocation_method = "Static"
|
||||
}
|
||||
|
||||
resource "azurerm_linux_virtual_machine" "vm" {
|
||||
name = "example-vm"
|
||||
resource_group_name = var.resource_group_name
|
||||
|
||||
@@ -4,3 +4,4 @@ variable "subnet_id" { type = string }
|
||||
variable "vm_size" { type = string }
|
||||
variable "admin_username" { type = string }
|
||||
variable "ssh_public_key" { type = string }
|
||||
variable "ex_ip" { type = string }
|
||||
|
||||
Reference in New Issue
Block a user