Skip to content

Commit e01a01f

Browse files
authored
feat: add support for project_id in provider (#601)
1 parent 3b64bdc commit e01a01f

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

docs/index.md

+4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ provider "scaleway" {
2929
access_key = "<SCALEWAY-ACCESS-KEY>"
3030
secret_key = "<SCALEWAY-SECRET-KEY>"
3131
organization_id = "<SCALEWAY-ORGANIZATION-ID>"
32+
project_id = "<SCALEWAY-PROJECT-ID>"
3233
zone = "fr-par-1"
3334
region = "fr-par"
3435
}
@@ -148,6 +149,9 @@ in this priority order.
148149
the `SCW_DEFAULT_ORGANIZATION_ID` [environment variable](https://github.com/scaleway/scaleway-sdk-go/blob/master/scw/README.md#environment-variables), or via a [shared configuration file](https://github.com/scaleway/scaleway-sdk-go/blob/master/scw/README.md#scaleway-config),
149150
in this priority order.
150151

152+
- `project_id` - (Optional) The project ID that will be used as default value for all resources.
153+
It can also be sourced from the `SCW_DEFAULT_PROJECT_ID` [environment variable](https://github.com/scaleway/scaleway-sdk-go/blob/master/scw/README.md#environment-variables), or via a [shared configuration file](https://github.com/scaleway/scaleway-sdk-go/blob/master/scw/README.md#scaleway-config), in this priority order.
154+
151155
- `region` - (Optional) The [region](./guides/regions_and_zones.md#regions) that will be used as default value for all resources. It can also be sourced from
152156
the `SCW_DEFAULT_REGION` [environment variable](https://github.com/scaleway/scaleway-sdk-go/blob/master/scw/README.md#environment-variables), or via a [shared configuration file](https://github.com/scaleway/scaleway-sdk-go/blob/master/scw/README.md#scaleway-config),
153157
in this priority order.

scaleway/provider.go

+15
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,21 @@ func Provider() func() *schema.Provider {
126126
}),
127127
ValidateFunc: validationUUID(),
128128
},
129+
"project_id": {
130+
Type: schema.TypeString,
131+
Optional: true, // To allow user to use organization instead of project
132+
Description: "The Scaleway project ID.",
133+
DefaultFunc: schema.SchemaDefaultFunc(func() (interface{}, error) {
134+
if envProfile.DefaultProjectID != nil {
135+
return *envProfile.DefaultProjectID, nil
136+
}
137+
if activeProfile != nil && activeProfile.DefaultProjectID != nil {
138+
return *activeProfile.DefaultProjectID, nil
139+
}
140+
return nil, nil
141+
}),
142+
ValidateFunc: validationUUID(),
143+
},
129144
"region": {
130145
Type: schema.TypeString,
131146
Optional: true,

0 commit comments

Comments
 (0)