Working Instance creation.

This commit is contained in:
Sławek Koszewski 2025-03-28 10:08:14 +01:00
parent d83774fc80
commit b8b56c9b7e
3 changed files with 48 additions and 0 deletions

41
main.tf Normal file
View File

@ -0,0 +1,41 @@
terraform {
required_providers {
google = {
source = "hashicorp/google"
version = "6.27.0"
}
}
}
provider "google" {
# Configuration options
project = "network-getting-started"
region = "europe-central2"
zone = "europe-central2-b"
}
data "google_project" "project" {
project_id = "network-getting-started"
}
resource "google_compute_instance" "vm_1" {
name = "tftest-vm"
machine_type = "e2-micro"
can_ip_forward = false
description = "Terraform test instance"
boot_disk {
initialize_params {
image = "debian-cloud/debian-12"
}
}
network_interface {
network = "dom-lab-vpc"
subnetwork = "pl-hub"
}
metadata = {
ssh-keys = "${var.ssh[0].public_key} ${var.ssh[0].ssh_user}"
}
}

BIN
main.tfplan Normal file

Binary file not shown.

7
variables.tf Normal file
View File

@ -0,0 +1,7 @@
variable "ssh" {
description = "SSH Key(s) definition"
type = list(object({
public_key = string
ssh_user = string
}))
}