Skip to content

Commit cc742e8

Browse files
authored
feat: Add error_message, provider_account_id, and interface_endpoint_name to Stream PrivateLinkEndpoint models (#3161)
1 parent 857f5c7 commit cc742e8

File tree

10 files changed

+112
-64
lines changed

10 files changed

+112
-64
lines changed

.changelog/3161.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
resource/mongodbatlas_stream_privatelink_endpoint: Adds `error_message`, `interface_endpoint_name`, and `provider_account_id` attributes
3+
```

docs/data-sources/stream_privatelink_endpoint.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,10 @@ output "interface_endpoint_ids" {
9393

9494
- `dns_domain` (String) Domain name of Privatelink connected cluster.
9595
- `dns_sub_domain` (List of String) Sub-Domain name of Confluent cluster. These are typically your availability zones.
96+
- `error_message` (String) Error message if the connection is in a failed state.
9697
- `interface_endpoint_id` (String) Interface endpoint ID that is created from the specified service endpoint ID.
98+
- `interface_endpoint_name` (String) Name of interface endpoint that is created from the specified service endpoint ID.
99+
- `provider_account_id` (String) Account ID from the cloud provider.
97100
- `provider_name` (String) Provider where the Kafka cluster is deployed.
98101
- `region` (String) Domain name of Confluent cluster.
99102
- `service_endpoint_id` (String) Service Endpoint ID.

docs/data-sources/stream_privatelink_endpoints.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,14 @@ Read-Only:
9999

100100
- `dns_domain` (String) Domain name of Privatelink connected cluster.
101101
- `dns_sub_domain` (List of String) Sub-Domain name of Confluent cluster. These are typically your availability zones.
102+
- `error_message` (String) Error message if the connection is in a failed state.
102103
- `id` (String) The ID of the Private Link connection.
103104
- `interface_endpoint_id` (String) Interface endpoint ID that is created from the specified service endpoint ID.
105+
- `interface_endpoint_name` (String) Name of interface endpoint that is created from the specified service endpoint ID.
104106
- `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.
105107

106108
**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.
109+
- `provider_account_id` (String) Account ID from the cloud provider.
107110
- `provider_name` (String) Provider where the Kafka cluster is deployed.
108111
- `region` (String) Domain name of Confluent cluster.
109112
- `service_endpoint_id` (String) Service Endpoint ID.

docs/resources/stream_privatelink_endpoint.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,11 @@ output "interface_endpoint_ids" {
9999

100100
### Read-Only
101101

102+
- `error_message` (String) Error message if the connection is in a failed state.
102103
- `id` (String) The ID of the Private Link connection.
103104
- `interface_endpoint_id` (String) Interface endpoint ID that is created from the specified service endpoint ID.
105+
- `interface_endpoint_name` (String) Name of interface endpoint that is created from the specified service endpoint ID.
106+
- `provider_account_id` (String) Account ID from the cloud provider.
104107
- `state` (String) Status of the connection.
105108

106109
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.

internal/service/streamprivatelinkendpoint/model.go

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,25 @@ const (
1616

1717
func NewTFModel(ctx context.Context, projectID string, apiResp *admin.StreamsPrivateLinkConnection) (*TFModel, diag.Diagnostics) {
1818
result := &TFModel{
19-
Id: types.StringPointerValue(apiResp.Id),
20-
DnsDomain: types.StringPointerValue(apiResp.DnsDomain),
21-
ProjectId: types.StringPointerValue(&projectID),
22-
InterfaceEndpointId: types.StringPointerValue(apiResp.InterfaceEndpointId),
23-
Provider: types.StringPointerValue(apiResp.Provider),
24-
Region: types.StringPointerValue(apiResp.Region),
25-
ServiceEndpointId: types.StringPointerValue(apiResp.ServiceEndpointId),
26-
State: types.StringPointerValue(apiResp.State),
27-
Vendor: types.StringPointerValue(apiResp.Vendor),
19+
Id: types.StringPointerValue(apiResp.Id),
20+
DnsDomain: types.StringPointerValue(apiResp.DnsDomain),
21+
ErrorMessage: types.StringPointerValue(apiResp.ErrorMessage),
22+
ProjectId: types.StringPointerValue(&projectID),
23+
InterfaceEndpointId: types.StringPointerValue(apiResp.InterfaceEndpointId),
24+
InterfaceEndpointName: types.StringPointerValue(apiResp.InterfaceEndpointName),
25+
Provider: types.StringPointerValue(apiResp.Provider),
26+
ProviderAccountId: types.StringPointerValue(apiResp.ProviderAccountId),
27+
Region: types.StringPointerValue(apiResp.Region),
28+
ServiceEndpointId: types.StringPointerValue(apiResp.ServiceEndpointId),
29+
State: types.StringPointerValue(apiResp.State),
30+
Vendor: types.StringPointerValue(apiResp.Vendor),
2831
}
29-
if apiResp.DnsSubDomain != nil {
30-
subdomain, diags := types.ListValueFrom(ctx, types.StringType, apiResp.GetDnsSubDomain())
31-
if diags.HasError() {
32-
return nil, diags
33-
}
34-
result.DnsSubDomain = subdomain
32+
33+
subdomain, diags := types.ListValueFrom(ctx, types.StringType, apiResp.GetDnsSubDomain())
34+
if diags.HasError() {
35+
return nil, diags
3536
}
37+
result.DnsSubDomain = subdomain
3638

3739
return result, nil
3840
}

internal/service/streamprivatelinkendpoint/model_test.go

Lines changed: 44 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,35 @@ type sdkToTFModelTestCase struct {
1919
}
2020

2121
var (
22-
projectID = "projectID"
23-
id = "id"
24-
dnsDomain = "dnsDomain"
25-
dnsSubDomain = "dnsSubDomain"
26-
interfaceEndpointID = "interfaceEndpointId"
27-
provider = "AWS"
28-
region = "us-east-1"
29-
serviceEndpointID = "serviceEndpointId"
30-
state = "DONE"
31-
vendor = "CONFLUENT"
22+
projectID = "projectID"
23+
id = "id"
24+
dnsDomain = "dnsDomain"
25+
dnsSubDomain = "dnsSubDomain"
26+
interfaceEndpointID = "interfaceEndpointId"
27+
interfaceEndpointName = "interfaceEndpointName"
28+
provider = "AWS"
29+
providerAccountID = "providerAccountId"
30+
region = "us-east-1"
31+
serviceEndpointID = "serviceEndpointId"
32+
state = "DONE"
33+
vendor = "CONFLUENT"
3234
)
3335

3436
func TestStreamPrivatelinkEndpointSDKToTFModel(t *testing.T) {
3537
testCases := map[string]sdkToTFModelTestCase{
3638
"Complete SDK response": {
3739
SDKResp: &admin.StreamsPrivateLinkConnection{
38-
Id: &id,
39-
DnsDomain: &dnsDomain,
40-
DnsSubDomain: conversion.Pointer([]string{dnsSubDomain, dnsSubDomain}),
41-
InterfaceEndpointId: &interfaceEndpointID,
42-
Provider: &provider,
43-
Region: &region,
44-
ServiceEndpointId: &serviceEndpointID,
45-
State: &state,
46-
Vendor: &vendor,
40+
Id: &id,
41+
DnsDomain: &dnsDomain,
42+
DnsSubDomain: conversion.Pointer([]string{dnsSubDomain, dnsSubDomain}),
43+
InterfaceEndpointId: &interfaceEndpointID,
44+
InterfaceEndpointName: &interfaceEndpointName,
45+
Provider: &provider,
46+
ProviderAccountId: &providerAccountID,
47+
Region: &region,
48+
ServiceEndpointId: &serviceEndpointID,
49+
State: &state,
50+
Vendor: &vendor,
4751
},
4852
projectID: projectID,
4953
expectedTFModel: &streamprivatelinkendpoint.TFModel{
@@ -53,13 +57,15 @@ func TestStreamPrivatelinkEndpointSDKToTFModel(t *testing.T) {
5357
types.StringValue(dnsSubDomain),
5458
types.StringValue(dnsSubDomain),
5559
}),
56-
ProjectId: types.StringValue(projectID),
57-
InterfaceEndpointId: types.StringValue(interfaceEndpointID),
58-
Provider: types.StringValue(provider),
59-
Region: types.StringValue(region),
60-
ServiceEndpointId: types.StringValue(serviceEndpointID),
61-
State: types.StringValue(state),
62-
Vendor: types.StringValue(vendor),
60+
ProjectId: types.StringValue(projectID),
61+
InterfaceEndpointId: types.StringValue(interfaceEndpointID),
62+
InterfaceEndpointName: types.StringValue(interfaceEndpointName),
63+
Provider: types.StringValue(provider),
64+
ProviderAccountId: types.StringValue(providerAccountID),
65+
Region: types.StringValue(region),
66+
ServiceEndpointId: types.StringValue(serviceEndpointID),
67+
State: types.StringValue(state),
68+
Vendor: types.StringValue(vendor),
6369
},
6470
},
6571
"SDK response without dns subdomains": {
@@ -77,6 +83,7 @@ func TestStreamPrivatelinkEndpointSDKToTFModel(t *testing.T) {
7783
expectedTFModel: &streamprivatelinkendpoint.TFModel{
7884
Id: types.StringValue(id),
7985
DnsDomain: types.StringValue(dnsDomain),
86+
DnsSubDomain: types.ListNull(types.StringType),
8087
ProjectId: types.StringValue(projectID),
8188
InterfaceEndpointId: types.StringValue(interfaceEndpointID),
8289
Provider: types.StringValue(provider),
@@ -89,7 +96,8 @@ func TestStreamPrivatelinkEndpointSDKToTFModel(t *testing.T) {
8996
"Empty SDK response": {
9097
SDKResp: &admin.StreamsPrivateLinkConnection{},
9198
expectedTFModel: &streamprivatelinkendpoint.TFModel{
92-
ProjectId: types.StringValue(""),
99+
ProjectId: types.StringValue(""),
100+
DnsSubDomain: types.ListNull(types.StringType),
93101
},
94102
},
95103
}
@@ -120,13 +128,15 @@ func TestStreamPrivatelinkEndpointTFModelToSDK(t *testing.T) {
120128
types.StringValue(dnsSubDomain),
121129
types.StringValue(dnsSubDomain),
122130
}),
123-
ProjectId: types.StringValue(projectID),
124-
InterfaceEndpointId: types.StringValue(interfaceEndpointID),
125-
Provider: types.StringValue(provider),
126-
Region: types.StringValue(region),
127-
ServiceEndpointId: types.StringValue(serviceEndpointID),
128-
State: types.StringValue(state),
129-
Vendor: types.StringValue(vendor),
131+
ProjectId: types.StringValue(projectID),
132+
InterfaceEndpointId: types.StringValue(interfaceEndpointID),
133+
InterfaceEndpointName: types.StringValue(interfaceEndpointName),
134+
Provider: types.StringValue(provider),
135+
ProviderAccountId: types.StringValue(providerAccountID),
136+
Region: types.StringValue(region),
137+
ServiceEndpointId: types.StringValue(serviceEndpointID),
138+
State: types.StringValue(state),
139+
Vendor: types.StringValue(vendor),
130140
},
131141
expectedSDKReq: &admin.StreamsPrivateLinkConnection{
132142
DnsDomain: &dnsDomain,

internal/service/streamprivatelinkendpoint/resource_migration_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ import (
1010
func TestMigStreamPrivatelinkEndpoint_basic(t *testing.T) {
1111
acc.SkipTestForCI(t) // needs confluent cloud resources
1212
mig.SkipIfVersionBelow(t, "1.25.0") // when resource 1st released
13-
mig.CreateTestAndRunUseExternalProviderNonParallel(t, basicTestCase(t), mig.ExternalProvidersWithConfluent(), nil)
13+
mig.CreateTestAndRunUseExternalProviderNonParallel(t, basicTestCase(t, true), mig.ExternalProvidersWithConfluent(), nil)
1414
}

internal/service/streamprivatelinkendpoint/resource_schema.go

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ func ResourceSchema(ctx context.Context) schema.Schema {
2323
MarkdownDescription: "Sub-Domain name of Confluent cluster. These are typically your availability zones.",
2424
ElementType: types.StringType,
2525
},
26+
"error_message": schema.StringAttribute{
27+
Computed: true,
28+
MarkdownDescription: "Error message if the connection is in a failed state.",
29+
},
2630
"project_id": schema.StringAttribute{
2731
Required: true,
2832
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.",
@@ -31,6 +35,14 @@ func ResourceSchema(ctx context.Context) schema.Schema {
3135
Computed: true,
3236
MarkdownDescription: "Interface endpoint ID that is created from the specified service endpoint ID.",
3337
},
38+
"interface_endpoint_name": schema.StringAttribute{
39+
Computed: true,
40+
MarkdownDescription: "Name of interface endpoint that is created from the specified service endpoint ID.",
41+
},
42+
"provider_account_id": schema.StringAttribute{
43+
Computed: true,
44+
MarkdownDescription: "Account ID from the cloud provider.",
45+
},
3446
"provider_name": schema.StringAttribute{
3547
Required: true,
3648
MarkdownDescription: "Provider where the Kafka cluster is deployed.",
@@ -56,16 +68,19 @@ func ResourceSchema(ctx context.Context) schema.Schema {
5668
}
5769

5870
type TFModel struct {
59-
Id types.String `tfsdk:"id"`
60-
DnsDomain types.String `tfsdk:"dns_domain"`
61-
DnsSubDomain types.List `tfsdk:"dns_sub_domain"`
62-
ProjectId types.String `tfsdk:"project_id"`
63-
InterfaceEndpointId types.String `tfsdk:"interface_endpoint_id"`
64-
Provider types.String `tfsdk:"provider_name"`
65-
Region types.String `tfsdk:"region"`
66-
ServiceEndpointId types.String `tfsdk:"service_endpoint_id"`
67-
State types.String `tfsdk:"state"`
68-
Vendor types.String `tfsdk:"vendor"`
71+
Id types.String `tfsdk:"id"`
72+
DnsDomain types.String `tfsdk:"dns_domain"`
73+
DnsSubDomain types.List `tfsdk:"dns_sub_domain"`
74+
ErrorMessage types.String `tfsdk:"error_message"`
75+
ProjectId types.String `tfsdk:"project_id"`
76+
InterfaceEndpointId types.String `tfsdk:"interface_endpoint_id"`
77+
InterfaceEndpointName types.String `tfsdk:"interface_endpoint_name"`
78+
Provider types.String `tfsdk:"provider_name"`
79+
ProviderAccountId types.String `tfsdk:"provider_account_id"`
80+
Region types.String `tfsdk:"region"`
81+
ServiceEndpointId types.String `tfsdk:"service_endpoint_id"`
82+
State types.String `tfsdk:"state"`
83+
Vendor types.String `tfsdk:"vendor"`
6984
}
7085

7186
type TFModelDSP struct {

internal/service/streamprivatelinkendpoint/resource_test.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,14 @@ var (
2121

2222
func TestAccStreamPrivatelinkEndpoint_basic(t *testing.T) {
2323
acc.SkipTestForCI(t) // needs confluent cloud resources
24-
tc := basicTestCase(t)
24+
tc := basicTestCase(t, true)
25+
// Tests include testing of plural data source and so cannot be run in parallel
26+
resource.Test(t, *tc)
27+
}
28+
29+
func TestAccStreamPrivatelinkEndpoint_noDNSsubdomains(t *testing.T) {
30+
acc.SkipTestForCI(t) // needs confluent cloud resources
31+
tc := basicTestCase(t, false)
2532
// Tests include testing of plural data source and so cannot be run in parallel
2633
resource.Test(t, *tc)
2734
}
@@ -40,7 +47,7 @@ func TestAccStreamPrivatelinkEndpoint_missingRequiredFields(t *testing.T) {
4047
resource.Test(t, *tc)
4148
}
4249

43-
func basicTestCase(t *testing.T) *resource.TestCase {
50+
func basicTestCase(t *testing.T, withDNSSubdomains bool) *resource.TestCase {
4451
t.Helper()
4552

4653
var (
@@ -50,7 +57,7 @@ func basicTestCase(t *testing.T) *resource.TestCase {
5057
awsAccountID = os.Getenv("AWS_ACCOUNT_ID")
5158
networkID = os.Getenv("CONFLUENT_CLOUD_NETWORK_ID")
5259
privatelinkAccessID = os.Getenv("CONFLUENT_CLOUD_PRIVATELINK_ACCESS_ID")
53-
config = acc.GetCompleteConfluentConfig(true, true, projectID, provider, region, vendor, awsAccountID, networkID, privatelinkAccessID)
60+
config = acc.GetCompleteConfluentConfig(true, withDNSSubdomains, projectID, provider, region, vendor, awsAccountID, networkID, privatelinkAccessID)
5461
)
5562

5663
return &resource.TestCase{
@@ -154,8 +161,10 @@ func checksStreamPrivatelinkEndpoint(projectID, provider, region, vendor string,
154161
attrSet := []string{
155162
"id",
156163
"interface_endpoint_id",
164+
"interface_endpoint_name",
157165
"state",
158166
"dns_domain",
167+
"provider_account_id",
159168
"service_endpoint_id",
160169
}
161170
if dnsSubdomainsCheck {

internal/testutil/acc/pre_check.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,6 @@ func PreCheckConfluentAWSPrivatelink(tb testing.TB) {
384384
os.Getenv("CONFLUENT_CLOUD_API_SECRET") == "" ||
385385
os.Getenv("CONFLUENT_CLOUD_NETWORK_ID") == "" ||
386386
os.Getenv("CONFLUENT_CLOUD_PRIVATELINK_ACCESS_ID") == "" {
387-
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")
387+
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")
388388
}
389389
}

0 commit comments

Comments
 (0)