Skip to content

Commit 2ba2c71

Browse files
authored
[ZT] Device enrollment Terraform examples (cloudflare#21829)
* update device enrollment examples * update app name * service token enrollment * update mtls example * remove empty line
1 parent 66c3c04 commit 2ba2c71

File tree

4 files changed

+78
-71
lines changed

4 files changed

+78
-71
lines changed

src/content/partials/cloudflare-one/access/create-service-token.mdx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,12 @@ import { Tabs, TabItem, Details } from '~/components';
2323
This is the only time Cloudflare Access will display the Client Secret. If you lose the Client Secret, you must generate a new service token.
2424
:::
2525

26-
</TabItem> <TabItem label="Terraform (v4)">
26+
</TabItem> <TabItem label="Terraform (v5)">
2727

28-
:::note[Provider versions]
29-
The following example requires Cloudflare provider version `>=4.40.0`.
30-
:::
31-
32-
1. Add the following permission to your [`cloudflare_api_token`](https://registry.terraform.io/providers/cloudflare/cloudflare/4.40.0/docs/resources/api_token):
28+
1. Add the following permission to your [`cloudflare_api_token`](https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs/resources/api_token):
3329
- `Access: Service Tokens Write`
3430

35-
2. Configure the [`cloudflare_zero_trust_access_service_token`](https://registry.terraform.io/providers/cloudflare/cloudflare/4.40.0/docs/resources/zero_trust_access_service_token) resource:
31+
2. Configure the [`cloudflare_zero_trust_access_service_token`](https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs/resources/zero_trust_access_service_token) resource:
3632

3733
```tf
3834
resource "cloudflare_zero_trust_access_service_token" "example_service_token" {

src/content/partials/cloudflare-one/warp/device-enrollment-mtls.mdx

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,13 @@ To check for an mTLS certificate:
2121

2222
4. On your device, add the client certificate to the [system keychain](/cloudflare-one/identity/devices/access-integrations/mutual-tls-authentication/#test-in-the-browser).
2323

24-
</TabItem> <TabItem label="Terraform (v4)">
24+
</TabItem> <TabItem label="Terraform (v5)">
2525

26-
:::note[Provider versions]
27-
The following example requires Cloudflare provider version `>=4.40.0`.
28-
:::
29-
30-
1. Add the following permissions to your [`cloudflare_api_token`](https://registry.terraform.io/providers/cloudflare/cloudflare/4.40.0/docs/resources/api_token):
26+
1. Add the following permissions to your [`cloudflare_api_token`](https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs/resources/api_token):
3127
- `Access: Mutual TLS Certificates Write`
3228
- `Access: Apps and Policies Write`
3329

34-
2. Use the [`cloudflare_zero_trust_access_mtls_certificate`](https://registry.terraform.io/providers/cloudflare/cloudflare/4.40.0/docs/resources/zero_trust_access_mtls_certificate) resource to add an mTLS certificate to your account:
30+
2. Use the [`cloudflare_zero_trust_access_mtls_certificate`](https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs/resources/zero_trust_access_mtls_certificate) resource to add an mTLS certificate to your account:
3531

3632
```tf
3733
resource "cloudflare_zero_trust_access_mtls_certificate" "example_mtls_cert" {
@@ -47,26 +43,38 @@ The following example requires Cloudflare provider version `>=4.40.0`.
4743
}
4844
```
4945

50-
3. Add the following policy to your [WARP enrollment Access application](/cloudflare-one/connections/connect-devices/warp/deployment/device-enrollment/#set-device-enrollment-permissions):
46+
3. Create the following Access policy:
5147

5248
```tf
53-
resource "cloudflare_zero_trust_access_policy" "warp_enrollment_employees" {
54-
application_id = cloudflare_zero_trust_access_application.warp_enrollment_app.id
49+
resource "cloudflare_zero_trust_access_policy" "warp_enrollment_mtls" {
5550
account_id = var.cloudflare_account_id
56-
name = "Allow company emails"
51+
name = "Allow employees with mTLS cert"
5752
decision = "allow"
58-
precedence = 1
59-
60-
include {
61-
email_domain = ["company.com"]
62-
}
63-
64-
require {
65-
common_names = ["Common name 1", "Common name 2"]
66-
}
53+
include = [
54+
{
55+
email_domain = {
56+
domain = "@example.com"
57+
}
58+
}
59+
]
60+
61+
require = [
62+
{
63+
common_name = {
64+
common_name = "Common name 1"
65+
}
66+
},
67+
{
68+
common_name = {
69+
common_name = "Common name 2"
70+
}
71+
}
72+
]
6773
}
6874
```
6975

70-
4. On your device, add the client certificate to the [system keychain](/cloudflare-one/identity/devices/access-integrations/mutual-tls-authentication/#test-in-the-browser).
76+
4. Add the policy to your [`cloudflared_zero_trust_access_application` for WARP](/cloudflare-one/connections/connect-devices/warp/deployment/device-enrollment/#set-device-enrollment-permissions).
77+
78+
5. On your device, add the client certificate to the [system keychain](/cloudflare-one/identity/devices/access-integrations/mutual-tls-authentication/#test-in-the-browser).
7179

7280
</TabItem> </Tabs>

src/content/partials/cloudflare-one/warp/device-enrollment.mdx

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -22,43 +22,46 @@ Device posture checks are not supported in device enrollment policies. WARP can
2222
4. In the **Authentication** tab, select the [identity providers](/cloudflare-one/identity/idp-integration/) users can authenticate with. If you have not integrated an identity provider, you can use the [one-time PIN](/cloudflare-one/identity/one-time-pin/).
2323
5. Select **Save**.
2424

25-
</TabItem> <TabItem label="Terraform (v4)">
25+
</TabItem> <TabItem label="Terraform (v5)">
2626

27-
:::note[Provider versions]
28-
The following example requires Cloudflare provider version `>=4.40.0`.
29-
:::
30-
31-
1. Add the following permission to your [`cloudflare_api_token`](https://registry.terraform.io/providers/cloudflare/cloudflare/4.40.0/docs/resources/api_token):
27+
1. Add the following permission to your [`cloudflare_api_token`](https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs/resources/api_token):
3228
- `Access: Apps and Policies Write`
3329

34-
2. Use the [`cloudflare_zero_trust_access_application`](https://registry.terraform.io/providers/cloudflare/cloudflare/4.45.0/docs/resources/zero_trust_access_application) resource to create an application with type `warp`.
30+
2. Create a reusable Access policy using the [`cloudflare_zero_trust_access_policy`](https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs/resources/zero_trust_access_policy) resource:
31+
32+
```tf
33+
resource "cloudflare_zero_trust_access_policy" "allow_company_emails" {
34+
account_id = var.cloudflare_account_id
35+
name = "Allow company emails"
36+
decision = "allow"
37+
include = [
38+
{
39+
email_domain = {
40+
domain = "@example.com"
41+
}
42+
}
43+
]
44+
}
45+
```
46+
47+
3. Use the [`cloudflare_zero_trust_access_application`](https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs/resources/zero_trust_access_application) resource to create an application with type `warp`.
3548

3649
```tf
37-
resource "cloudflare_zero_trust_access_application" "warp_enrollment_app" {
38-
account_id = var.cloudflare_account_id
39-
session_duration = "18h"
40-
name = "Warp device enrollment"
50+
resource "cloudflare_zero_trust_access_application" "device_enrollment" {
51+
account_id = var.cloudflare_account_id
52+
type = "warp"
53+
name = "Warp device enrollment"
4154
allowed_idps = [cloudflare_zero_trust_access_identity_provider.microsoft_entra_id.id]
4255
auto_redirect_to_identity = true
43-
type = "warp"
4456
app_launcher_visible = false
57+
policies = [
58+
{
59+
id = cloudflare_zero_trust_access_policy.allow_company_emails.id
60+
precedence = 1
61+
}
62+
]
4563
}
4664
```
4765

48-
3. Use the [`cloudflare_zero_trust_access_policy`](https://registry.terraform.io/providers/cloudflare/cloudflare/4.45.0/docs/resources/zero_trust_access_policy) resource to define enrollment permissions.
49-
50-
```tf
51-
resource "cloudflare_zero_trust_access_policy" "warp_enrollment_employees" {
52-
application_id = cloudflare_zero_trust_access_application.warp_enrollment_app.id
53-
account_id = var.cloudflare_account_id
54-
name = "Allow company emails"
55-
decision = "allow"
56-
precedence = 1
57-
58-
include {
59-
email_domain = ["company.com"]
60-
}
61-
}
62-
```
63-
64-
</TabItem> </Tabs>
66+
</TabItem>
67+
</Tabs>

src/content/partials/cloudflare-one/warp/service-token-enrollment.mdx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,33 +23,33 @@ import { Tabs, TabItem } from '~/components';
2323
* `auth_client_id`: The **Client ID** of your service token.
2424
* `auth_client_secret`: The **Client Secret** of your service token.
2525

26-
</TabItem> <TabItem label="Terraform (v4)">
26+
</TabItem> <TabItem label="Terraform (v5)">
2727

28-
:::note[Provider versions]
29-
The following example requires Cloudflare provider version `>=4.40.0`.
30-
:::
31-
32-
1. Add the following permission to your [`cloudflare_api_token`](https://registry.terraform.io/providers/cloudflare/cloudflare/4.40.0/docs/resources/api_token):
28+
1. Add the following permissions to your [`cloudflare_api_token`](https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs/resources/api_token):
3329
- `Access: Apps and Policies Write`
30+
- `Access: Service Tokens Write`
3431

3532
2. [Create a service token](/cloudflare-one/identity/service-tokens/#create-a-service-token) and copy its **Client ID** and **Client Secret**.
3633

37-
3. Add the following policy to your [WARP enrollment Access application](/cloudflare-one/connections/connect-devices/warp/deployment/device-enrollment/#set-device-enrollment-permissions):
34+
3. Create the following Access policy:
3835

3936
```tf
4037
resource "cloudflare_zero_trust_access_policy" "warp_enrollment_service_token" {
41-
application_id = cloudflare_zero_trust_access_application.warp_enrollment_app.id
4238
account_id = var.cloudflare_account_id
4339
name = "Allow service token"
4440
decision = "non_identity"
45-
precedence = 2
46-
47-
include {
48-
service_token = [cloudflare_zero_trust_access_service_token.example_service_token.id]
49-
}
41+
include = [
42+
{
43+
service_token = {
44+
token_id = cloudflare_zero_trust_access_service_token.example_service_token.id
45+
}
46+
}
47+
]
5048
}
5149
```
52-
4. In your MDM [deployment parameters](/cloudflare-one/connections/connect-devices/warp/deployment/mdm-deployment/parameters/), add the following fields:
50+
4. Add the policy to your [`cloudflared_zero_trust_access_application` for WARP](/cloudflare-one/connections/connect-devices/warp/deployment/device-enrollment/#set-device-enrollment-permissions).
51+
52+
5. In your MDM [deployment parameters](/cloudflare-one/connections/connect-devices/warp/deployment/mdm-deployment/parameters/), add the following fields:
5353
* `auth_client_id`: The **Client ID** of your service token.
5454
* `auth_client_secret`: The **Client Secret** of your service token.
5555

0 commit comments

Comments
 (0)