Skip to content

Commit

Permalink
fixed network peering resource for Azure (#513)
Browse files Browse the repository at this point in the history
  • Loading branch information
abner-dou committed Aug 17, 2021
1 parent 1634562 commit 1cb0755
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 13 deletions.
7 changes: 0 additions & 7 deletions mongodbatlas/resource_mongodbatlas_network_peering.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"

matlas "go.mongodb.org/atlas/mongodbatlas"
)

Expand Down Expand Up @@ -208,11 +207,6 @@ func resourceMongoDBAtlasNetworkPeeringCreate(ctx context.Context, d *schema.Res
}

if providerName == "AZURE" {
atlasCidrBlock, ok := d.GetOk("atlas_cidr_block")
if !ok {
return diag.FromErr(errors.New("`atlas_cidr_block` must be set when `provider_name` is `AZURE`"))
}

azureDirectoryID, ok := d.GetOk("azure_directory_id")
if !ok {
return diag.FromErr(errors.New("`azure_directory_id` must be set when `provider_name` is `AZURE`"))
Expand All @@ -233,7 +227,6 @@ func resourceMongoDBAtlasNetworkPeeringCreate(ctx context.Context, d *schema.Res
return diag.FromErr(errors.New("`vnet_name` must be set when `provider_name` is `AZURE`"))
}

peerRequest.AtlasCIDRBlock = atlasCidrBlock.(string)
peerRequest.AzureDirectoryID = azureDirectoryID.(string)
peerRequest.AzureSubscriptionID = azureSubscriptionID.(string)
peerRequest.ResourceGroupName = resourceGroupName.(string)
Expand Down
3 changes: 1 addition & 2 deletions mongodbatlas/resource_mongodbatlas_network_peering_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func TestAccResourceMongoDBAtlasNetworkPeering_basicAzure(t *testing.T) {
ImportStateIdFunc: testAccCheckMongoDBAtlasNetworkPeeringImportStateIDFunc(resourceName),
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"atlas_cidr_block", "container_id"},
ImportStateVerifyIgnore: []string{"container_id"},
},
},
})
Expand Down Expand Up @@ -288,7 +288,6 @@ func testAccMongoDBAtlasNetworkPeeringConfigAzure(projectID, providerName, direc
resource "mongodbatlas_network_peering" "test" {
project_id = "%[1]s"
atlas_cidr_block = "192.168.0.0/21"
container_id = mongodbatlas_network_container.test.container_id
provider_name = "%[2]s"
azure_directory_id = "%[3]s"
Expand Down
1 change: 0 additions & 1 deletion website/docs/d/network_peering.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ In addition to all arguments above, the following attributes are exported:
* `vpc_id` - Unique identifier of the peer VPC.
* `error_state_name` - Error state, if any. The VPC peering connection error state value can be one of the following: `REJECTED`, `EXPIRED`, `INVALID_ARGUMENT`.
* `status_name` - The VPC peering connection status value can be one of the following: `INITIATING`, `PENDING_ACCEPTANCE`, `FAILED`, `FINALIZING`, `AVAILABLE`, `TERMINATING`.
* `atlas_cidr_block` - Unique identifier for an Azure AD directory.
* `azure_directory_id` - Unique identifier for an Azure AD directory.
* `azure_subscription_id` - Unique identifer of the Azure subscription in which the VNet resides.
* `resource_group_name` - Name of your Azure resource group.
Expand Down
1 change: 0 additions & 1 deletion website/docs/d/network_peerings.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ In addition to all arguments above, the following attributes are exported:
* `vpc_id` - Unique identifier of the peer VPC.
* `error_state_name` - Error state, if any. The VPC peering connection error state value can be one of the following: `REJECTED`, `EXPIRED`, `INVALID_ARGUMENT`.
* `status_name` - The VPC peering connection status value can be one of the following: `INITIATING`, `PENDING_ACCEPTANCE`, `FAILED`, `FINALIZING`, `AVAILABLE`, `TERMINATING`.
* `atlas_cidr_block` - Unique identifier for an Azure AD directory.
* `azure_directory_id` - Unique identifier for an Azure AD directory.
* `azure_subscription_id` - Unique identifer of the Azure subscription in which the VNet resides.
* `resource_group_name` - Name of your Azure resource group.
Expand Down
2 changes: 0 additions & 2 deletions website/docs/r/network_peering.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ resource "mongodbatlas_network_peering" "test" {
azure_subscription_id = local.AZURE_SUBSCRIPTION_ID
resource_group_name = local.AZURE_RESOURCES_GROUP_NAME
vnet_name = local.AZURE_VNET_NAME
atlas_cidr_block = mongodbatlas_network_container.test.atlas_cidr_block
}
# Create the cluster once the peering connection is completed
Expand Down Expand Up @@ -314,7 +313,6 @@ resource "mongodbatlas_network_peering" "test" {
azure_subscription_id = local.AZURE_SUBSCRIPTION_ID
resource_group_name = local.AZURE_RESOURCE_GROUP_NAME
vnet_name = local.AZURE_VNET_NAME
atlas_cidr_block = local.ATLAS_CIDR_BLOCK
}
```

Expand Down

0 comments on commit 1cb0755

Please sign in to comment.