-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcloudflare-access.tf
54 lines (47 loc) · 1.96 KB
/
cloudflare-access.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
locals {
vault_users = length(var.vault_users) > 0 ? var.vault_users : [var.cloudflare_email]
vault_ssh_users = length(var.vault_ssh_users) > 0 ? var.vault_ssh_users : [var.cloudflare_email]
}
# Access application to apply zero trust policy to Vault/SSH
resource "cloudflare_access_application" "vault" {
zone_id = local.cloudflare_zone_id
name = "${var.vault_subdomain}.${var.cloudflare_zone_name}"
domain = "${var.vault_subdomain}.${var.cloudflare_zone_name}"
session_duration = "1h"
type = "self_hosted"
}
# Access policy that the above appplication uses. (i.e. who is allowed in)
resource "cloudflare_access_policy" "vault" {
application_id = cloudflare_access_application.vault.id
zone_id = local.cloudflare_zone_id
name = cloudflare_access_application.vault.domain
precedence = "1"
decision = "allow"
include {
email = local.vault_users
}
}
# Access application to apply zero trust policy to Vault/SSH
resource "cloudflare_access_application" "vault_ssh" {
zone_id = local.cloudflare_zone_id
name = "${var.vault_subdomain}${var.vault_subdomain_suffix_ssh}.${var.cloudflare_zone_name}"
domain = "${var.vault_subdomain}${var.vault_subdomain_suffix_ssh}.${var.cloudflare_zone_name}"
session_duration = "1h"
type = "ssh"
}
# Access policy that the above appplication uses. (i.e. who is allowed in)
resource "cloudflare_access_policy" "vault_ssh" {
application_id = cloudflare_access_application.vault_ssh.id
zone_id = local.cloudflare_zone_id
name = cloudflare_access_application.vault_ssh.domain
precedence = "1"
decision = "allow"
include {
email = local.vault_ssh_users
}
}
# SSH CA certificate for SSH short-lived certificates
resource "cloudflare_access_ca_certificate" "vault_ssh" {
zone_id = local.cloudflare_zone_id
application_id = cloudflare_access_application.vault_ssh.id
}