Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

INTMDB-364: [Terraform] Add support for serverless private endpoints #314

Merged
merged 12 commits into from Oct 14, 2022

Conversation

martinstibbe
Copy link
Collaborator

@martinstibbe martinstibbe commented Oct 3, 2022

Description

INTMDB-364: [Terraform] Add support for serverless private endpoints

Link to any related issue(s):

Type of change:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Required Checklist:

  • I have signed the MongoDB CLA
  • I have added tests that prove my fix is effective or that my feature works
  • I have added any necessary documentation (if appropriate)
  • I have run make fmt and formatted my code

Further comments

@martinstibbe martinstibbe requested a review from a team as a code owner October 3, 2022 17:57
@martinstibbe martinstibbe requested review from themantissa and removed request for a team October 3, 2022 17:57
Copy link
Collaborator

@andreaangiolillo andreaangiolillo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! 🎉 Just one small comment


// List retrieve details for all private Serverless endpoint services in one Atlas project.
//
// See more: https://www.mongodb.com/docs/atlas/reference/api/serverless-private-endpoints-get-all/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[q] Could we stop using this doc page that will be deprecated soon and start using https://www.mongodb.com/docs/atlas/reference/api-resources-spec/#tag/Serverless-Private-Endpoints (autogenerated with open API annotations)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

Copy link
Collaborator

@andreaangiolillo andreaangiolillo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Collaborator

@gssbzn gssbzn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

both on the old docs and new docs serverless endpoints is a dedicated section from trditional private endpoints, we try to keep the SDK organized the same as docs, let's please split into a new service

Copy link
Collaborator

@gssbzn gssbzn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please refer to the up to date docs https://www.mongodb.com/docs/atlas/reference/api-resources-spec/#tag/Serverless-Private-Endpoints, please notice the correct term is serverless private endpoint and not private serverless endpoint which seems used all over the place also this seems to only cover the AWS private endpoint and not the azure one

// PrivateEndpointsService is an interface for interfacing with the Private Endpoints
// of the MongoDB Atlas API.
//
// See more: https://docs.atlas.mongodb.com/reference/api/private-endpoints/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// See more: https://docs.atlas.mongodb.com/reference/api/private-endpoints/
// See more: https://www.mongodb.com/docs/atlas/reference/api-resources-spec/#tag/Serverless-Private-Endpoints

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gssbzn Was using docs at the time that stated ... Creates one private endpoint for one Atlas serverless instance. Serverless instances support private endpoints on AWS only. Will have to add support for Azure

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@martinstibbe Azure support is ok to do as a follow up

// of the MongoDB Atlas API.
//
// See more: https://docs.atlas.mongodb.com/reference/api/private-endpoints/
type PrivateServerlessEndpointsService interface {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
type PrivateServerlessEndpointsService interface {
type ServerlessPrivateEndpointsService interface {

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored

serverlessPrivateEndpointsPath = "api/atlas/v1.0/groups/%s/privateEndpoint/serverless/instance/%s/endpoint"
)

// PrivateEndpointsService is an interface for interfacing with the Private Endpoints
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// PrivateEndpointsService is an interface for interfacing with the Private Endpoints
// ServerlessPrivateEndpointsService is an interface for interfacing with the Private Endpoints

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored

Comment on lines 57 to 60
// List retrieve details for all private Serverless endpoint services in one Atlas project.
//
// See more: https://www.mongodb.com/docs/atlas/reference/api-resources-spec/#operation/returnAllPrivateEndpointsForOneServerlessInstance
func (s *PrivateServerlessEndpointsServiceOp) ListPrivateServerlessEndpoint(ctx context.Context, groupID, instanceID string, listOptions *ListOptions) ([]PrivateServerlessEndpointConnection, *Response, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// List retrieve details for all private Serverless endpoint services in one Atlas project.
//
// See more: https://www.mongodb.com/docs/atlas/reference/api-resources-spec/#operation/returnAllPrivateEndpointsForOneServerlessInstance
func (s *PrivateServerlessEndpointsServiceOp) ListPrivateServerlessEndpoint(ctx context.Context, groupID, instanceID string, listOptions *ListOptions) ([]PrivateServerlessEndpointConnection, *Response, error) {
// List retrieve details for all private Serverless endpoint services in one Atlas project.
//
// See more: https://www.mongodb.com/docs/atlas/reference/api-resources-spec/#operation/returnAllPrivateEndpointsForOneServerlessInstance
func (s *PrivateServerlessEndpointsServiceOp) List(ctx context.Context, groupID, instanceName string, listOptions *ListOptions) ([]PrivateServerlessEndpointConnection, *Response, error) {

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored

var _ PrivateServerlessEndpointsService = &PrivateServerlessEndpointsServiceOp{}

// PrivateEndpointServerlessConnection represents MongoDB Private Endpoint Connection.
type PrivateServerlessEndpointConnection struct {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
type PrivateServerlessEndpointConnection struct {
type ServerlessPrivateEndpointConnection struct {

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored

Comment on lines 33 to 37
ListPrivateServerlessEndpoint(context.Context, string, string, *ListOptions) ([]PrivateServerlessEndpointConnection, *Response, error)
AddOnePrivateServerlessEndpoint(context.Context, string, string, *PrivateServerlessEndpointConnection) (*PrivateServerlessEndpointConnection, *Response, error)
GetOnePrivateServerlessEndpoint(context.Context, string, string, string) (*PrivateServerlessEndpointConnection, *Response, error)
DeleteOnePrivateServerlessEndpoint(context.Context, string, string, string) (*Response, error)
UpdateOnePrivateServerlessEndpoint(context.Context, string, string, string, *PrivateServerlessEndpointConnection) (*PrivateServerlessEndpointConnection, *Response, error)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ListPrivateServerlessEndpoint(context.Context, string, string, *ListOptions) ([]PrivateServerlessEndpointConnection, *Response, error)
AddOnePrivateServerlessEndpoint(context.Context, string, string, *PrivateServerlessEndpointConnection) (*PrivateServerlessEndpointConnection, *Response, error)
GetOnePrivateServerlessEndpoint(context.Context, string, string, string) (*PrivateServerlessEndpointConnection, *Response, error)
DeleteOnePrivateServerlessEndpoint(context.Context, string, string, string) (*Response, error)
UpdateOnePrivateServerlessEndpoint(context.Context, string, string, string, *PrivateServerlessEndpointConnection) (*PrivateServerlessEndpointConnection, *Response, error)
List(context.Context, string, string, *ListOptions) ([]PrivateServerlessEndpointConnection, *Response, error)
Create(context.Context, string, string, *PrivateServerlessEndpointConnection) (*PrivateServerlessEndpointConnection, *Response, error)
Get(context.Context, string, string, string) (*PrivateServerlessEndpointConnection, *Response, error)
Delete(context.Context, string, string, string) (*Response, error)
Update(context.Context, string, string, string, *PrivateServerlessEndpointConnection) (*PrivateServerlessEndpointConnection, *Response, error)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored


// PrivateServerlessEndpointsServiceOp handles communication with the PrivateServerlessEndpoints related methods
// of the MongoDB Atlas API.
type PrivateServerlessEndpointsServiceOp service
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
type PrivateServerlessEndpointsServiceOp service
type ServerlessPrivateEndpointsServiceOp service

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored

Comment on lines 48 to 54
ID string `json:"_id,omitempty"` // Unique identifier of the Serverless PrivateLink Service.
CloudProviderEndpointID string `json:"cloudProviderEndpointId,omitempty"`
Comment string `json:"comment,omitempty"`
EndpointServiceName string `json:"endpointServiceName,omitempty"` // Name of the PrivateLink endpoint service in AWS. Returns null while the endpoint service is being created.
ErrorMessage string `json:"errorMessage,omitempty"` // Error message pertaining to the AWS Service Connect. Returns null if there are no errors.
Status string `json:"status,omitempty"` // Status of the AWS Serverless PrivateLink connection: INITIATING, WAITING_FOR_USER, FAILED, DELETING, AVAILABLE.
ProviderName string `json:"providerName,omitempty"` // Human-readable label that identifies the cloud provider. Values include AWS or AZURE. Atlas currently supports only AWS.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these fields only cover AWS for Azure you are missing privateEndpointIpAddress, privateLinkServiceResourceId,

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added additional fields

Copy link
Collaborator

@gssbzn gssbzn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks for the work here

Copy link
Collaborator

@evertsd evertsd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@martinstibbe martinstibbe merged commit ac6bf94 into master Oct 14, 2022
@martinstibbe martinstibbe deleted the INTMDB-364 branch October 14, 2022 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants