Skip to content

feat: Add error_message, provider_account_id, and interface_endpoint_name to Stream PrivateLinkEndpoint models #3139

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

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/3139.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/mongodbatlas_stream_privatelink_endpoint: Adds `error_message`, `interface_endpoint_name`, and `provider_account_id` attributes
```
3 changes: 3 additions & 0 deletions docs/data-sources/stream_privatelink_endpoint.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ output "interface_endpoint_ids" {

- `dns_domain` (String) Domain name of Privatelink connected cluster.
- `dns_sub_domain` (List of String) Sub-Domain name of Confluent cluster. These are typically your availability zones.
- `error_message` (String) Error message if the connection is in a failed state.
- `interface_endpoint_id` (String) Interface endpoint ID that is created from the specified service endpoint ID.
- `interface_endpoint_name` (String) Interface endpoint name that is created from the specified service endpoint ID.
- `provider_account_id` (String) Account ID from the cloud provider.
- `provider_name` (String) Provider where the Kafka cluster is deployed.
- `region` (String) Domain name of Confluent cluster.
- `service_endpoint_id` (String) Service Endpoint ID.
Expand Down
3 changes: 3 additions & 0 deletions docs/data-sources/stream_privatelink_endpoints.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,14 @@ Read-Only:

- `dns_domain` (String) Domain name of Privatelink connected cluster.
- `dns_sub_domain` (List of String) Sub-Domain name of Confluent cluster. These are typically your availability zones.
- `error_message` (String) Error message if the connection is in a failed state.
- `id` (String) The ID of the Private Link connection.
- `interface_endpoint_id` (String) Interface endpoint ID that is created from the specified service endpoint ID.
- `interface_endpoint_name` (String) Interface endpoint name that is created from the specified service endpoint ID.
- `project_id` (String) Unique 24-hexadecimal digit string that identifies your project. Use the [/groups](#tag/Projects/operation/listProjects) endpoint to retrieve all projects to which the authenticated user has access.

**NOTE**: Groups and projects are synonymous terms. Your group id is the same as your project id. For existing groups, your group or project id remains the same. The resource and corresponding endpoints use the term groups.
- `provider_account_id` (String) Account ID from the cloud provider.
- `provider_name` (String) Provider where the Kafka cluster is deployed.
- `region` (String) Domain name of Confluent cluster.
- `service_endpoint_id` (String) Service Endpoint ID.
Expand Down
3 changes: 3 additions & 0 deletions docs/resources/stream_privatelink_endpoint.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,11 @@ output "interface_endpoint_ids" {

### Read-Only

- `error_message` (String) Error message if the connection is in a failed state.
- `id` (String) The ID of the Private Link connection.
- `interface_endpoint_id` (String) Interface endpoint ID that is created from the specified service endpoint ID.
- `interface_endpoint_name` (String) Interface endpoint name that is created from the specified service endpoint ID.
- `provider_account_id` (String) Account ID from the cloud provider.
- `state` (String) Status of the connection.

For more information see: [MongoDB Atlas API - Streams Privatelink](https://www.mongodb.com/docs/atlas/reference/api-resources-spec/v2/#tag/Streams/operation/createPrivateLinkConnection) Documentation.
32 changes: 17 additions & 15 deletions internal/service/streamprivatelinkendpoint/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,25 @@ const (

func NewTFModel(ctx context.Context, projectID string, apiResp *admin.StreamsPrivateLinkConnection) (*TFModel, diag.Diagnostics) {
result := &TFModel{
Id: types.StringPointerValue(apiResp.Id),
DnsDomain: types.StringPointerValue(apiResp.DnsDomain),
ProjectId: types.StringPointerValue(&projectID),
InterfaceEndpointId: types.StringPointerValue(apiResp.InterfaceEndpointId),
Provider: types.StringPointerValue(apiResp.Provider),
Region: types.StringPointerValue(apiResp.Region),
ServiceEndpointId: types.StringPointerValue(apiResp.ServiceEndpointId),
State: types.StringPointerValue(apiResp.State),
Vendor: types.StringPointerValue(apiResp.Vendor),
Id: types.StringPointerValue(apiResp.Id),
DnsDomain: types.StringPointerValue(apiResp.DnsDomain),
ErrorMessage: types.StringPointerValue(apiResp.ErrorMessage),
ProjectId: types.StringPointerValue(&projectID),
InterfaceEndpointId: types.StringPointerValue(apiResp.InterfaceEndpointId),
InterfaceEndpointName: types.StringPointerValue(apiResp.InterfaceEndpointName),
Provider: types.StringPointerValue(apiResp.Provider),
ProviderAccountId: types.StringPointerValue(apiResp.ProviderAccountId),
Region: types.StringPointerValue(apiResp.Region),
ServiceEndpointId: types.StringPointerValue(apiResp.ServiceEndpointId),
State: types.StringPointerValue(apiResp.State),
Vendor: types.StringPointerValue(apiResp.Vendor),
}
if apiResp.DnsSubDomain != nil {
subdomain, diags := types.ListValueFrom(ctx, types.StringType, apiResp.GetDnsSubDomain())
if diags.HasError() {
return nil, diags
}
result.DnsSubDomain = subdomain

subdomain, diags := types.ListValueFrom(ctx, types.StringType, apiResp.GetDnsSubDomain())
if diags.HasError() {
return nil, diags
}
result.DnsSubDomain = subdomain

return result, nil
}
Expand Down
78 changes: 44 additions & 34 deletions internal/service/streamprivatelinkendpoint/model_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,35 @@ type sdkToTFModelTestCase struct {
}

var (
projectID = "projectID"
id = "id"
dnsDomain = "dnsDomain"
dnsSubDomain = "dnsSubDomain"
interfaceEndpointID = "interfaceEndpointId"
provider = "AWS"
region = "us-east-1"
serviceEndpointID = "serviceEndpointId"
state = "DONE"
vendor = "CONFLUENT"
projectID = "projectID"
id = "id"
dnsDomain = "dnsDomain"
dnsSubDomain = "dnsSubDomain"
interfaceEndpointID = "interfaceEndpointId"
interfaceEndpointName = "interfaceEndpointName"
provider = "AWS"
providerAccountID = "providerAccountId"
region = "us-east-1"
serviceEndpointID = "serviceEndpointId"
state = "DONE"
vendor = "CONFLUENT"
)

func TestStreamPrivatelinkEndpointSDKToTFModel(t *testing.T) {
testCases := map[string]sdkToTFModelTestCase{
"Complete SDK response": {
SDKResp: &admin.StreamsPrivateLinkConnection{
Id: &id,
DnsDomain: &dnsDomain,
DnsSubDomain: conversion.Pointer([]string{dnsSubDomain, dnsSubDomain}),
InterfaceEndpointId: &interfaceEndpointID,
Provider: &provider,
Region: &region,
ServiceEndpointId: &serviceEndpointID,
State: &state,
Vendor: &vendor,
Id: &id,
DnsDomain: &dnsDomain,
DnsSubDomain: conversion.Pointer([]string{dnsSubDomain, dnsSubDomain}),
InterfaceEndpointId: &interfaceEndpointID,
InterfaceEndpointName: &interfaceEndpointName,
Provider: &provider,
ProviderAccountId: &providerAccountID,
Region: &region,
ServiceEndpointId: &serviceEndpointID,
State: &state,
Vendor: &vendor,
},
projectID: projectID,
expectedTFModel: &streamprivatelinkendpoint.TFModel{
Expand All @@ -54,13 +58,15 @@ func TestStreamPrivatelinkEndpointSDKToTFModel(t *testing.T) {
types.StringValue(dnsSubDomain),
types.StringValue(dnsSubDomain),
}),
ProjectId: types.StringValue(projectID),
InterfaceEndpointId: types.StringValue(interfaceEndpointID),
Provider: types.StringValue(provider),
Region: types.StringValue(region),
ServiceEndpointId: types.StringValue(serviceEndpointID),
State: types.StringValue(state),
Vendor: types.StringValue(vendor),
ProjectId: types.StringValue(projectID),
InterfaceEndpointId: types.StringValue(interfaceEndpointID),
InterfaceEndpointName: types.StringValue(interfaceEndpointName),
Provider: types.StringValue(provider),
ProviderAccountId: types.StringValue(providerAccountID),
Region: types.StringValue(region),
ServiceEndpointId: types.StringValue(serviceEndpointID),
State: types.StringValue(state),
Vendor: types.StringValue(vendor),
},
},
"SDK response without dns subdomains": {
Expand All @@ -78,6 +84,7 @@ func TestStreamPrivatelinkEndpointSDKToTFModel(t *testing.T) {
expectedTFModel: &streamprivatelinkendpoint.TFModel{
Id: types.StringValue(id),
DnsDomain: types.StringValue(dnsDomain),
DnsSubDomain: types.ListNull(types.StringType),
ProjectId: types.StringValue(projectID),
InterfaceEndpointId: types.StringValue(interfaceEndpointID),
Provider: types.StringValue(provider),
Expand All @@ -90,7 +97,8 @@ func TestStreamPrivatelinkEndpointSDKToTFModel(t *testing.T) {
"Empty SDK response": {
SDKResp: &admin.StreamsPrivateLinkConnection{},
expectedTFModel: &streamprivatelinkendpoint.TFModel{
ProjectId: types.StringValue(""),
ProjectId: types.StringValue(""),
DnsSubDomain: types.ListNull(types.StringType),
},
},
}
Expand Down Expand Up @@ -121,13 +129,15 @@ func TestStreamPrivatelinkEndpointTFModelToSDK(t *testing.T) {
types.StringValue(dnsSubDomain),
types.StringValue(dnsSubDomain),
}),
ProjectId: types.StringValue(projectID),
InterfaceEndpointId: types.StringValue(interfaceEndpointID),
Provider: types.StringValue(provider),
Region: types.StringValue(region),
ServiceEndpointId: types.StringValue(serviceEndpointID),
State: types.StringValue(state),
Vendor: types.StringValue(vendor),
ProjectId: types.StringValue(projectID),
InterfaceEndpointId: types.StringValue(interfaceEndpointID),
InterfaceEndpointName: types.StringValue(interfaceEndpointName),
Provider: types.StringValue(provider),
ProviderAccountId: types.StringValue(providerAccountID),
Region: types.StringValue(region),
ServiceEndpointId: types.StringValue(serviceEndpointID),
State: types.StringValue(state),
Vendor: types.StringValue(vendor),
},
expectedSDKReq: &admin.StreamsPrivateLinkConnection{
DnsDomain: &dnsDomain,
Expand Down
35 changes: 25 additions & 10 deletions internal/service/streamprivatelinkendpoint/resource_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ func ResourceSchema(ctx context.Context) schema.Schema {
MarkdownDescription: "Sub-Domain name of Confluent cluster. These are typically your availability zones.",
ElementType: types.StringType,
},
"error_message": schema.StringAttribute{
Computed: true,
MarkdownDescription: "Error message if the connection is in a failed state.",
},
"project_id": schema.StringAttribute{
Required: true,
MarkdownDescription: "Unique 24-hexadecimal digit string that identifies your project. Use the [/groups](#tag/Projects/operation/listProjects) endpoint to retrieve all projects to which the authenticated user has access.\n\n**NOTE**: Groups and projects are synonymous terms. Your group id is the same as your project id. For existing groups, your group or project id remains the same. The resource and corresponding endpoints use the term groups.",
Expand All @@ -31,6 +35,14 @@ func ResourceSchema(ctx context.Context) schema.Schema {
Computed: true,
MarkdownDescription: "Interface endpoint ID that is created from the specified service endpoint ID.",
},
"interface_endpoint_name": schema.StringAttribute{
Computed: true,
MarkdownDescription: "Interface endpoint name that is created from the specified service endpoint ID.",
},
"provider_account_id": schema.StringAttribute{
Computed: true,
MarkdownDescription: "Account ID from the cloud provider.",
},
"provider_name": schema.StringAttribute{
Required: true,
MarkdownDescription: "Provider where the Kafka cluster is deployed.",
Expand All @@ -56,16 +68,19 @@ func ResourceSchema(ctx context.Context) schema.Schema {
}

type TFModel struct {
Id types.String `tfsdk:"id"`
DnsDomain types.String `tfsdk:"dns_domain"`
DnsSubDomain types.List `tfsdk:"dns_sub_domain"`
ProjectId types.String `tfsdk:"project_id"`
InterfaceEndpointId types.String `tfsdk:"interface_endpoint_id"`
Provider types.String `tfsdk:"provider_name"`
Region types.String `tfsdk:"region"`
ServiceEndpointId types.String `tfsdk:"service_endpoint_id"`
State types.String `tfsdk:"state"`
Vendor types.String `tfsdk:"vendor"`
Id types.String `tfsdk:"id"`
DnsDomain types.String `tfsdk:"dns_domain"`
DnsSubDomain types.List `tfsdk:"dns_sub_domain"`
ErrorMessage types.String `tfsdk:"error_message"`
ProjectId types.String `tfsdk:"project_id"`
InterfaceEndpointId types.String `tfsdk:"interface_endpoint_id"`
InterfaceEndpointName types.String `tfsdk:"interface_endpoint_name"`
Provider types.String `tfsdk:"provider_name"`
ProviderAccountId types.String `tfsdk:"provider_account_id"`
Region types.String `tfsdk:"region"`
ServiceEndpointId types.String `tfsdk:"service_endpoint_id"`
State types.String `tfsdk:"state"`
Vendor types.String `tfsdk:"vendor"`
}

type TFModelDSP struct {
Expand Down
41 changes: 41 additions & 0 deletions internal/service/streamprivatelinkendpoint/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ func TestAccStreamPrivatelinkEndpoint_basic(t *testing.T) {
resource.Test(t, *tc)
}

func TestAccStreamPrivateLinkEndpoint_noDNSSubdomains(t *testing.T) {
acc.SkipTestForCI(t) // needs confluent cloud resources
tc := noDNSSubDomainsTestCase(t)
// Tests include testing of plural data source and so cannot be run in parallel
resource.Test(t, *tc)
}

func TestAccStreamPrivatelinkEndpoint_failedUpdate(t *testing.T) {
acc.SkipTestForCI(t) // needs confluent cloud resources
tc := failedUpdateTestCase(t)
Expand Down Expand Up @@ -53,6 +60,40 @@ func basicTestCase(t *testing.T) *resource.TestCase {
config = acc.GetCompleteConfluentConfig(true, true, projectID, provider, region, vendor, awsAccountID, networkID, privatelinkAccessID)
)

return &resource.TestCase{
PreCheck: func() { acc.PreCheckBasic(t); acc.PreCheckConfluentAWSPrivatelink(t) },
CheckDestroy: checkDestroy,
ExternalProviders: acc.ExternalProvidersOnlyConfluent(),
ProtoV6ProviderFactories: acc.TestAccProviderV6Factories,
Steps: []resource.TestStep{
{

Config: config,
Check: checksStreamPrivatelinkEndpoint(projectID, provider, region, vendor, true),
},
{
ResourceName: resourceName,
ImportStateIdFunc: importStateIDFunc(resourceName),
ImportState: true,
ImportStateVerify: true,
},
},
}
}

func noDNSSubDomainsTestCase(t *testing.T) *resource.TestCase {
t.Helper()

var (
projectID = acc.ProjectIDExecution(t)
provider = "AWS"
region = "us-east-1"
awsAccountID = os.Getenv("AWS_ACCOUNT_ID")
networkID = os.Getenv("CONFLUENT_CLOUD_NETWORK_ID")
privatelinkAccessID = os.Getenv("CONFLUENT_CLOUD_PRIVATELINK_ACCESS_ID")
config = acc.GetCompleteConfluentConfig(true, false, projectID, provider, region, vendor, awsAccountID, networkID, privatelinkAccessID)
)

return &resource.TestCase{
PreCheck: func() { acc.PreCheckBasic(t); acc.PreCheckConfluentAWSPrivatelink(t) },
CheckDestroy: checkDestroy,
Expand Down
2 changes: 1 addition & 1 deletion internal/testutil/acc/pre_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,6 @@ func PreCheckConfluentAWSPrivatelink(tb testing.TB) {
os.Getenv("CONFLUENT_CLOUD_API_SECRET") == "" ||
os.Getenv("CONFLUENT_CLOUD_NETWORK_ID") == "" ||
os.Getenv("CONFLUENT_CLOUD_PRIVATELINK_ACCESS_ID") == "" {
tb.Fatal("`CONFLUENT_CLOUD_API_KEY`, `CONFLUENT_CLOUD_API_SECRET`, `CONFLUENT_CLOUD_NETWORK_ID`, and `CONFLUENT_CLOUD_PRIVATELINK_ACCESS_ID` must be set for Cloud Backup Snapshot Export Bucket acceptance testing")
tb.Fatal("`CONFLUENT_CLOUD_API_KEY`, `CONFLUENT_CLOUD_API_SECRET`, `CONFLUENT_CLOUD_NETWORK_ID`, and `CONFLUENT_CLOUD_PRIVATELINK_ACCESS_ID` must be set for AWS PrivateLink acceptance testing")
}
}
Loading