-
Notifications
You must be signed in to change notification settings - Fork 0
/
ssh.tf
60 lines (51 loc) · 1.76 KB
/
ssh.tf
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
59
resource "tls_private_key" "bastion" {
algorithm = "RSA"
rsa_bits = 4096
}
resource "tls_private_key" "private" {
algorithm = "RSA"
rsa_bits = 4096
}
resource "google_compute_project_metadata_item" "ssh_keys" {
key = "${var.env}-ssh-keys"
value = "${google_service_account.bastion_sa.email}:${tls_private_key.bastion.public_key_openssh}"
}
# resource "google_project_iam_custom_role" "ssh_role" {
# project = var.project_id
# role_id = "${var.env}-CusomtSshRole"
# title = "SSH Role for accessing bastion host"
# permissions = [
# "compute.instances.get",
# "compute.instances.osLogin",
# "compute.instances.setMetadata",
# "compute.projects.get",
# "compute.instances.use",
# ]
# }
# resource "google_project_iam_member" "ssh_access" {
# count = length(var.iam_member_emails)
# project = var.project_id
# role = google_project_iam_custom_role.ssh_role.id
# member = "user:${var.iam_member_emails[count.index]}"
# }
# resource "google_project_iam_member" "os_login_users" {
# count = length(var.iam_member_emails)
# project = var.project_id
# role = "roles/compute.osLogin"
# member = "user:${var.iam_member_emails[count.index]}"
# }
// ssh storage
resource "google_storage_bucket" "ssh_keys_bucket" {
name = "${var.env}-ludo-ssh-keys-cloud-bucket-storage"
location = var.region
}
resource "google_storage_bucket_object" "bastion_ssh_key" {
name = "${var.env}-bastion-ssh-key.pem"
content = tls_private_key.bastion.private_key_pem
bucket = google_storage_bucket.ssh_keys_bucket.name
}
resource "google_storage_bucket_object" "private_ssh_key" {
name = "${var.env}-private-ssh-key.pem"
content = tls_private_key.private.private_key_pem
bucket = google_storage_bucket.ssh_keys_bucket.name
}