Skip to content

Commit a2bfe6a

Browse files
committed
add default team ID/slug in the provider configuration
1 parent 3e3c42f commit a2bfe6a

18 files changed

+263
-91
lines changed

docs/data-sources/site.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ data "netlify_site" "blog" {
3131
### Optional
3232

3333
- `name` (String)
34-
- `team_slug` (String)
34+
- `team_slug` (String) Required if name is specified and a default team was not configured in the provider configuration.
3535

3636
### Read-Only
3737

docs/data-sources/sites.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ data "netlify_sites" "team" {
2222
<!-- schema generated by tfplugindocs -->
2323
## Schema
2424

25-
### Required
25+
### Optional
2626

27-
- `team_slug` (String)
27+
- `team_slug` (String) Required if a default team was not configured in the provider configuration.
2828

2929
### Read-Only
3030

docs/data-sources/team.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ data "netlify_team" "team" {
2929

3030
### Optional
3131

32-
- `slug` (String)
32+
- `id` (String) ID or slug are required if a default team was not configured in the provider configuration.
33+
- `slug` (String) ID or slug are required if a default team was not configured in the provider configuration.
3334

3435
### Read-Only
3536

36-
- `id` (String) The ID of this resource.
3737
- `name` (String)

docs/index.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,21 @@ terraform {
4848
4949
provider "netlify" {
5050
token = var.netlify_api_token
51+
# Optionally, set a default team through its ID or its slug to avoid repeating it.
52+
default_team_slug = "your-team-slug"
5153
}
5254
5355
data "netlify_team" "team" {
54-
slug = "your-team-slug"
56+
# slug coming from the default team
5557
}
5658
5759
data "netlify_site" "blog" {
58-
team_slug = data.netlify_team.team.slug
59-
name = "blog"
60+
# team_slug coming from the default team
61+
name = "blog"
6062
}
6163
6264
resource "netlify_environment_variable" "astro_database_file" {
63-
team_id = data.netlify_team.team.id
65+
# team_id coming from the default team
6466
site_id = data.netlify_site.blog.id
6567
key = "ASTRO_DATABASE_FILE"
6668
values = [
@@ -77,5 +79,7 @@ resource "netlify_environment_variable" "astro_database_file" {
7779

7880
### Optional
7981

82+
- `default_team_id` (String) The default team ID to use for resources that require a team ID or a team slug. Warning: Changing this value may not trigger recreation of resources.
83+
- `default_team_slug` (String) The default team slug to use for resources that require a team ID or a team slug. Warning: Changing this value may not trigger recreation of resources.
8084
- `endpoint` (String) Defaults to: https://api.netlify.com
8185
- `token` (String, Sensitive) Read: https://docs.netlify.com/api/get-started/#authentication , will use the `NETLIFY_API_TOKEN` environment variable if not set.

docs/resources/dns_zone.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ resource "netlify_dns_zone" "example" {
2828
### Required
2929

3030
- `name` (String)
31-
- `team_slug` (String)
31+
32+
### Optional
33+
34+
- `team_slug` (String) Required if a default team was not configured in the provider configuration.
3235

3336
### Read-Only
3437

docs/resources/environment_variable.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,13 @@ resource "netlify_environment_variable" "astro_database_file" {
9191
### Required
9292

9393
- `key` (String)
94-
- `team_id` (String)
9594

9695
### Optional
9796

9897
- `scopes` (Set of String) One or more of builds, functions, runtime, and post-processing
9998
- `secret_values` (Attributes Set) (see [below for nested schema](#nestedatt--secret_values))
10099
- `site_id` (String)
100+
- `team_id` (String) Required if a default team was not configured in the provider configuration.
101101
- `values` (Attributes Set) (see [below for nested schema](#nestedatt--values))
102102

103103
### Read-Only

docs/resources/team_firewall_traffic_rules.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,12 @@ resource "netlify_team_firewall_traffic_rules" "team" {
5151
### Required
5252

5353
- `published` (Attributes) (see [below for nested schema](#nestedatt--published))
54-
- `team_id` (String)
5554
- `unpublished` (Attributes) (see [below for nested schema](#nestedatt--unpublished))
5655

56+
### Optional
57+
58+
- `team_id` (String) Required if a default team was not configured in the provider configuration.
59+
5760
### Read-Only
5861

5962
- `last_updated` (String)

examples/misc/dns/main.tf

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,12 @@ terraform {
88
}
99

1010
# `token` comes from NETLIFY_API_TOKEN, but can be specified with a Terraform variable
11-
provider "netlify" {}
12-
13-
# data "netlify_team" "current" {
14-
# slug = "ramon-test-1"
15-
# }
11+
provider "netlify" {
12+
default_team_slug = "ramon-test-1"
13+
}
1614

1715
resource "netlify_dns_zone" "example" {
18-
team_slug = "ramon-test-1" // data.netlify_team.current.slug
19-
name = "example-tf-test-test.com"
16+
name = "example-tf-test-test.com"
2017
lifecycle {
2118
prevent_destroy = true
2219
}

examples/misc/env_vars/main.tf

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ terraform {
88
}
99

1010
# `token` comes from NETLIFY_API_TOKEN, but can be specified with a Terraform variable
11-
provider "netlify" {}
11+
provider "netlify" {
12+
default_team_slug = "ramon-test-1"
13+
}
1214

1315
data "netlify_team" "current" {
1416
slug = "ramon-test-1"
@@ -31,6 +33,17 @@ resource "netlify_environment_variable" "woof" {
3133
]
3234
}
3335

36+
resource "netlify_environment_variable" "woof2" {
37+
site_id = data.netlify_site.platform_test.id
38+
key = "WOOF2"
39+
values = [
40+
{
41+
value = "dogs are here",
42+
context = "all",
43+
}
44+
]
45+
}
46+
3447
resource "netlify_environment_variable" "meow" {
3548
team_id = data.netlify_team.current.id
3649
site_id = data.netlify_site.platform_test.id

examples/misc/site_data_sources/main.tf

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,25 @@ terraform {
88
}
99

1010
# `token` comes from NETLIFY_API_TOKEN, but can be specified with a Terraform variable
11-
provider "netlify" {}
12-
13-
data "netlify_team" "current" {
14-
slug = "ramon-test-1"
11+
provider "netlify" {
12+
default_team_slug = "ramon-test-1"
1513
}
1614

15+
data "netlify_team" "current" {}
16+
1717
data "netlify_site" "platform_test" {
18-
team_slug = data.netlify_team.current.slug
19-
name = "platform-test-1"
18+
name = "platform-test-1"
2019
}
2120

22-
data "netlify_sites" "all" {
21+
data "netlify_sites" "mine" {}
22+
23+
data "netlify_sites" "testing" {
2324
team_slug = "netlify-testing"
2425
}
2526

2627
output "sites" {
2728
value = [
28-
for site in data.netlify_sites.all.sites : site
29+
for site in data.netlify_sites.testing.sites : site
2930
if site.custom_domain != ""
3031
]
3132
}

0 commit comments

Comments
 (0)