Skip to content

AWS and AZURE Private Endpoints (INTMDB-123 & INTMDB-124) #349

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

Merged
merged 36 commits into from
Nov 26, 2020

Conversation

coderGo93
Copy link
Contributor

@coderGo93 coderGo93 commented Nov 13, 2020

Description

  • Resources, datasources and its tests of private endpoints has been migrated
  • Created files for deprecated 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
  • Documentation fix/enhancement

Required Checklist:

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

Further comments

@leofigy
Copy link
Contributor

leofigy commented Nov 13, 2020

It's looking good, just fix the linting

@coderGo93 coderGo93 changed the title WIP: INTMDB-123 and INTMDB-124 WIP: AWS and AZURE Private Endpoints (INTMDB-123 & INTMDB-124) Nov 13, 2020
@coderGo93 coderGo93 changed the title WIP: AWS and AZURE Private Endpoints (INTMDB-123 & INTMDB-124) AWS and AZURE Private Endpoints (INTMDB-123 & INTMDB-124) Nov 17, 2020
@coderGo93 coderGo93 self-assigned this Nov 17, 2020
@themantissa
Copy link
Collaborator

@leofigy and @coderGo93 I'm concerned with how the deprecation is being performed here, it seems to be simply a rename of the existing resource and creating a new one, this gives no time for existing AWS privatelink users to transition from the old resource/datasource to the new (i.e. following https://www.terraform.io/docs/extend/best-practices/deprecations.html#provider-data-source-or-resource-removal) Am I mis-understanding?

@coderGo93
Copy link
Contributor Author

Thanks for the eye, @themantissa , forgot to add that deprecate messages, will do that

@coderGo93 coderGo93 requested a review from leofigy November 19, 2020 02:31
@coderGo93
Copy link
Contributor Author

Hi @leofigy , just made changes with renamed after discussing with @themantissa , did testing about importing with new resource from old resource and it works for me

@leofigy
Copy link
Contributor

leofigy commented Nov 19, 2020

LGTM

Copy link
Collaborator

@themantissa themantissa left a comment

Choose a reason for hiding this comment

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

Some minor changes but I think over all looks really good!

@@ -0,0 +1,81 @@
# Example - Microsoft Azure and MongoDB Atlas Private Endpoint
Copy link
Collaborator

Choose a reason for hiding this comment

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

Well this is surprising! We have had some internal team members adding examples and while this is useful was not technically in scope for the ticket. We can do more of these during development if we are able to get more hours and if we do the actual addition work first and then add the example. For now I do want to recognize that you saw what we've been doing and followed the example and I truly applaud and appreciate that but please try to keep in the scoped work till we can add on time for example generation :)

endpoint_service_id = mongodbatlas_private_endpoint.test.private_link_id
private_endpoint_ip_address = azurerm_private_endpoint.test.private_service_connection.0.private_ip_address
provider_name = "AZURE"
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

There's a couple of files giving the no newline warning so please add - some linters will pick those up

@@ -42,6 +42,7 @@ func dataSourceMongoDBAtlasPrivateEndpointInterfaceLink() *schema.Resource {
Computed: true,
},
},
DeprecationMessage: "use mongodbatlas_privatelink_endpoint_service datasource instead",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's expand this a bit:
"this data source is deprecated, please transition as soon as possible to mongodbatlas_privatelink_endpoint_service",

@@ -43,6 +43,7 @@ func dataSourceMongoDBAtlasPrivateEndpoint() *schema.Resource {
Computed: true,
},
},
DeprecationMessage: "use mongodbatlas_privatelink_endpoint datasource instead",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Expanding out a bit "this data source is deprecated, please transition as soon as possible to mongodbatlas_privatelink_endpoint_service",

@@ -71,19 +71,20 @@ func resourceMongoDBAtlasPrivateEndpoint() *schema.Resource {
Computed: true,
},
},
DeprecationMessage: "use mongodbatlas_privatelink_endpoint resource instead",
Copy link
Collaborator

Choose a reason for hiding this comment

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

"this resource is deprecated, please transition as soon as possible to mongodbatlas_privatelink_endpoint",

* `provider_name` - (Required) Cloud provider for which you want to retrieve a private endpoint service. Atlas accepts `AWS` or `AZURE`.


## Attributes Reference
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this may be missing the Azure attributes (there are two tabs in the api docs, one with AWS and one with azure)

* `project_id` - Required Unique identifier for the project.
* `providerName` - (Required) Name of the cloud provider for which you want to create the private endpoint service. Atlas accepts `AWS` or `AZURE`.
* `region` - (Required) Cloud provider region in which you want to create the private endpoint connection.
Accepted values are:
Copy link
Collaborator

Choose a reason for hiding this comment

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

We have had a hard time keeping these updated so please just link to the api doc for these, for example:
Updated accepted values can found in the main API documentation: MongoDB API Private Endpoint Service

* `provider_name` - (Required) Cloud provider for which you want to create a private endpoint. Atlas accepts `AWS` or `AZURE`.
* `private_endpoint_ip_address` - (Optional) Private IP address of the private endpoint network interface you created in your Azure VNet. Only for `AZURE`.

## Attributes Reference
Copy link
Collaborator

Choose a reason for hiding this comment

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

Need to be sure to include which are for AWS and which for Azure.

@themantissa themantissa requested a review from shum November 20, 2020 00:14
@themantissa
Copy link
Collaborator

@coderGo93 can you share with me the steps to you did to move from old to new in your test and I'll write up a guide. @shum added you to just give it a look since you were close to this one.

@coderGo93
Copy link
Contributor Author

Hi @themantissa , for steps to import from old to new are like this:

For PrivateLink Endpoint can be read in README.md

  1. Terraform import terraform import mongodbatlas_privatelink_endpoint.test {project_id}-{private_link_id}-{provider_name}
    i.e: terraform import mongodbatlas_privatelink_endpoint.test 1112222b3bf99403840e8934-3242342343112-AWS

For PrivateLink Endpoint Service

  1. Terraform import mongodbatlas_privatelink_endpoint_service.test {project_id}--{private_link_id}--{endpoint_service_id}--{provider_name}
    i.e: terraform import mongodbatlas_privatelink_endpoint_service.test terraform import mongodbatlas_privatelink_endpoint_service.test 1112222b3bf99403840e8934--vpce-4242342343--3242342343112--AWS

NOTE: Provider name for both resources are case sensitive.

Once done it should appear the info of imported resource with terraform show.

Copy link
Collaborator

@themantissa themantissa 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 @coderGo93 for the fixes. Let's just have @shum take a quick look and we are good.

@themantissa
Copy link
Collaborator

Hi @themantissa , for steps to import from old to new are like this:

For PrivateLink Endpoint can be read in README.md

1. Terraform import `terraform import mongodbatlas_privatelink_endpoint.test {project_id}-{private_link_id}-{provider_name} `
   i.e: `terraform import mongodbatlas_privatelink_endpoint.test 1112222b3bf99403840e8934-3242342343112-AWS`

For PrivateLink Endpoint Service

1. Terraform import `mongodbatlas_privatelink_endpoint_service.test {project_id}--{private_link_id}--{endpoint_service_id}--{provider_name} `
   i.e: `terraform import mongodbatlas_privatelink_endpoint_service.test terraform import mongodbatlas_privatelink_endpoint_service.test 1112222b3bf99403840e8934--vpce-4242342343--3242342343112--AWS`

NOTE: Provider name for both resources are case sensitive.

Once done it should appear the info of imported resource with terraform show.

@coderGo93 but you first need to remove them from terraform state with the old resource, correct? and thanks for including here.

@coderGo93
Copy link
Contributor Author

@themantissa That's correct, you need to remove first the terraform state otherwise it will say it already has info or something like that IIRC

Copy link
Collaborator

@shum shum left a comment

Choose a reason for hiding this comment

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

Generally LGTM. A few comments. Will review again after Thanksgiving!

}

variable "subscription_id" {
default = "AZURE SUSCRIPTION ID"
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
default = "AZURE SUSCRIPTION ID"
default = "AZURE SUBSCRIPTION ID"

errorGetRead = "error reading cloud provider access %s"
)

func dataSourceMongoDBAtlasCloudProviderAccessList() *schema.Resource {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This reads like it would have been a part of INTMDB-131 - is this intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

is it? @leofigy

Copy link
Contributor

Choose a reason for hiding this comment

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

It's weird, I did a PR but it was to grab your changes into my branch #353, because I needed your changes because you changed the client. I did a commit right now to remove the provider access files


const (
errorCloudProviderAccessCreate = "error creating cloud provider access %s"
errorCloudProviderAccessUpdate = "error update cloud provider access %s"
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
errorCloudProviderAccessUpdate = "error update cloud provider access %s"
errorCloudProviderAccessUpdate = "error updating cloud provider access %s"

const (
errorCloudProviderAccessCreate = "error creating cloud provider access %s"
errorCloudProviderAccessUpdate = "error update cloud provider access %s"
errorCloudProviderAccessDelete = "error delete cloud provider access %s"
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
errorCloudProviderAccessDelete = "error delete cloud provider access %s"
errorCloudProviderAccessDelete = "error deleting cloud provider access %s"

errorCloudProviderAccessCreate = "error creating cloud provider access %s"
errorCloudProviderAccessUpdate = "error update cloud provider access %s"
errorCloudProviderAccessDelete = "error delete cloud provider access %s"
errorCloudProviderAccessImporter = "error in import for cloud provider access %s"
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
errorCloudProviderAccessImporter = "error in import for cloud provider access %s"
errorCloudProviderAccessImporter = "error importing cloud provider access %s"

errorCloudProviderAccessImporter = "error in import for cloud provider access %s"
)

func resourceMongoDBAtlasCloudProviderAccess() *schema.Resource {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This again, looks like INTMDB-131 - intentional? I will ignore for now.

Copy link
Collaborator

@shum shum left a comment

Choose a reason for hiding this comment

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

Actually, I don't have any blocking comments on the actual private endpoint changes. If we can remove the cloud_provider_access files, I think we're good to go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
run-testacc To run acceptance tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants