|
| 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 | +} |
0 commit comments