Skip to content

Commit a36148b

Browse files
authored
Merge branch 'master' into feat/support-resource-identity
2 parents 39a3059 + 7e15b9d commit a36148b

File tree

96 files changed

+52831
-38228
lines changed

Some content is hidden

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

96 files changed

+52831
-38228
lines changed

.github/workflows/acceptance-tests.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,14 @@ jobs:
110110
echo "Pattern: $SKIP_PATTERN"
111111
echo ""
112112
echo "Tests that will be skipped:"
113-
go test -list=. ./internal/services/${{ matrix.products }} | grep -E "$SKIP_PATTERN" || true
113+
go tool gotestsum --format github-actions -- -list=. ./internal/services/${{ matrix.products }} | grep -E "$SKIP_PATTERN" || true
114114
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
115115
echo ""
116116
117-
go test -v ./internal/services/${{ matrix.products }} -timeout=2h -skip="$SKIP_PATTERN"
117+
go tool gotestsum --format github-actions -- -v ./internal/services/${{ matrix.products }} -timeout=2h -skip="$SKIP_PATTERN"
118118
TEST_RESULT=$?
119119
else
120-
go test -v ./internal/services/${{ matrix.products }} -timeout=2h
120+
go tool gotestsum --format github-actions -- -v ./internal/services/${{ matrix.products }} -timeout=2h
121121
TEST_RESULT=$?
122122
fi
123123
@@ -155,7 +155,7 @@ jobs:
155155
- name: Install Terraform
156156
uses: hashicorp/setup-terraform@v3
157157
- name: Run scwconfig tests
158-
run: go test -v ./internal/services/scwconfig -timeout=2m
158+
run: go tool gotestsum --format github-actions -- ./internal/services/scwconfig -timeout=2m
159159
env:
160160
TF_LOG: DEBUG
161161
TF_ACC: 1

.github/workflows/nightly.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
with:
6161
go-version: 1.24.0
6262
- name: Run Acceptance Tests
63-
run: go test -v ./internal/services/${{ matrix.products }} -timeout=4h
63+
run: go tool gotestsum --format github-actions -- -v ./internal/services/${{ matrix.products }} -timeout=4h
6464
env:
6565
TF_LOG: DEBUG
6666
# https://www.terraform.io/docs/extend/testing/acceptance-tests/index.html#running-acceptance-tests

docs/resources/mongodb_user.md

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
---
2+
subcategory: "MongoDB®"
3+
page_title: "Scaleway: scaleway_mongodb_user"
4+
---
5+
6+
# Resource: scaleway_mongodb_user
7+
8+
Creates and manages Scaleway MongoDB® users.
9+
For more information refer to the [product documentation](https://www.scaleway.com/en/docs/managed-mongodb-databases/).
10+
11+
## Example Usage
12+
13+
### Basic
14+
15+
```terraform
16+
resource "scaleway_mongodb_instance" "main" {
17+
name = "test-mongodb-user"
18+
version = "7.0.12"
19+
node_type = "MGDB-PLAY2-NANO"
20+
node_number = 1
21+
user_name = "initial_user"
22+
password = "initial_password123"
23+
volume_size_in_gb = 5
24+
}
25+
26+
resource "scaleway_mongodb_user" "main" {
27+
instance_id = scaleway_mongodb_instance.main.id
28+
name = "my_user"
29+
password = "my_password123"
30+
31+
roles {
32+
role = "read_write"
33+
database_name = "my_database"
34+
}
35+
}
36+
```
37+
38+
### With Multiple Users
39+
40+
```terraform
41+
resource "scaleway_mongodb_instance" "main" {
42+
name = "test-mongodb-multi-user"
43+
version = "7.0.12"
44+
node_type = "MGDB-PLAY2-NANO"
45+
node_number = 1
46+
user_name = "admin_user"
47+
password = "admin_password123"
48+
volume_size_in_gb = 5
49+
}
50+
51+
resource "scaleway_mongodb_user" "app_user" {
52+
instance_id = scaleway_mongodb_instance.main.id
53+
name = "app_user"
54+
password = "app_password123"
55+
56+
roles {
57+
role = "read_write"
58+
database_name = "app_database"
59+
}
60+
61+
roles {
62+
role = "read"
63+
database_name = "logs_database"
64+
}
65+
}
66+
67+
resource "scaleway_mongodb_user" "admin_user" {
68+
instance_id = scaleway_mongodb_instance.main.id
69+
name = "admin_user"
70+
password = "admin_password123"
71+
72+
roles {
73+
role = "db_admin"
74+
database_name = "admin"
75+
}
76+
77+
roles {
78+
role = "read"
79+
any_database = true
80+
}
81+
}
82+
```
83+
84+
## Argument Reference
85+
86+
The following arguments are supported:
87+
88+
- `instance_id` - (Required) The ID of the MongoDB® instance.
89+
90+
- `name` - (Required) The name of the MongoDB® user.
91+
92+
- `password` - (Required) The password of the MongoDB® user.
93+
94+
- `roles` - (Optional) List of roles assigned to the user. Each role block supports:
95+
- `role` - (Required) The role name. Valid values are `read`, `read_write`, `db_admin`, `sync`.
96+
- `database_name` - (Optional) The database name for the role. Cannot be used with `any_database`.
97+
- `any_database` - (Optional) Apply the role to all databases. Cannot be used with `database_name`.
98+
99+
- `region` - (Defaults to [provider](../index.md#region) `region`) The [region](../guides/regions_and_zones.md#regions) in which the MongoDB® user should be created.
100+
101+
## Attributes Reference
102+
103+
In addition to all arguments above, the following attributes are exported:
104+
105+
- `id` - The ID of the MongoDB® user.
106+
107+
- `roles` - The list of roles assigned to the user.
108+
109+
## Import
110+
111+
MongoDB® users can be imported using the `{region}/{instance_id}/{name}`, e.g.
112+
113+
```bash
114+
terraform import scaleway_mongodb_user.main fr-par/11111111-1111-1111-1111-111111111111/my_user
115+
```

go.mod

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ require (
6464
github.com/bflad/tfproviderdocs v0.12.1 // indirect
6565
github.com/bflad/tfproviderlint v0.31.0 // indirect
6666
github.com/bgentry/speakeasy v0.1.0 // indirect
67+
github.com/bitfield/gotestdox v0.2.2 // indirect
6768
github.com/bmatcuk/doublestar v1.3.4 // indirect
6869
github.com/bmatcuk/doublestar/v4 v4.8.1 // indirect
6970
github.com/cloudflare/circl v1.6.1 // indirect
@@ -72,15 +73,17 @@ require (
7273
github.com/containerd/log v0.1.0 // indirect
7374
github.com/davecgh/go-spew v1.1.1 // indirect
7475
github.com/distribution/reference v0.5.0 // indirect
76+
github.com/dnephin/pflag v1.0.7 // indirect
7577
github.com/docker/go-connections v0.4.0 // indirect
7678
github.com/docker/go-units v0.4.0 // indirect
7779
github.com/fatih/color v1.18.0 // indirect
7880
github.com/felixge/httpsnoop v1.0.4 // indirect
79-
github.com/fsnotify/fsnotify v1.5.4 // indirect
81+
github.com/fsnotify/fsnotify v1.8.0 // indirect
8082
github.com/go-logr/logr v1.4.2 // indirect
8183
github.com/go-logr/stdr v1.2.2 // indirect
8284
github.com/gogo/protobuf v1.3.2 // indirect
8385
github.com/golang/protobuf v1.5.4 // indirect
86+
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
8487
github.com/gookit/color v1.5.1 // indirect
8588
github.com/hashicorp/cli v1.1.7 // indirect
8689
github.com/hashicorp/errwrap v1.1.0 // indirect
@@ -159,6 +162,7 @@ require (
159162
golang.org/x/net v0.42.0 // indirect
160163
golang.org/x/sync v0.16.0 // indirect
161164
golang.org/x/sys v0.35.0 // indirect
165+
golang.org/x/term v0.34.0 // indirect
162166
golang.org/x/text v0.28.0 // indirect
163167
golang.org/x/time v0.3.0 // indirect
164168
golang.org/x/tools v0.35.0 // indirect
@@ -170,7 +174,7 @@ require (
170174
gopkg.in/ini.v1 v1.66.4 // indirect
171175
gopkg.in/yaml.v2 v2.4.0 // indirect
172176
gopkg.in/yaml.v3 v3.0.1 // indirect
173-
gotest.tools/v3 v3.0.3 // indirect
177+
gotest.tools/gotestsum v1.12.3 // indirect
174178
)
175179

176180
tool (
@@ -179,4 +183,5 @@ tool (
179183
github.com/bflad/tfproviderlint/cmd/tfproviderlintx
180184
github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs
181185
github.com/katbyte/terrafmt
186+
gotest.tools/gotestsum
182187
)

go.sum

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ github.com/bflad/tfproviderlint v0.31.0 h1:9N/dUzFARsTpAQOjdZzIWnHKMzQc7UDDEYrSN
119119
github.com/bflad/tfproviderlint v0.31.0/go.mod h1:yZQdJs4uobBIgVHt1Tv5OpHhgM8fwh29OgxL/La5BFs=
120120
github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY=
121121
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
122+
github.com/bitfield/gotestdox v0.2.2 h1:x6RcPAbBbErKLnapz1QeAlf3ospg8efBsedU93CDsnE=
123+
github.com/bitfield/gotestdox v0.2.2/go.mod h1:D+gwtS0urjBrzguAkTM2wodsTQYFHdpx8eqRJ3N+9pY=
122124
github.com/bmatcuk/doublestar v1.3.4 h1:gPypJ5xD31uhX6Tf54sDPUOBXTqKH4c9aPY66CyQrS0=
123125
github.com/bmatcuk/doublestar v1.3.4/go.mod h1:wiQtGV+rzVYxB7WIlirSN++5HPtPlXEo9MEoZQC/PmE=
124126
github.com/bmatcuk/doublestar/v4 v4.8.1 h1:54Bopc5c2cAvhLRAzqOGCYHYyhcDHsFF4wWIR5wKP38=
@@ -154,6 +156,8 @@ github.com/distribution/reference v0.5.0 h1:/FUIFXtfc/x2gpa5/VGfiGLuOIdYa1t65IKK
154156
github.com/distribution/reference v0.5.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E=
155157
github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI=
156158
github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ=
159+
github.com/dnephin/pflag v1.0.7 h1:oxONGlWxhmUct0YzKTgrpQv9AUA1wtPBn7zuSjJqptk=
160+
github.com/dnephin/pflag v1.0.7/go.mod h1:uxE91IoWURlOiTUIA8Mq5ZZkAv3dPUfZNaT80Zm7OQE=
157161
github.com/docker/docker v28.3.3+incompatible h1:Dypm25kh4rmk49v1eiVbsAtpAsYURjYkaKubwuBdxEI=
158162
github.com/docker/docker v28.3.3+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
159163
github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ=
@@ -178,8 +182,8 @@ github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2
178182
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
179183
github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE=
180184
github.com/frankban/quicktest v1.14.3/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps=
181-
github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI=
182-
github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU=
185+
github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M=
186+
github.com/fsnotify/fsnotify v1.8.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
183187
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI=
184188
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic=
185189
github.com/go-git/go-billy/v5 v5.6.2 h1:6Q86EsPXMa7c3YZ3aLAQsMA0VlWmy43r6FHqa/UNbRM=
@@ -259,6 +263,8 @@ github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLe
259263
github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
260264
github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
261265
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
266+
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4=
267+
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ=
262268
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
263269
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
264270
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
@@ -690,7 +696,6 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc
690696
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
691697
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
692698
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
693-
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
694699
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
695700
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
696701
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
@@ -906,9 +911,11 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
906911
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
907912
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
908913
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
914+
gotest.tools/gotestsum v1.12.3 h1:jFwenGJ0RnPkuKh2VzAYl1mDOJgbhobBDeL2W1iEycs=
915+
gotest.tools/gotestsum v1.12.3/go.mod h1:Y1+e0Iig4xIRtdmYbEV7K7H6spnjc1fX4BOuUhWw2Wk=
909916
gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk=
910-
gotest.tools/v3 v3.0.3 h1:4AuOwCGf4lLR9u3YOe2awrHygurzhO/HeQ6laiA6Sx0=
911-
gotest.tools/v3 v3.0.3/go.mod h1:Z7Lb0S5l+klDB31fvDQX8ss/FlKDxtlFlw3Oa8Ymbl8=
917+
gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q=
918+
gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA=
912919
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
913920
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
914921
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

internal/provider/provider.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ func Provider(config *Config) plugin.ProviderFunc {
215215
"scaleway_mnq_sqs_queue": mnq.ResourceSQSQueue(),
216216
"scaleway_mongodb_instance": mongodb.ResourceInstance(),
217217
"scaleway_mongodb_snapshot": mongodb.ResourceSnapshot(),
218+
"scaleway_mongodb_user": mongodb.ResourceUser(),
218219
"scaleway_object": object.ResourceObject(),
219220
"scaleway_object_bucket": object.ResourceBucket(),
220221
"scaleway_object_bucket_acl": object.ResourceBucketACL(),

internal/services/account/project_test.go

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
package account_test
22

33
import (
4+
"context"
45
"fmt"
56
"testing"
7+
"time"
68

9+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
710
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
811
"github.com/hashicorp/terraform-plugin-testing/terraform"
912
accountSDK "github.com/scaleway/scaleway-sdk-go/api/account/v3"
@@ -12,6 +15,8 @@ import (
1215
"github.com/scaleway/terraform-provider-scaleway/v2/internal/services/account"
1316
)
1417

18+
var DestroyWaitTimeout = 3 * time.Minute
19+
1520
func TestAccProject_Basic(t *testing.T) {
1621
tt := acctest.NewTestTools(t)
1722
defer tt.Cleanup()
@@ -101,29 +106,31 @@ func isProjectPresent(tt *acctest.TestTools, name string) resource.TestCheckFunc
101106
}
102107

103108
func isProjectDestroyed(tt *acctest.TestTools) resource.TestCheckFunc {
104-
return func(s *terraform.State) error {
105-
for _, rs := range s.RootModule().Resources {
106-
if rs.Type != "scaleway_account_project" {
107-
continue
108-
}
109-
110-
accountAPI := account.NewProjectAPI(tt.Meta)
109+
return func(state *terraform.State) error {
110+
ctx := context.Background()
111+
api := account.NewProjectAPI(tt.Meta)
111112

112-
_, err := accountAPI.GetProject(&accountSDK.ProjectAPIGetProjectRequest{
113-
ProjectID: rs.Primary.ID,
114-
})
113+
return retry.RetryContext(ctx, DestroyWaitTimeout, func() *retry.RetryError {
114+
for _, rs := range state.RootModule().Resources {
115+
if rs.Type != "scaleway_account_project" {
116+
continue
117+
}
115118

116-
// If no error resource still exist
117-
if err == nil {
118-
return fmt.Errorf("resource %s(%s) still exist", rs.Type, rs.Primary.ID)
119-
}
119+
_, err := api.GetProject(&accountSDK.ProjectAPIGetProjectRequest{
120+
ProjectID: rs.Primary.ID,
121+
})
120122

121-
// Unexpected api error we return it
122-
if !httperrors.Is404(err) {
123-
return err
123+
switch {
124+
case err == nil:
125+
return retry.RetryableError(fmt.Errorf("resource %s(%s) still exists", rs.Type, rs.Primary.ID))
126+
case httperrors.Is404(err):
127+
continue
128+
default:
129+
return retry.NonRetryableError(err)
130+
}
124131
}
125-
}
126132

127-
return nil
133+
return nil
134+
})
128135
}
129136
}

0 commit comments

Comments
 (0)