Skip to content

Commit f607842

Browse files
authored
[ZT] Service token Vault example (#18405)
* add service token vault example * tweak wording
1 parent ed3dc92 commit f607842

File tree

1 file changed

+46
-25
lines changed

1 file changed

+46
-25
lines changed

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

Lines changed: 46 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
---
55

6-
import { Tabs, TabItem } from '~/components';
6+
import { Tabs, TabItem, Details } from '~/components';
77

88
<Tabs syncKey="dashPlusAPI"> <TabItem label="Dashboard">
99

@@ -32,35 +32,56 @@ import { Tabs, TabItem } from '~/components';
3232

3333
```tf
3434
resource "cloudflare_zero_trust_access_service_token" "example_service_token" {
35-
account_id = var.cloudflare_account_id
36-
name = "Example service token"
37-
duration = "8760h"
38-
}
39-
```
35+
account_id = var.cloudflare_account_id
36+
name = "Example service token"
37+
duration = "8760h"
4038
41-
3. Output the Client ID and Client Secret to the Terraform state file:
42-
43-
```tf
44-
output "example_service_token_client_id" {
45-
value = cloudflare_zero_trust_access_service_token.example_service_token.client_id
39+
lifecycle {
40+
create_before_destroy = true
41+
}
4642
}
43+
```
4744

48-
output "example_service_token_client_secret" {
49-
value = cloudflare_zero_trust_access_service_token.example_service_token.client_secret
50-
sensitive = true
45+
3. Get the Client ID and Client Secret of the service token:
46+
47+
<Details header="Example: Output to CLI" open = {false}>
48+
1. Output the Client ID and Client Secret to the Terraform state file:
49+
```tf
50+
output "example_service_token_client_id" {
51+
value = cloudflare_zero_trust_access_service_token.example_service_token.client_id
52+
}
53+
54+
output "example_service_token_client_secret" {
55+
value = cloudflare_zero_trust_access_service_token.example_service_token.client_secret
56+
sensitive = true
57+
}
58+
```
59+
2. Apply the configuration:
60+
```sh
61+
terraform apply
62+
```
63+
3. Read the Client ID and Client Secret:
64+
```sh
65+
terraform output -raw example_service_token_client_id
66+
```
67+
```sh
68+
terraform output -raw example_service_token_client_secret
69+
```
70+
</Details>
71+
72+
<Details header="Example: Store in HashiCorp Vault" open = {false}>
73+
```tf
74+
resource "vault_generic_secret" "example_service_token" {
75+
path = "kv/cloudflare/example_service_token"
76+
disable_read = true
77+
78+
data_json = jsonencode({
79+
"CLIENT_ID" = cloudflare_access_service_token.example_service_token.client_id
80+
"CLIENT_SECRET" = cloudflare_access_service_token.example_service_token.client_secret
81+
})
5182
}
5283
```
53-
4. Apply the configuration:
54-
```sh
55-
terraform apply
56-
```
84+
</Details>
5785

58-
5. Read the Client ID and Client Secret:
59-
```sh
60-
terraform output -raw example_service_token_client_id
61-
```
62-
```sh
63-
terraform output -raw example_service_token_client_secret
64-
```
6586

6687
</TabItem> </Tabs>

0 commit comments

Comments
 (0)