@@ -35,38 +35,18 @@ func TestAccEncryptionAtRestPrivateEndpoint_Azure_basic(t *testing.T) {
35
35
36
36
func TestAccEncryptionAtRestPrivateEndpoint_createTimeoutWithDeleteOnCreate (t * testing.T ) {
37
37
var (
38
- projectID = os .Getenv ("MONGODB_ATLAS_PROJECT_EAR_PE_AWS_ID" )
39
38
createTimeout = "1s"
40
39
deleteOnCreateTimeout = true
41
- awsKms = admin.AWSKMSConfiguration {
42
- Enabled : conversion .Pointer (true ),
43
- CustomerMasterKeyID : conversion .StringPtr (os .Getenv ("AWS_CUSTOMER_MASTER_KEY_ID" )),
44
- Region : conversion .StringPtr (conversion .AWSRegionToMongoDBRegion (os .Getenv ("AWS_REGION" ))),
45
- RoleId : conversion .StringPtr (os .Getenv ("AWS_EAR_ROLE_ID" )),
46
- RequirePrivateNetworking : conversion .Pointer (false ),
47
- }
48
- awsKmsPrivateNetworking = admin.AWSKMSConfiguration {
49
- Enabled : conversion .Pointer (true ),
50
- CustomerMasterKeyID : conversion .StringPtr (os .Getenv ("AWS_CUSTOMER_MASTER_KEY_ID" )),
51
- Region : conversion .StringPtr (conversion .AWSRegionToMongoDBRegion (os .Getenv ("AWS_REGION" ))),
52
- RoleId : conversion .StringPtr (os .Getenv ("AWS_EAR_ROLE_ID" )),
53
- RequirePrivateNetworking : conversion .Pointer (true ),
54
- }
55
- region = conversion .AWSRegionToMongoDBRegion (os .Getenv ("AWS_REGION" ))
40
+ region = conversion .AWSRegionToMongoDBRegion (os .Getenv ("AWS_REGION" ))
41
+ // Create encryption at rest configuration outside of test configuration to avoid cleanup issues
42
+ projectID = acc .EncryptionAtRestExecution (t )
56
43
)
57
44
resource .ParallelTest (t , resource.TestCase {
58
45
PreCheck : func () { acc .PreCheckEncryptionAtRestEnvAWS (t ) },
59
46
ProtoV6ProviderFactories : acc .TestAccProviderV6Factories ,
60
47
Steps : []resource.TestStep {
61
48
{
62
- Config : acc .ConfigAwsKms (projectID , & awsKms , false , true , false ),
63
- Check : resource .ComposeAggregateTestCheckFunc (
64
- resource .TestCheckResourceAttr (earResourceName , "aws_kms_config.0.enabled" , "true" ),
65
- resource .TestCheckResourceAttr (earResourceName , "aws_kms_config.0.require_private_networking" , "false" ),
66
- ),
67
- },
68
- {
69
- Config : configAWSBasicWithTimeout (projectID , & awsKmsPrivateNetworking , region , acc .TimeoutConfig (& createTimeout , nil , nil , true ), & deleteOnCreateTimeout ),
49
+ Config : configEARPrivateEndpointWithTimeout (projectID , region , acc .TimeoutConfig (& createTimeout , nil , nil , true ), & deleteOnCreateTimeout ),
70
50
ExpectError : regexp .MustCompile ("will run cleanup because delete_on_create_timeout is true" ),
71
51
},
72
52
},
@@ -388,6 +368,30 @@ func configAWSBasicWithTimeout(projectID string, awsKms *admin.AWSKMSConfigurati
388
368
return config
389
369
}
390
370
371
+ func configEARPrivateEndpointWithTimeout (projectID , region , timeoutConfig string , deleteOnCreateTimeout * bool ) string {
372
+ deleteOnCreateTimeoutConfig := ""
373
+ if deleteOnCreateTimeout != nil {
374
+ deleteOnCreateTimeoutConfig = fmt .Sprintf (`
375
+ delete_on_create_timeout = %[1]t
376
+ ` , * deleteOnCreateTimeout )
377
+ }
378
+
379
+ config := fmt .Sprintf (`
380
+ resource "mongodbatlas_encryption_at_rest_private_endpoint" "test" {
381
+ project_id = %[1]q
382
+ cloud_provider = "AWS"
383
+ region_name = %[2]q
384
+ %[3]s
385
+ %[4]s
386
+ }
387
+
388
+ %[5]s
389
+
390
+ ` , projectID , region , deleteOnCreateTimeoutConfig , timeoutConfig , configDS ())
391
+
392
+ return config
393
+ }
394
+
391
395
func configDS () string {
392
396
return `
393
397
data "mongodbatlas_encryption_at_rest_private_endpoint" "test" {
0 commit comments