migrate
This commit is contained in:
+23
@@ -0,0 +1,23 @@
|
||||
resource "cloudflare_zero_trust_access_application" "<< resource_name >>" {
|
||||
zone_id = data.cloudflare_zone.main.zone_id
|
||||
name = "<< app_name >>"
|
||||
domain = "<< domain >>"
|
||||
type = "self_hosted"
|
||||
session_duration = "<< session_duration >>"
|
||||
policies = [
|
||||
<%- if service_token_enabled %>
|
||||
{
|
||||
id = cloudflare_zero_trust_access_policy.<< resource_name >>_service_token.id
|
||||
}
|
||||
<%- if ip_policy_enabled %>
|
||||
,
|
||||
<%- endif %>
|
||||
<%- endif %>
|
||||
<%- if ip_policy_enabled %>
|
||||
{
|
||||
id = cloudflare_zero_trust_access_policy.<< resource_name >>_ip.id
|
||||
}
|
||||
<%- endif %>
|
||||
]
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<%- if service_token_enabled %>
|
||||
resource "cloudflare_zero_trust_access_policy" "<< resource_name >>_service_token" {
|
||||
account_id = data.cloudflare_account.main.account_id
|
||||
name = "<< service_token_policy_name >>"
|
||||
decision = "non_identity"
|
||||
include = [{
|
||||
service_token = {
|
||||
token_id = "<< service_token_id >>"
|
||||
}
|
||||
}]
|
||||
session_duration = "<< session_duration >>"
|
||||
}
|
||||
<%- endif %>
|
||||
<%- if ip_policy_enabled %>
|
||||
resource "cloudflare_zero_trust_access_policy" "<< resource_name >>_ip" {
|
||||
account_id = data.cloudflare_account.main.account_id
|
||||
name = "<< ip_policy_name >>"
|
||||
decision = "non_identity"
|
||||
include = [
|
||||
for ip_range in split(",", "<< ip_ranges >>") : {
|
||||
ip = {
|
||||
ip = trimspace(ip_range)
|
||||
}
|
||||
}
|
||||
]
|
||||
session_duration = "<< session_duration >>"
|
||||
}
|
||||
<%- endif %>
|
||||
@@ -0,0 +1,7 @@
|
||||
data "cloudflare_account" "main" {
|
||||
account_id = "<< account_id_value >>"
|
||||
}
|
||||
|
||||
data "cloudflare_zone" "main" {
|
||||
zone_id = "<< zone_id_value >>"
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
{
|
||||
"slug": "cloudflare-ztna-application",
|
||||
"kind": "terraform",
|
||||
"metadata": {
|
||||
"name": "Cloudflare Zero Trust Access Application",
|
||||
"description": "Creates a Cloudflare Zero Trust Access application with service token and IP-based access policies.",
|
||||
"tags": [],
|
||||
"icon": {
|
||||
"provider": "selfhst",
|
||||
"id": "cloudflare-zero-trust"
|
||||
},
|
||||
"draft": false,
|
||||
"version": {
|
||||
"name": "5.12.0",
|
||||
"source_dep_name": "manual/cloudflare-ztna-application"
|
||||
}
|
||||
},
|
||||
"variables": [
|
||||
{
|
||||
"title": "Application",
|
||||
"name": "application",
|
||||
"items": [
|
||||
{
|
||||
"name": "app_name",
|
||||
"type": "str",
|
||||
"title": "Application name",
|
||||
"required": false,
|
||||
"default": "application",
|
||||
"config": {
|
||||
"placeholder": "application"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "domain",
|
||||
"type": "str",
|
||||
"title": "Application domain",
|
||||
"required": true,
|
||||
"config": {
|
||||
"placeholder": "app.home.arpa"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "session_duration",
|
||||
"type": "str",
|
||||
"title": "Session Duration",
|
||||
"required": false,
|
||||
"default": "15m",
|
||||
"description": "Session duration (e.g., 15m, 1h, 24h)",
|
||||
"config": {
|
||||
"placeholder": "15m"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "General",
|
||||
"name": "general",
|
||||
"items": [
|
||||
{
|
||||
"name": "account_id_value",
|
||||
"type": "str",
|
||||
"title": "Cloudflare Account ID",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"name": "resource_name",
|
||||
"type": "str",
|
||||
"title": "Resource Name",
|
||||
"required": false,
|
||||
"default": "ztna_app",
|
||||
"config": {
|
||||
"placeholder": "ztna_app"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "zone_id_value",
|
||||
"type": "str",
|
||||
"title": "Cloudflare Zone ID",
|
||||
"required": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "IP-Based Policy",
|
||||
"name": "ip-policy",
|
||||
"items": [
|
||||
{
|
||||
"name": "ip_policy_enabled",
|
||||
"type": "bool",
|
||||
"title": "IP Policy",
|
||||
"required": false,
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "ip_policy_name",
|
||||
"type": "str",
|
||||
"title": "IP Policy Name",
|
||||
"required": false,
|
||||
"default": "ip_policy",
|
||||
"description": "Policy name for IP-based access",
|
||||
"config": {
|
||||
"placeholder": "ip_policy"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "ip_ranges",
|
||||
"type": "str",
|
||||
"title": "IP Ranges",
|
||||
"required": false,
|
||||
"default": "IP_RANGE",
|
||||
"description": "Comma-separated list of IP ranges (CIDR notation)",
|
||||
"needs": [
|
||||
"ip_policy_enabled=true"
|
||||
],
|
||||
"config": {
|
||||
"placeholder": "IP_RANGE"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "Service Token Policy",
|
||||
"name": "service-token-policy",
|
||||
"items": [
|
||||
{
|
||||
"name": "service_token_enabled",
|
||||
"type": "bool",
|
||||
"title": "Service Token",
|
||||
"required": false,
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "service_token_id",
|
||||
"type": "str",
|
||||
"title": "Service Token ID",
|
||||
"required": false,
|
||||
"needs": [
|
||||
"service_token_enabled=true"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "service_token_policy_name",
|
||||
"type": "str",
|
||||
"title": "Service Token Name",
|
||||
"required": false,
|
||||
"default": "service_token_policy",
|
||||
"needs": [
|
||||
"service_token_enabled=true"
|
||||
],
|
||||
"config": {
|
||||
"placeholder": "service_token_policy"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user