Skip to content

Commit 47469dd

Browse files
fix: define ConfigMode for computed nest block attribute in privatelink_endpoint_service to support tf 1.0.8 (#1629)
* fix: define ConfigMode for computed nest block attribute in privatelink_endpoint_service to support tf 1.0.8 * move configuration of providers from step to general test case to avoid duplication
1 parent 9ee2da8 commit 47469dd

3 files changed

+92
-4
lines changed

mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ func resourceMongoDBAtlasPrivateEndpointServiceLink() *schema.Resource {
103103
Optional: true,
104104
Computed: true,
105105
ConflictsWith: []string{"private_endpoint_ip_address"},
106+
ConfigMode: schema.SchemaConfigModeAttr,
106107
Elem: &schema.Resource{
107108
Schema: map[string]*schema.Schema{
108109
"status": {
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
package mongodbatlas
2+
3+
import (
4+
"fmt"
5+
"os"
6+
"testing"
7+
8+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
9+
"github.com/hashicorp/terraform-plugin-testing/plancheck"
10+
)
11+
12+
func TestAccMigrationNetworkRSPrivateLinkEndpointService_Complete(t *testing.T) {
13+
SkipTestExtCred(t)
14+
var (
15+
resourceSuffix = "test"
16+
resourceName = fmt.Sprintf("mongodbatlas_privatelink_endpoint_service.%s", resourceSuffix)
17+
18+
awsAccessKey = os.Getenv("AWS_ACCESS_KEY_ID")
19+
awsSecretKey = os.Getenv("AWS_SECRET_ACCESS_KEY")
20+
21+
providerName = "AWS"
22+
projectID = os.Getenv("MONGODB_ATLAS_PROJECT_ID")
23+
region = os.Getenv("AWS_REGION")
24+
vpcID = os.Getenv("AWS_VPC_ID")
25+
subnetID = os.Getenv("AWS_SUBNET_ID")
26+
securityGroupID = os.Getenv("AWS_SECURITY_GROUP_ID")
27+
lastVersionConstraint = os.Getenv("MONGODB_ATLAS_LAST_VERSION")
28+
)
29+
30+
resource.Test(t, resource.TestCase{
31+
PreCheck: func() { testAccPreCheck(t); testCheckAwsEnv(t) },
32+
CheckDestroy: testAccCheckMongoDBAtlasPrivateLinkEndpointServiceDestroy,
33+
Steps: []resource.TestStep{
34+
{
35+
ExternalProviders: map[string]resource.ExternalProvider{
36+
"mongodbatlas": {
37+
VersionConstraint: lastVersionConstraint,
38+
Source: "mongodb/mongodbatlas",
39+
},
40+
"aws": {
41+
VersionConstraint: "5.1.0",
42+
Source: "hashicorp/aws",
43+
},
44+
},
45+
Config: testAccMongoDBAtlasPrivateLinkEndpointServiceConfigCompleteAWS(
46+
awsAccessKey, awsSecretKey, projectID, providerName, region, vpcID, subnetID, securityGroupID, resourceSuffix,
47+
),
48+
Check: resource.ComposeTestCheckFunc(
49+
testAccCheckMongoDBAtlasPrivateLinkEndpointServiceExists(resourceName),
50+
resource.TestCheckResourceAttrSet(resourceName, "project_id"),
51+
resource.TestCheckResourceAttrSet(resourceName, "private_link_id"),
52+
resource.TestCheckResourceAttrSet(resourceName, "endpoint_service_id"),
53+
),
54+
},
55+
{
56+
ExternalProviders: map[string]resource.ExternalProvider{
57+
"aws": {
58+
VersionConstraint: "5.1.0",
59+
Source: "hashicorp/aws",
60+
},
61+
},
62+
ProtoV6ProviderFactories: testAccProviderV6Factories,
63+
Config: testAccMongoDBAtlasPrivateLinkEndpointServiceConfigCompleteAWS(
64+
awsAccessKey, awsSecretKey, projectID, providerName, region, vpcID, subnetID, securityGroupID, resourceSuffix,
65+
),
66+
ConfigPlanChecks: resource.ConfigPlanChecks{
67+
PostApplyPreRefresh: []plancheck.PlanCheck{
68+
DebugPlan(),
69+
},
70+
},
71+
PlanOnly: true,
72+
},
73+
},
74+
})
75+
}

mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service_test.go

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,14 @@ func TestAccNetworkRSPrivateLinkEndpointServiceAWS_Complete(t *testing.T) {
2929

3030
resource.Test(t, resource.TestCase{
3131
PreCheck: func() { testAccPreCheck(t); testCheckAwsEnv(t) },
32-
ProtoV6ProviderFactories: testAccProviderV6Factories,
3332
CheckDestroy: testAccCheckMongoDBAtlasPrivateLinkEndpointServiceDestroy,
33+
ProtoV6ProviderFactories: testAccProviderV6Factories,
34+
ExternalProviders: map[string]resource.ExternalProvider{
35+
"aws": {
36+
VersionConstraint: "5.1.0",
37+
Source: "hashicorp/aws",
38+
},
39+
},
3440
Steps: []resource.TestStep{
3541
{
3642
Config: testAccMongoDBAtlasPrivateLinkEndpointServiceConfigCompleteAWS(
@@ -66,8 +72,14 @@ func TestAccNetworkRSPrivateLinkEndpointServiceAWS_import(t *testing.T) {
6672

6773
resource.Test(t, resource.TestCase{
6874
PreCheck: func() { testAccPreCheck(t); testCheckAwsEnv(t) },
69-
ProtoV6ProviderFactories: testAccProviderV6Factories,
7075
CheckDestroy: testAccCheckMongoDBAtlasPrivateLinkEndpointServiceDestroy,
76+
ProtoV6ProviderFactories: testAccProviderV6Factories,
77+
ExternalProviders: map[string]resource.ExternalProvider{
78+
"aws": {
79+
VersionConstraint: "5.1.0",
80+
Source: "hashicorp/aws",
81+
},
82+
},
7183
Steps: []resource.TestStep{
7284
{
7385
Config: testAccMongoDBAtlasPrivateLinkEndpointServiceConfigCompleteAWS(
@@ -106,7 +118,7 @@ func testAccCheckMongoDBAtlasPrivateLinkEndpointServiceImportStateIDFunc(resourc
106118

107119
func testAccCheckMongoDBAtlasPrivateLinkEndpointServiceExists(resourceName string) resource.TestCheckFunc {
108120
return func(s *terraform.State) error {
109-
conn := testAccProviderSdkV2.Meta().(*MongoDBClient).Atlas
121+
conn := testMongoDBClient.(*MongoDBClient).Atlas
110122

111123
rs, ok := s.RootModule().Resources[resourceName]
112124
if !ok {
@@ -129,7 +141,7 @@ func testAccCheckMongoDBAtlasPrivateLinkEndpointServiceExists(resourceName strin
129141
}
130142

131143
func testAccCheckMongoDBAtlasPrivateLinkEndpointServiceDestroy(s *terraform.State) error {
132-
conn := testAccProviderSdkV2.Meta().(*MongoDBClient).Atlas
144+
conn := testMongoDBClient.(*MongoDBClient).Atlas
133145

134146
for _, rs := range s.RootModule().Resources {
135147
if rs.Type != "mongodbatlas_privatelink_endpoint_service" {

0 commit comments

Comments
 (0)