Skip to content

Commit e3684c2

Browse files
coderGo93Edgar López
andauthored
INTMDB-175: Added azure status and fixes the error about target state (#398)
* fix: added parameter azure status and updated refresh func * docs: added azure status info * test: modified the line in azure test private link * docs: updated docs for privatelink endopoint to be more consistent from api docs * chore: updated client mongo master * refactor: deleted unnecesary pending state * docs: added upgrade guide for 0.8.2 version * docs: made changes suggested by melissa * chore: updated released tag for client Co-authored-by: Edgar López <[email protected]>
1 parent e6f5604 commit e3684c2

13 files changed

+148
-44
lines changed

examples/azure-atlas-privatelink/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ resource "azurerm_private_endpoint" "test" {
4949

5050
resource "mongodbatlas_privatelink_endpoint_service" "test" {
5151
project_id = mongodbatlas_privatelink_endpoint.test.project_id
52-
private_link_id = azurerm_private_endpoint.test.id
53-
endpoint_service_id = mongodbatlas_privatelink_endpoint.test.private_link_id
52+
private_link_id = mongodbatlas_privatelink_endpoint.test.private_link_id
53+
endpoint_service_id = azurerm_private_endpoint.test.id
5454
private_endpoint_ip_address = azurerm_private_endpoint.test.private_service_connection.0.private_ip_address
5555
provider_name = "AZURE"
5656
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ require (
1111
github.com/spf13/cast v1.3.1
1212
github.com/terraform-providers/terraform-provider-aws v1.60.1-0.20200518153306-40099de47e37
1313
github.com/terraform-providers/terraform-provider-google v1.20.1-0.20200518165017-1dd21651c496
14-
go.mongodb.org/atlas v0.7.1
14+
go.mongodb.org/atlas v0.7.2
1515
)

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,10 @@ go.mongodb.org/atlas v0.7.0 h1:nBur5go1JSCFCi1VaQ7Ry6du2uHjMFY0w8rI64KQ+b0=
611611
go.mongodb.org/atlas v0.7.0/go.mod h1:CIaBeO8GLHhtYLw7xSSXsw7N90Z4MFY87Oy9qcPyuEs=
612612
go.mongodb.org/atlas v0.7.1 h1:hNBtwtKgmhB9vmSX/JyN/cArmhzyy4ihKpmXSMIc4mw=
613613
go.mongodb.org/atlas v0.7.1/go.mod h1:CIaBeO8GLHhtYLw7xSSXsw7N90Z4MFY87Oy9qcPyuEs=
614+
go.mongodb.org/atlas v0.7.2-0.20210201161153-9669ea80d4d2 h1:097127emSQhG6Mnbs0wich0Oh0YjmMzxnQlso5vF06Y=
615+
go.mongodb.org/atlas v0.7.2-0.20210201161153-9669ea80d4d2/go.mod h1:CIaBeO8GLHhtYLw7xSSXsw7N90Z4MFY87Oy9qcPyuEs=
616+
go.mongodb.org/atlas v0.7.2 h1:wB3+hP71t3mK+JOSrjBFbrzb5MsZRzDtZlpEKp58KK0=
617+
go.mongodb.org/atlas v0.7.2/go.mod h1:CIaBeO8GLHhtYLw7xSSXsw7N90Z4MFY87Oy9qcPyuEs=
614618
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
615619
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
616620
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=

mongodbatlas/data_source_mongodbatlas_privatelink_endpoint_service.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,11 @@ func dataSourceMongoDBAtlasPrivateEndpointServiceLink() *schema.Resource {
5858
Type: schema.TypeString,
5959
Computed: true,
6060
},
61-
"connection_status": {
61+
"aws_connection_status": {
62+
Type: schema.TypeString,
63+
Computed: true,
64+
},
65+
"azure_status": {
6266
Type: schema.TypeString,
6367
Computed: true,
6468
},
@@ -88,8 +92,12 @@ func dataSourceMongoDBAtlasPrivateEndpointServiceLinkRead(d *schema.ResourceData
8892
return fmt.Errorf(errorEndpointSetting, "error_message", endpointServiceID, err)
8993
}
9094

91-
if err := d.Set("connection_status", serviceEndpoint.ConnectionStatus); err != nil {
92-
return fmt.Errorf(errorEndpointSetting, "connection_status", endpointServiceID, err)
95+
if err := d.Set("aws_connection_status", serviceEndpoint.AWSConnectionStatus); err != nil {
96+
return fmt.Errorf(errorEndpointSetting, "aws_connection_status", endpointServiceID, err)
97+
}
98+
99+
if err := d.Set("azure_status", serviceEndpoint.AzureStatus); err != nil {
100+
return fmt.Errorf(errorEndpointSetting, "azure_status", endpointServiceID, err)
93101
}
94102

95103
d.SetId(encodeStateID(map[string]string{

mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service.go

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,11 @@ func resourceMongoDBAtlasPrivateEndpointServiceLink() *schema.Resource {
7878
Type: schema.TypeString,
7979
Computed: true,
8080
},
81-
"connection_status": {
81+
"aws_connection_status": {
82+
Type: schema.TypeString,
83+
Computed: true,
84+
},
85+
"azure_status": {
8286
Type: schema.TypeString,
8387
Computed: true,
8488
},
@@ -104,8 +108,8 @@ func resourceMongoDBAtlasPrivateEndpointServiceLinkCreate(d *schema.ResourceData
104108
}
105109

106110
stateConf := &resource.StateChangeConf{
107-
Pending: []string{"NONE", "PENDING_ACCEPTANCE", "PENDING", "DELETING", "WAITING_FOR_USER"},
108-
Target: []string{"AVAILABLE", "REJECTED", "DELETED"},
111+
Pending: []string{"NONE", "INITIATING", "PENDING_ACCEPTANCE", "PENDING", "DELETING"},
112+
Target: []string{"AVAILABLE", "REJECTED", "DELETED", "FAILED"},
109113
Refresh: resourceServiceEndpointRefreshFunc(conn, projectID, providerName, privateLinkID, endpointServiceID),
110114
Timeout: 1 * time.Hour,
111115
MinTimeout: 5 * time.Second,
@@ -149,8 +153,12 @@ func resourceMongoDBAtlasPrivateEndpointServiceLinkRead(d *schema.ResourceData,
149153
return fmt.Errorf(errorEndpointSetting, "error_message", endpointServiceID, err)
150154
}
151155

152-
if err := d.Set("connection_status", privateEndpoint.ConnectionStatus); err != nil {
153-
return fmt.Errorf(errorEndpointSetting, "connection_status", endpointServiceID, err)
156+
if err := d.Set("aws_connection_status", privateEndpoint.AWSConnectionStatus); err != nil {
157+
return fmt.Errorf(errorEndpointSetting, "aws_connection_status", endpointServiceID, err)
158+
}
159+
160+
if err := d.Set("azure_status", privateEndpoint.AzureStatus); err != nil {
161+
return fmt.Errorf(errorEndpointSetting, "azure_status", endpointServiceID, err)
154162
}
155163

156164
if err := d.Set("interface_endpoint_id", privateEndpoint.InterfaceEndpointID); err != nil {
@@ -196,8 +204,8 @@ func resourceMongoDBAtlasPrivateEndpointServiceLinkDelete(d *schema.ResourceData
196204
}
197205

198206
stateConf := &resource.StateChangeConf{
199-
Pending: []string{"NONE", "PENDING_ACCEPTANCE", "PENDING", "DELETING", "WAITING_FOR_USER"},
200-
Target: []string{"REJECTED", "DELETED"},
207+
Pending: []string{"NONE", "PENDING_ACCEPTANCE", "PENDING", "DELETING", "INITIATING"},
208+
Target: []string{"REJECTED", "DELETED", "FAILED"},
201209
Refresh: resourceServiceEndpointRefreshFunc(conn, projectID, providerName, privateLinkID, endpointServiceID),
202210
Timeout: 1 * time.Hour,
203211
MinTimeout: 5 * time.Second,
@@ -269,10 +277,16 @@ func resourceServiceEndpointRefreshFunc(client *matlas.Client, projectID, provid
269277
return nil, "", err
270278
}
271279

272-
if i.ConnectionStatus != "AVAILABLE" {
273-
return "", i.ConnectionStatus, nil
280+
if strings.EqualFold(providerName, "azure") {
281+
if i.AzureStatus != "AVAILABLE" {
282+
return "", i.AzureStatus, nil
283+
}
284+
return i, i.AzureStatus, nil
285+
}
286+
if i.AWSConnectionStatus != "AVAILABLE" {
287+
return "", i.AWSConnectionStatus, nil
274288
}
275289

276-
return i, i.ConnectionStatus, nil
290+
return i, i.AWSConnectionStatus, nil
277291
}
278292
}

vendor/go.mongodb.org/atlas/mongodbatlas/mongodbatlas.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/go.mongodb.org/atlas/mongodbatlas/private_endpoints.go

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/modules.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ github.com/zclconf/go-cty/cty/msgpack
476476
github.com/zclconf/go-cty/cty/set
477477
# github.com/zclconf/go-cty-yaml v1.0.1
478478
github.com/zclconf/go-cty-yaml
479-
# go.mongodb.org/atlas v0.7.1
479+
# go.mongodb.org/atlas v0.7.2
480480
## explicit
481481
go.mongodb.org/atlas/mongodbatlas
482482
# go.opencensus.io v0.22.3

website/docs/d/private_endpoint.html.markdown

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,16 @@ In addition to all arguments above, the following attributes are exported:
4444
* `endpoint_service_name` - Name of the PrivateLink endpoint service in AWS. Returns null while the endpoint service is being created.
4545
* `error_message` - Error message pertaining to the AWS PrivateLink connection. Returns null if there are no errors.
4646
* `interface_endpoints` - Unique identifiers of the interface endpoints in your VPC that you added to the AWS PrivateLink connection.
47-
* `status` - Status of the AWS PrivateLink connection.
48-
Returns one of the following values:
49-
* `INITIATING` Atlas is creating the network load balancer and VPC endpoint service.
50-
* `WAITING_FOR_USER` The Atlas network load balancer and VPC endpoint service are created and ready to receive connection requests. When you receive this status, create an interface endpoint to continue configuring the AWS PrivateLink connection.
51-
* `FAILED` A system failure has occurred.
52-
* `DELETING` The AWS PrivateLink connection is being deleted.
47+
* `status` - Status of the AWS PrivateLink connection or Status of the Azure Private Link Service. Atlas returns one of the following values:
48+
AWS:
49+
* `AVAILABLE` Atlas is creating the network load balancer and VPC endpoint service.
50+
* `WAITING_FOR_USER` The Atlas network load balancer and VPC endpoint service are created and ready to receive connection requests.
51+
* `FAILED` A system failure has occurred.
52+
* `DELETING` The AWS PrivateLink connection is being deleted.
53+
AZURE:
54+
* `AVAILABLE` Atlas created the load balancer and the Private Link Service.
55+
* `INITIATING` Atlas is creating the load balancer and the Private Link Service.
56+
* `FAILED` Atlas failed to create the load balancer and the Private Link service.
57+
* `DELETING` Atlas is deleting the Private Link service.
5358

5459
See [MongoDB Atlas API](https://docs.atlas.mongodb.com/reference/api/private-endpoint-get-one-private-endpoint-connection/) Documentation for more information.

website/docs/d/privatelink_endpoint_service.html.markdown

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,19 @@ In addition to all arguments above, the following attributes are exported:
6161
* `private_endpoint_resource_id` - Unique identifier of the private endpoint.
6262
* `delete_requested` - Indicates if Atlas received a request to remove the interface endpoint from the private endpoint connection.
6363
* `error_message` - Error message pertaining to the interface endpoint. Returns null if there are no errors.
64-
* `connection_status` - Status of the interface endpoint.
64+
* `aws_connection_status` - Status of the interface endpoint for AWS.
6565
Returns one of the following values:
66-
* `NONE` - Atlas created the network load balancer and VPC endpoint service, but AWS hasn’t yet created the VPC endpoint.
67-
* `PENDING_ACCEPTANCE` - AWS has received the connection request from your VPC endpoint to the Atlas VPC endpoint service.
68-
* `PENDING` - AWS is establishing the connection between your VPC endpoint and the Atlas VPC endpoint service.
69-
* `AVAILABLE` - Atlas VPC resources are connected to the VPC endpoint in your VPC. You can connect to Atlas clusters in this region using AWS PrivateLink.
70-
* `REJECTED` - AWS failed to establish a connection between Atlas VPC resources to the VPC endpoint in your VPC.
71-
* `INITIATING` - Atlas has not yet accepted the connection to your private endpoint.
72-
* `FAILED` - Atlas failed to accept the connection your private endpoint.
73-
* `DELETING` - Atlas is removing the interface endpoint from the private endpoint connection.
66+
* `NONE` - Atlas created the network load balancer and VPC endpoint service, but AWS hasn’t yet created the VPC endpoint.
67+
* `PENDING_ACCEPTANCE` - AWS has received the connection request from your VPC endpoint to the Atlas VPC endpoint service.
68+
* `PENDING` - AWS is establishing the connection between your VPC endpoint and the Atlas VPC endpoint service.
69+
* `AVAILABLE` - Atlas VPC resources are connected to the VPC endpoint in your VPC. You can connect to Atlas clusters in this region using AWS PrivateLink.
70+
* `REJECTED` - AWS failed to establish a connection between Atlas VPC resources to the VPC endpoint in your VPC.
71+
* `DELETING` - Atlas is removing the interface endpoint from the private endpoint connection.
72+
* `azure_status` - Status of the interface endpoint for AZURE.
73+
Returns one of the following values:
74+
* `INITIATING` - Atlas has not yet accepted the connection to your private endpoint.
75+
* `AVAILABLE` - Atlas approved the connection to your private endpoint.
76+
* `FAILED` - Atlas failed to accept the connection your private endpoint.
77+
* `DELETING` - Atlas is removing the connection to your private endpoint from the Private Link service.
7478

7579
See [MongoDB Atlas API](https://docs.atlas.mongodb.com/reference/api/private-endpoints-endpoint-get-one/) Documentation for more information.

0 commit comments

Comments
 (0)