Skip to content

Commit dcade6f

Browse files
committed
Merge branch 'CLOUDP-320243-dev-2.0.0' into CLOUDP-334357
2 parents 622b1a1 + c87e8be commit dcade6f

32 files changed

+1127
-50
lines changed

.changelog/3539.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:new-resource
2+
resource/mongodbatlas_team_project_assignment
3+
```

.changelog/3544.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:new-datasource
2+
data-source/mongodbatlas_team_project_assignment
3+
```

.changelog/3570.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
resource/mongodbatlas_push_based_log_export: Adds `delete_on_create_timeout` attribute to indicate whether to delete the resource if its creation times out
3+
```

.changelog/3571.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
```release-note:enhancement
2+
resource/mongodbatlas_stream_processor: Adds `delete_on_create_timeout` attribute to indicate whether to delete the resource if its creation times out
3+
```
4+
5+
```release-note:enhancement
6+
resource/mongodbatlas_stream_processor: Adds `timeouts` attribute for create operation
7+
```

.github/workflows/acceptance-tests-runner.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ jobs:
323323
- 'internal/service/projectapikey/*.go'
324324
- 'internal/service/rolesorgid/*.go'
325325
- 'internal/service/team/*.go'
326+
- 'internal/service/teamprojectassignment/*.go'
326327
- 'internal/service/thirdpartyintegration/*.go'
327328
encryption:
328329
- 'internal/service/encryptionatrest/*.go'
@@ -616,6 +617,7 @@ jobs:
616617
MONGODB_ATLAS_TEAMS_IDS: ${{ inputs.mongodb_atlas_teams_ids }}
617618
MONGODB_ATLAS_PROJECT_OWNER_ID: ${{ inputs.mongodb_atlas_project_owner_id }}
618619
MONGODB_ATLAS_ORG_ID: ${{ inputs.mongodb_atlas_org_id }}
620+
MONGODB_ATLAS_USERNAME: ${{ vars.MONGODB_ATLAS_USERNAME }}
619621
ACCTEST_PACKAGES: |
620622
./internal/service/clouduserorgassignment
621623
./internal/service/clouduserteamassignment
@@ -710,6 +712,7 @@ jobs:
710712
./internal/service/apikey
711713
./internal/service/rolesorgid
712714
./internal/service/team
715+
./internal/service/teamprojectassignment
713716
./internal/service/thirdpartyintegration
714717
run: make testacc
715718

docs/guides/2.0.0-upgrade-guide.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ The Terraform MongoDB Atlas Provider version 2.0.0 has the following new feature
2121
- `mongodbatlas_online_archive`
2222
- `mongodbatlas_privatelink_endpoint`
2323
- `mongodbatlas_privatelink_endpoint_service`
24+
- `mongodbatlas_push_based_log_export`
2425
- `mongodbatlas_search_deployment`
26+
- `mongodbatlas_stream_processor`
2527

2628
## Breaking Changes
2729

docs/resources/push_based_log_export.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ output "test" {
5959

6060
### Optional
6161

62+
- `delete_on_create_timeout` (Boolean) Indicates whether to delete the resource being created if a timeout is reached when waiting for completion. When set to `true` and timeout occurs, it triggers the deletion and returns immediately without waiting for deletion to complete. When set to `false`, the timeout will not trigger resource deletion. If you suspect a transient error when the value is `true`, wait before retrying to allow resource deletion to finish. Default is `true`.
6263
- `prefix_path` (String) S3 directory in which vector writes in order to store the logs. An empty string denotes the root directory.
6364
- `timeouts` (Attributes) (see [below for nested schema](#nestedatt--timeouts))
6465

docs/resources/stream_processor.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,12 @@ output "stream_processors_results" {
132132

133133
### Optional
134134

135+
- `delete_on_create_timeout` (Boolean) Indicates whether to delete the resource being created if a timeout is reached when waiting for completion. When set to `true` and timeout occurs, it triggers the deletion and returns immediately without waiting for deletion to complete. When set to `false`, the timeout will not trigger resource deletion. If you suspect a transient error when the value is `true`, wait before retrying to allow resource deletion to finish. Default is `true`.
135136
- `options` (Attributes) Optional configuration for the stream processor. (see [below for nested schema](#nestedatt--options))
136137
- `state` (String) The state of the stream processor. Commonly occurring states are 'CREATED', 'STARTED', 'STOPPED' and 'FAILED'. Used to start or stop the Stream Processor. Valid values are `CREATED`, `STARTED` or `STOPPED`. When a Stream Processor is created without specifying the state, it will default to `CREATED` state. When a Stream Processor is updated without specifying the state, it will default to the Previous state.
137138

138139
**NOTE** When a Stream Processor is updated without specifying the state, it is stopped and then restored to previous state upon update completion.
140+
- `timeouts` (Attributes) (see [below for nested schema](#nestedatt--timeouts))
139141

140142
### Read-Only
141143

@@ -158,6 +160,15 @@ Required:
158160
- `connection_name` (String) Name of the connection to write DLQ messages to. Must be an Atlas connection.
159161
- `db` (String) Name of the database to use for the DLQ.
160162

163+
164+
165+
<a id="nestedatt--timeouts"></a>
166+
### Nested Schema for `timeouts`
167+
168+
Optional:
169+
170+
- `create` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).
171+
161172
## Import
162173
Stream Processor resource can be imported using the Project ID, Stream Instance name and Stream Processor name, in the format `INSTANCE_NAME-PROJECT_ID-PROCESSOR_NAME`, e.g.
163174
```

internal/provider/provider.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import (
5050
"github.com/mongodb/terraform-provider-mongodbatlas/internal/service/streaminstance"
5151
"github.com/mongodb/terraform-provider-mongodbatlas/internal/service/streamprivatelinkendpoint"
5252
"github.com/mongodb/terraform-provider-mongodbatlas/internal/service/streamprocessor"
53+
"github.com/mongodb/terraform-provider-mongodbatlas/internal/service/teamprojectassignment"
5354
"github.com/mongodb/terraform-provider-mongodbatlas/version"
5455
)
5556

@@ -463,6 +464,7 @@ func (p *MongodbtlasProvider) DataSources(context.Context) []func() datasource.D
463464
resourcepolicy.PluralDataSource,
464465
clouduserorgassignment.DataSource,
465466
clouduserteamassignment.DataSource,
467+
teamprojectassignment.DataSource,
466468
apikeyprojectassignment.DataSource,
467469
apikeyprojectassignment.PluralDataSource,
468470
}
@@ -491,6 +493,7 @@ func (p *MongodbtlasProvider) Resources(context.Context) []func() resource.Resou
491493
resourcepolicy.Resource,
492494
clouduserorgassignment.Resource,
493495
apikeyprojectassignment.Resource,
496+
teamprojectassignment.Resource,
494497
clouduserteamassignment.Resource,
495498
}
496499
if config.PreviewProviderV2AdvancedCluster() {
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,95 @@
11
package clouduserteamassignment_test
22

33
import (
4+
"fmt"
5+
"os"
46
"testing"
57

8+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
9+
"github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc"
610
"github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/mig"
711
)
812

13+
const (
14+
resourceTeamName = "mongodbatlas_team.test"
15+
resourceTeamAssignmentName = "mongodbatlas_cloud_user_team_assignment.test"
16+
)
17+
918
func TestMigCloudUserTeamAssignmentRS_basic(t *testing.T) {
1019
mig.SkipIfVersionBelow(t, "2.0.0") // when resource 1st released
1120
mig.CreateAndRunTest(t, basicTestCase(t))
1221
}
22+
23+
func TestMigCloudUserTeamAssignmentRS_migrationJourney(t *testing.T) {
24+
var (
25+
orgID = os.Getenv("MONGODB_ATLAS_ORG_ID")
26+
teamName = fmt.Sprintf("team-test-%s", acc.RandomName())
27+
username = os.Getenv("MONGODB_ATLAS_USERNAME")
28+
)
29+
30+
resource.ParallelTest(t, resource.TestCase{
31+
PreCheck: func() { acc.PreCheckBasic(t); acc.PreCheckAtlasUsername(t) },
32+
CheckDestroy: checkDestroy,
33+
Steps: []resource.TestStep{
34+
{
35+
// NOTE: 'usernames' attribute (available v1.39.0, deprecated in v2.0.0) is used in this test in team resource,
36+
// which may be removed in future versions. This could cause the test to break - keep for version tracking.
37+
ExternalProviders: mig.ExternalProviders(),
38+
Config: configTeamWithUsernamesFirst(orgID, teamName, username),
39+
},
40+
{
41+
ProtoV6ProviderFactories: acc.TestAccProviderV6Factories,
42+
Config: configWithTeamAssignmentsSecond(orgID, teamName, username), // expected to see 1 import in the plan
43+
Check: resource.ComposeTestCheckFunc(
44+
resource.TestCheckResourceAttr(resourceTeamName, "name", teamName),
45+
46+
resource.TestCheckResourceAttrSet(resourceTeamAssignmentName, "user_id"),
47+
resource.TestCheckResourceAttr(resourceTeamAssignmentName, "username", username),
48+
),
49+
},
50+
mig.TestStepCheckEmptyPlan(configWithTeamAssignmentsSecond(orgID, teamName, username)),
51+
},
52+
})
53+
}
54+
55+
// Step 1: Original configuration with usernames attribute
56+
func configTeamWithUsernamesFirst(orgID, teamName, username string) string {
57+
return fmt.Sprintf(`
58+
resource "mongodbatlas_team" "test" {
59+
org_id = %[2]q
60+
name = %[3]q
61+
usernames = [%[1]q]
62+
}
63+
`, username, orgID, teamName)
64+
}
65+
66+
// Step 2: Configuration with team assignments using import blocks
67+
68+
// NOTE: Using static resource assignment instead of for_each with multiple usernames
69+
// due to a known limitation in Terraform's acceptance testing framework with indexed resources.
70+
// The actual migration using for_each works correctly (verified locally).
71+
func configWithTeamAssignmentsSecond(orgID, teamName, username string) string {
72+
return fmt.Sprintf(`
73+
resource "mongodbatlas_team" "test" {
74+
org_id = %[1]q
75+
name = %[2]q
76+
}
77+
78+
data "mongodbatlas_team" "test" {
79+
org_id = %[1]q
80+
team_id = mongodbatlas_team.test.team_id
81+
}
82+
83+
resource "mongodbatlas_cloud_user_team_assignment" "test" {
84+
org_id = %[1]q
85+
team_id = mongodbatlas_team.test.team_id
86+
user_id = data.mongodbatlas_team.test.users[0].id
87+
}
88+
89+
import {
90+
to = mongodbatlas_cloud_user_team_assignment.test
91+
id = "%[1]s/${mongodbatlas_team.test.team_id}/${data.mongodbatlas_team.test.users[0].id}"
92+
}
93+
94+
`, orgID, teamName)
95+
}

0 commit comments

Comments
 (0)