Skip to content

Commit 86f2015

Browse files
committed
Docs and examples
1 parent ffec5fb commit 86f2015

File tree

51 files changed

+777
-51
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+777
-51
lines changed

Diff for: docs/data-sources/dns_zone.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@ description: |-
1010

1111

1212

13-
13+
## Example Usage
14+
15+
```terraform
16+
# Read-only data source for a Netlify DNS zone.
17+
data "netlify_dns_zone" "example" {
18+
name = "example.com"
19+
}
20+
```
1421

1522
<!-- schema generated by tfplugindocs -->
1623
## Schema

Diff for: docs/data-sources/site.md

+14-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,20 @@ description: |-
1010

1111

1212

13-
13+
## Example Usage
14+
15+
```terraform
16+
# Looking up a site by its team slug and site name
17+
data "netlify_site" "blog" {
18+
team_slug = "my-team-slug"
19+
name = "Blog"
20+
}
21+
22+
# Looking up a blog by its ID
23+
data "netlify_site" "blog" {
24+
id = "12345667-0000-0000-0000-abcdef012345"
25+
}
26+
```
1427

1528
<!-- schema generated by tfplugindocs -->
1629
## Schema

Diff for: docs/data-sources/sites.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@ description: |-
1010

1111

1212

13-
13+
## Example Usage
14+
15+
```terraform
16+
# List all sites in a team, by the team's slug
17+
data "netlify_sites" "team" {
18+
team_slug = "my-team-slug"
19+
}
20+
```
1421

1522
<!-- schema generated by tfplugindocs -->
1623
## Schema

Diff for: docs/data-sources/team.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,19 @@ description: |-
1010

1111

1212

13-
13+
## Example Usage
14+
15+
```terraform
16+
# Looking up a team by its slug
17+
data "netlify_team" "team" {
18+
slug = "my-team-slug"
19+
}
20+
21+
# Looking up a team by its ID
22+
data "netlify_team" "team" {
23+
id = "6600abcdef1234567890abcd"
24+
}
25+
```
1426

1527
<!-- schema generated by tfplugindocs -->
1628
## Schema

Diff for: docs/index.md

+65-2
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,75 @@ description: |-
77

88
# Netlify Provider
99

10-
The Netlify provider provides resources to interact with a Netlify account.
10+
The Netlify provider provides resources to manage Netlify resources like site configuration, environment variables, and Advanced Web Security features.
11+
12+
## Authentication
13+
14+
To use the provider, you will need a [personal access token](https://docs.netlify.com/api/get-started/#authentication).
15+
You can create a new token in the [Netlify app](https://app.netlify.com/user/applications#personal-access-tokens).
16+
17+
You can expose the token as an environment variable:
18+
```bash
19+
export NETLIFY_API_TOKEN="your-personal-access-token"
20+
```
21+
22+
Or by creating a Terraform variable:
23+
```terraform
24+
variable "netlify_api_token" {
25+
type = string
26+
}
27+
28+
provider "netlify" {
29+
token = var.netlify_api_token
30+
}
31+
```
32+
and setting the variable's value as an environment variable (`TF_VAR_netlify_api_token`).
33+
34+
## Example Usage
35+
36+
```terraform
37+
variable "netlify_api_token" {
38+
type = string
39+
}
40+
41+
terraform {
42+
required_providers {
43+
netlify = {
44+
source = "registry.terraform.io/netlify/netlify"
45+
}
46+
}
47+
}
48+
49+
provider "netlify" {
50+
token = var.netlify_api_token
51+
}
52+
53+
data "netlify_team" "team" {
54+
slug = "your-team-slug"
55+
}
56+
57+
data "netlify_site" "blog" {
58+
team_slug = data.netlify_team.team.slug
59+
name = "blog"
60+
}
61+
62+
resource "netlify_environment_variable" "astro_database_file" {
63+
team_id = data.netlify_team.team.id
64+
site_id = data.netlify_site.blog.id
65+
key = "ASTRO_DATABASE_FILE"
66+
values = [
67+
{
68+
value = "/path/here",
69+
context = "all",
70+
}
71+
]
72+
}
73+
```
1174

1275
<!-- schema generated by tfplugindocs -->
1376
## Schema
1477

1578
### Optional
1679

1780
- `endpoint` (String) Defaults to: https://api.netlify.com
18-
- `token` (String, Sensitive) Read: https://docs.netlify.com/api/get-started/
81+
- `token` (String, Sensitive) Read: https://docs.netlify.com/api/get-started/#authentication , will use the `NETLIFY_API_TOKEN` environment variable if not set.

Diff for: docs/resources/dns_record.md

+36-3
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,46 @@
33
page_title: "netlify_dns_record Resource - netlify"
44
subcategory: ""
55
description: |-
6-
6+
Netlify DNS record. Read more https://docs.netlify.com/domains-https/netlify-dns/
77
---
88

99
# netlify_dns_record (Resource)
1010

11+
Netlify DNS record. [Read more](https://docs.netlify.com/domains-https/netlify-dns/)
1112

13+
## Example Usage
1214

15+
```terraform
16+
resource "netlify_dns_record" "www" {
17+
type = "A"
18+
zone_id = netlify_dns_zone.example.id
19+
hostname = "www.example.com"
20+
value = "198.18.0.50"
21+
}
1322
23+
resource "netlify_dns_record" "calendar" {
24+
type = "CNAME"
25+
zone_id = netlify_dns_zone.example.id
26+
hostname = "calendar.example.com"
27+
value = "ghs.googlehosted.com."
28+
}
29+
30+
resource "netlify_dns_record" "mx" {
31+
type = "MX"
32+
zone_id = netlify_dns_zone.example.id
33+
hostname = "example.com"
34+
value = "smtp.google.com"
35+
priority = 1
36+
}
37+
```
1438

1539
<!-- schema generated by tfplugindocs -->
1640
## Schema
1741

1842
### Required
1943

20-
- `hostname` (String)
21-
- `type` (String)
44+
- `hostname` (String) The hostname for the DNS record. For example, `www.example.com`.
45+
- `type` (String) One of A, AAAA, ALIAS, CAA, CNAME, MX, NS, SPF, or TXT
2246
- `value` (String)
2347
- `zone_id` (String)
2448

@@ -33,3 +57,12 @@ description: |-
3357

3458
- `id` (String) The ID of this resource.
3559
- `last_updated` (String)
60+
61+
## Import
62+
63+
Import is supported using the following syntax:
64+
65+
```shell
66+
# Import a DNS record by its zone ID and its record ID
67+
terraform import netlify_dns_record.www_example 6600abcdef1234567890abcd:6600abcdef1234567890abcd
68+
```

Diff for: docs/resources/dns_zone.md

+21-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,24 @@
33
page_title: "netlify_dns_zone Resource - netlify"
44
subcategory: ""
55
description: |-
6-
6+
Netlify DNS zone. Read more https://docs.netlify.com/domains-https/netlify-dns/
77
---
88

99
# netlify_dns_zone (Resource)
1010

11+
Netlify DNS zone. [Read more](https://docs.netlify.com/domains-https/netlify-dns/)
1112

13+
## Example Usage
1214

13-
15+
```terraform
16+
resource "netlify_dns_zone" "example" {
17+
team_slug = data.netlify_team.team.slug
18+
name = "example.com"
19+
lifecycle {
20+
prevent_destroy = true
21+
}
22+
}
23+
```
1424

1525
<!-- schema generated by tfplugindocs -->
1626
## Schema
@@ -40,3 +50,12 @@ Read-Only:
4050
- `name` (String)
4151
- `registered_at` (String)
4252
- `renewal_price` (String)
53+
54+
## Import
55+
56+
Import is supported using the following syntax:
57+
58+
```shell
59+
# Import a DNS zone by its ID
60+
terraform import netlify_dns_zone.example 6600abcdef1234567890abcd
61+
```

Diff for: docs/resources/environment_variable.md

+92-7
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,87 @@
33
page_title: "netlify_environment_variable Resource - netlify"
44
subcategory: ""
55
description: |-
6-
6+
Environment variables for Netlify sites. Read more https://docs.netlify.com/environment-variables/overview/
77
---
88

99
# netlify_environment_variable (Resource)
1010

11-
12-
13-
11+
Environment variables for Netlify sites. [Read more](https://docs.netlify.com/environment-variables/overview/)
12+
13+
## Example Usage
14+
15+
```terraform
16+
# Site-level environment variable, note that both team_id and site_id are specified
17+
resource "netlify_environment_variable" "astro_database_file" {
18+
team_id = data.netlify_team.team.id
19+
site_id = data.netlify_site.blog.id
20+
key = "ASTRO_DATABASE_FILE"
21+
values = [
22+
{
23+
value = "/path/here",
24+
context = "all",
25+
}
26+
]
27+
}
28+
29+
# Team-level environment variable, note that only team_id is specified
30+
# Not supported on all Netlify plans
31+
resource "netlify_environment_variable" "astro_database_file" {
32+
team_id = data.netlify_team.team.id
33+
key = "ASTRO_DATABASE_FILE"
34+
values = [
35+
{
36+
value = "/path/here",
37+
context = "all",
38+
}
39+
]
40+
}
41+
42+
# Secret environment variable
43+
# Not supported on all Netlify plans
44+
resource "netlify_environment_variable" "astro_studio_app_token" {
45+
team_id = data.netlify_team.team.id
46+
site_id = data.netlify_site.blog.id
47+
key = "ASTRO_STUDIO_APP_TOKEN"
48+
secret_values = [
49+
{
50+
value = "token-here",
51+
context = "all",
52+
}
53+
]
54+
}
55+
56+
# Values that differ by context
57+
resource "netlify_environment_variable" "astro_studio_app_token" {
58+
team_id = data.netlify_team.team.id
59+
site_id = data.netlify_site.blog.id
60+
key = "ASTRO_STUDIO_APP_TOKEN"
61+
secret_values = [
62+
{
63+
value = "token-here",
64+
context = "production",
65+
},
66+
{
67+
value = "non-prod-token-here",
68+
context = "deploy-preview",
69+
}
70+
]
71+
}
72+
73+
# A variable that's only available in some scopes, e.g. in builds
74+
resource "netlify_environment_variable" "astro_database_file" {
75+
team_id = data.netlify_team.team.id
76+
site_id = data.netlify_site.blog.id
77+
key = "ASTRO_DATABASE_FILE"
78+
scopes = ["builds"]
79+
values = [
80+
{
81+
value = "/path/here",
82+
context = "all",
83+
}
84+
]
85+
}
86+
```
1487

1588
<!-- schema generated by tfplugindocs -->
1689
## Schema
@@ -22,7 +95,7 @@ description: |-
2295

2396
### Optional
2497

25-
- `scopes` (Set of String)
98+
- `scopes` (Set of String) One or more of builds, functions, runtime, and post-processing
2699
- `secret_values` (Attributes Set) (see [below for nested schema](#nestedatt--secret_values))
27100
- `site_id` (String)
28101
- `values` (Attributes Set) (see [below for nested schema](#nestedatt--values))
@@ -36,7 +109,7 @@ description: |-
36109

37110
Required:
38111

39-
- `context` (String)
112+
- `context` (String) One of all, dev, branch-deploy, deploy-preview, production, or branch
40113
- `value` (String, Sensitive)
41114

42115
Optional:
@@ -49,9 +122,21 @@ Optional:
49122

50123
Required:
51124

52-
- `context` (String)
125+
- `context` (String) One of all, dev, branch-deploy, deploy-preview, production, or branch
53126
- `value` (String)
54127

55128
Optional:
56129

57130
- `context_parameter` (String)
131+
132+
## Import
133+
134+
Import is supported using the following syntax:
135+
136+
```shell
137+
# Import a team-level environment variable using the team ID and the environment variable key
138+
terraform import netlify_environment_variable.name 6600abcdef1234567890abcd:ASTRO_DATABASE_FILE
139+
140+
# Import a site-level environment variable using the team ID, the site ID, and the environment variable key
141+
terraform import netlify_environment_variable.name 6600abcdef1234567890abcd:12345667-0000-0000-0000-abcdef012345:ASTRO_DATABASE_FILE
142+
```

0 commit comments

Comments
 (0)