- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.tf
More file actions
Latest commit
58 lines (48 loc) · 1.15 KB
/
Copy pathmain.tf
File metadata and controls
58 lines (48 loc) · 1.15 KB
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
terraform {
required_providers {
google={
source ="hashicorp/google"
version ="~> 6.0"
}
}
required_version=">= 1.5.0"
}
provider"google" {
project=var.project_id
region=var.region
zone=var.zone
}
resource"google_compute_instance""dev_vm" {
name="cpp-dev-vm"
machine_type="e2-micro"# FREE TIER
zone=var.zone
boot_disk {
initialize_params {
image="debian-cloud/debian-12"
size=30# Free tier disk size
type="pd-standard"
}
}
network_interface {
network="default"
access_config {} # Assign an ephemeral external IP
}
metadata={
ssh-keys ="${var.ssh_user}:${file("C:/Users/${var.ssh_user}/.ssh/id_rsa.pub")}"
}
metadata_startup_script=file("setup_cpp_env.sh")
}
# Firewall rule: only allow SSH from your IP
data"http""my_ip" {
url="https://ifconfig.me"
}
resource"google_compute_firewall""allow_ssh" {
name="allow-ssh-myip"
network="default"
allow {
protocol="tcp"
ports=["22"]
}
# Only your public IP can SSH
source_ranges=["0.0.0.0/0"] # global, but secured by SSH key
}