Phase1-2
This commit is contained in:
@@ -1,27 +0,0 @@
|
||||
name: Terraform
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ "main" ]
|
||||
push:
|
||||
branches: [ "main" ]
|
||||
|
||||
jobs:
|
||||
terraform:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Terraform
|
||||
uses: hashicorp/setup-terraform@v2
|
||||
|
||||
- name: Terraform Init
|
||||
run: terraform -chdir=environments/dev init
|
||||
|
||||
- name: Terraform Validate
|
||||
run: terraform -chdir=environments/dev validate
|
||||
|
||||
- name: Terraform Plan
|
||||
run: terraform -chdir=environments/dev plan
|
||||
|
||||
@@ -15,7 +15,7 @@ provider "azurerm" {
|
||||
module "network" {
|
||||
source = "../../modules/network"
|
||||
vnet_name = "dev-vnet"
|
||||
resource_group_name = "dev-rg"
|
||||
resource_group_name = "terraform"
|
||||
location = "UK South"
|
||||
address_space = ["10.0.0.0/16"]
|
||||
subnets = { public = "10.0.1.0/24", private = "10.0.2.0/24" }
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
resource "azurerm_network_interface" "nic" {
|
||||
name = "example-nic"
|
||||
location = var.location
|
||||
resource_group_name = var.resource_group_name
|
||||
|
||||
ip_configuration {
|
||||
name = "internal"
|
||||
subnet_id = var.subnet_id
|
||||
private_ip_address_allocation = "Dynamic"
|
||||
public_ip_address_id = azurerm_public_ip.vm_public.id
|
||||
}
|
||||
}
|
||||
|
||||
resource "azurerm_public_ip" "vm_public" {
|
||||
name = "example-pip"
|
||||
location = var.location
|
||||
resource_group_name = var.resource_group_name
|
||||
allocation_method = "Dynamic"
|
||||
}
|
||||
|
||||
resource "azurerm_linux_virtual_machine" "vm" {
|
||||
name = "example-vm"
|
||||
resource_group_name = var.resource_group_name
|
||||
location = var.location
|
||||
size = var.vm_size
|
||||
admin_username = var.admin_username
|
||||
network_interface_ids = [azurerm_network_interface.nic.id]
|
||||
admin_ssh_key {
|
||||
username = var.admin_username
|
||||
public_key = var.ssh_public_key
|
||||
}
|
||||
os_disk {
|
||||
caching = "ReadWrite"
|
||||
storage_account_type = "Standard_LRS"
|
||||
}
|
||||
source_image_reference {
|
||||
publisher = "Canonical"
|
||||
offer = "UbuntuServer"
|
||||
sku = "22_04-lts-gen2"
|
||||
version = "latest"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user