Skip to content

Commit 67a44c8

Browse files
authored
feat: Adds support for future_inbound and future_outbound in mongodbatlas_project_ip_addresses data source (#2934)
1 parent a5581eb commit 67a44c8

File tree

8 files changed

+76
-25
lines changed

8 files changed

+76
-25
lines changed

.changelog/2934.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
data-source/mongodbatlas_project_ip_addresses: Adds support for `future_inbound` and `future_outbound` fields
3+
```

docs/data-sources/project_ip_addresses.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ Read-Only:
3737
Read-Only:
3838

3939
- `cluster_name` (String) Human-readable label that identifies the cluster.
40+
- `future_inbound` (List of String) List of future inbound IP addresses associated with the cluster. If your network allows outbound HTTP requests only to specific IP addresses, you must allow access to the following IP addresses so that your application can connect to your Atlas cluster.
41+
- `future_outbound` (List of String) List of future outbound IP addresses associated with the cluster. If your network allows inbound HTTP requests only from specific IP addresses, you must allow access from the following IP addresses so that your Atlas cluster can communicate with your webhooks and KMS.
4042
- `inbound` (List of String) List of inbound IP addresses associated with the cluster. If your network allows outbound HTTP requests only to specific IP addresses, you must allow access to the following IP addresses so that your application can connect to your Atlas cluster.
4143
- `outbound` (List of String) List of outbound IP addresses associated with the cluster. If your network allows inbound HTTP requests only from specific IP addresses, you must allow access from the following IP addresses so that your Atlas cluster can communicate with your webhooks and KMS.
4244

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ require (
3434
go.mongodb.org/atlas v0.37.0
3535
go.mongodb.org/atlas-sdk/v20240530005 v20240530005.0.0
3636
go.mongodb.org/atlas-sdk/v20240805005 v20240805005.0.0
37-
go.mongodb.org/atlas-sdk/v20241113004 v20241113004.0.0
37+
go.mongodb.org/atlas-sdk/v20241113004 v20241113004.1.0
3838
go.mongodb.org/realm v0.1.0
3939
gopkg.in/yaml.v3 v3.0.1
4040
)

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,8 @@ go.mongodb.org/atlas-sdk/v20240805005 v20240805005.0.0 h1:EGTT54tKbDbkhhK+jH5AqI
831831
go.mongodb.org/atlas-sdk/v20240805005 v20240805005.0.0/go.mod h1:UTNpAyiKm/7utu+Nl0FafgjgvS+ONNGEoxBT5g/40WM=
832832
go.mongodb.org/atlas-sdk/v20241113004 v20241113004.0.0 h1:dmIp82dS4foajdKgcKRfr26g0cWE52jQAf+nbgFXr10=
833833
go.mongodb.org/atlas-sdk/v20241113004 v20241113004.0.0/go.mod h1:z6m7PcfItkgV3+mnLuStlTkdTbfUBQJpRyES8tuHNCk=
834+
go.mongodb.org/atlas-sdk/v20241113004 v20241113004.1.0 h1:AvrgNUpVMFnqZZJo4m/Bynr0wlDWM4xjhugCSdX/7mM=
835+
go.mongodb.org/atlas-sdk/v20241113004 v20241113004.1.0/go.mod h1:CABkQ0sbsqRBXR55UwS+0rX91Dx7et0xxq4QBB6qRog=
834836
go.mongodb.org/realm v0.1.0 h1:zJiXyLaZrznQ+Pz947ziSrDKUep39DO4SfA0Fzx8M4M=
835837
go.mongodb.org/realm v0.1.0/go.mod h1:4Vj6iy+Puo1TDERcoh4XZ+pjtwbOzPpzqy3Cwe8ZmDM=
836838
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=

internal/service/projectipaddresses/data_source.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55

66
"github.com/hashicorp/terraform-plugin-framework/datasource"
7+
78
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion"
89
"github.com/mongodb/terraform-provider-mongodbatlas/internal/config"
910
)

internal/service/projectipaddresses/data_source_schema.go

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@ func DataSourceSchema(ctx context.Context) schema.Schema {
3434
Computed: true,
3535
MarkdownDescription: "List of outbound IP addresses associated with the cluster. If your network allows inbound HTTP requests only from specific IP addresses, you must allow access from the following IP addresses so that your Atlas cluster can communicate with your webhooks and KMS.",
3636
},
37+
"future_inbound": schema.ListAttribute{
38+
ElementType: types.StringType,
39+
Computed: true,
40+
MarkdownDescription: "List of future inbound IP addresses associated with the cluster. If your network allows outbound HTTP requests only to specific IP addresses, you must allow access to the following IP addresses so that your application can connect to your Atlas cluster.",
41+
},
42+
"future_outbound": schema.ListAttribute{
43+
ElementType: types.StringType,
44+
Computed: true,
45+
MarkdownDescription: "List of future outbound IP addresses associated with the cluster. If your network allows inbound HTTP requests only from specific IP addresses, you must allow access from the following IP addresses so that your Atlas cluster can communicate with your webhooks and KMS.",
46+
},
3747
},
3848
},
3949
Computed: true,
@@ -57,9 +67,11 @@ type TFServicesModel struct {
5767
}
5868

5969
type TFClusterValueModel struct {
60-
ClusterName types.String `tfsdk:"cluster_name"`
61-
Inbound types.List `tfsdk:"inbound"`
62-
Outbound types.List `tfsdk:"outbound"`
70+
ClusterName types.String `tfsdk:"cluster_name"`
71+
Inbound types.List `tfsdk:"inbound"`
72+
Outbound types.List `tfsdk:"outbound"`
73+
FutureInbound types.List `tfsdk:"future_inbound"`
74+
FutureOutbound types.List `tfsdk:"future_outbound"`
6375
}
6476

6577
var IPAddressesObjectType = types.ObjectType{AttrTypes: map[string]attr.Type{
@@ -72,7 +84,9 @@ var ServicesObjectType = types.ObjectType{AttrTypes: map[string]attr.Type{
7284
}}
7385

7486
var ClusterIPsObjectType = types.ObjectType{AttrTypes: map[string]attr.Type{
75-
"cluster_name": types.StringType,
76-
"inbound": types.ListType{ElemType: types.StringType},
77-
"outbound": types.ListType{ElemType: types.StringType},
87+
"cluster_name": types.StringType,
88+
"inbound": types.ListType{ElemType: types.StringType},
89+
"outbound": types.ListType{ElemType: types.StringType},
90+
"future_inbound": types.ListType{ElemType: types.StringType},
91+
"future_outbound": types.ListType{ElemType: types.StringType},
7892
}}

internal/service/projectipaddresses/model.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ package projectipaddresses
33
import (
44
"context"
55

6+
"go.mongodb.org/atlas-sdk/v20241113004/admin"
7+
68
"github.com/hashicorp/terraform-plugin-framework/diag"
79
"github.com/hashicorp/terraform-plugin-framework/types"
8-
"go.mongodb.org/atlas-sdk/v20241113004/admin"
910
)
1011

1112
func NewTFProjectIPAddresses(ctx context.Context, ipAddresses *admin.GroupIPAddresses) (*TFProjectIpAddressesModel, diag.Diagnostics) {
@@ -14,11 +15,15 @@ func NewTFProjectIPAddresses(ctx context.Context, ipAddresses *admin.GroupIPAddr
1415
for i, cluster := range ipAddresses.Services.GetClusters() {
1516
inbound, _ := types.ListValueFrom(ctx, types.StringType, cluster.GetInbound())
1617
outbound, _ := types.ListValueFrom(ctx, types.StringType, cluster.GetOutbound())
18+
futureInbound, _ := types.ListValueFrom(ctx, types.StringType, cluster.GetFutureInbound())
19+
futureOutbound, _ := types.ListValueFrom(ctx, types.StringType, cluster.GetFutureOutbound())
1720

1821
clusterObjs[i] = TFClusterValueModel{
19-
ClusterName: types.StringPointerValue(cluster.ClusterName),
20-
Inbound: inbound,
21-
Outbound: outbound,
22+
ClusterName: types.StringPointerValue(cluster.ClusterName),
23+
Inbound: inbound,
24+
Outbound: outbound,
25+
FutureInbound: futureInbound,
26+
FutureOutbound: futureOutbound,
2227
}
2328
}
2429

internal/service/projectipaddresses/model_test.go

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ import (
44
"context"
55
"testing"
66

7+
"go.mongodb.org/atlas-sdk/v20241113004/admin"
8+
79
"github.com/hashicorp/terraform-plugin-framework/attr"
810
"github.com/hashicorp/terraform-plugin-framework/types"
9-
"github.com/mongodb/terraform-provider-mongodbatlas/internal/service/projectipaddresses"
1011
"github.com/stretchr/testify/assert"
11-
"go.mongodb.org/atlas-sdk/v20241113004/admin"
12+
13+
"github.com/mongodb/terraform-provider-mongodbatlas/internal/service/projectipaddresses"
1214
)
1315

1416
const (
@@ -28,14 +30,18 @@ func TestProjectIPAddressesSDKToTFModel(t *testing.T) {
2830
Services: &admin.GroupService{
2931
Clusters: &[]admin.ClusterIPAddresses{
3032
{
31-
ClusterName: admin.PtrString("cluster1"),
32-
Inbound: &[]string{"192.168.1.1", "192.168.1.2"},
33-
Outbound: &[]string{"10.0.0.1", "10.0.0.2"},
33+
ClusterName: admin.PtrString("cluster1"),
34+
Inbound: &[]string{"192.168.1.1", "192.168.1.2"},
35+
Outbound: &[]string{"10.0.0.1", "10.0.0.2"},
36+
FutureInbound: &[]string{"192.168.1.1", "192.168.1.2"},
37+
FutureOutbound: &[]string{"10.0.0.1", "10.0.0.2"},
3438
},
3539
{
36-
ClusterName: admin.PtrString("cluster2"),
37-
Inbound: &[]string{"192.168.2.1"},
38-
Outbound: &[]string{"10.0.1.1"},
40+
ClusterName: admin.PtrString("cluster2"),
41+
Inbound: &[]string{"192.168.2.1"},
42+
Outbound: &[]string{"10.0.1.1"},
43+
FutureInbound: &[]string{"192.168.2.1"},
44+
FutureOutbound: &[]string{"10.0.1.1"},
3945
},
4046
},
4147
},
@@ -53,6 +59,14 @@ func TestProjectIPAddressesSDKToTFModel(t *testing.T) {
5359
types.StringValue("10.0.0.1"),
5460
types.StringValue("10.0.0.2"),
5561
}),
62+
FutureInbound: types.ListValueMust(types.StringType, []attr.Value{
63+
types.StringValue("192.168.1.1"),
64+
types.StringValue("192.168.1.2"),
65+
}),
66+
FutureOutbound: types.ListValueMust(types.StringType, []attr.Value{
67+
types.StringValue("10.0.0.1"),
68+
types.StringValue("10.0.0.2"),
69+
}),
5670
},
5771
{
5872
ClusterName: types.StringValue("cluster2"),
@@ -62,6 +76,12 @@ func TestProjectIPAddressesSDKToTFModel(t *testing.T) {
6276
Outbound: types.ListValueMust(types.StringType, []attr.Value{
6377
types.StringValue("10.0.1.1"),
6478
}),
79+
FutureInbound: types.ListValueMust(types.StringType, []attr.Value{
80+
types.StringValue("192.168.2.1"),
81+
}),
82+
FutureOutbound: types.ListValueMust(types.StringType, []attr.Value{
83+
types.StringValue("10.0.1.1"),
84+
}),
6585
},
6686
}),
6787
},
@@ -72,9 +92,11 @@ func TestProjectIPAddressesSDKToTFModel(t *testing.T) {
7292
Services: &admin.GroupService{
7393
Clusters: &[]admin.ClusterIPAddresses{
7494
{
75-
ClusterName: admin.PtrString("cluster1"),
76-
Inbound: &[]string{},
77-
Outbound: &[]string{},
95+
ClusterName: admin.PtrString("cluster1"),
96+
Inbound: &[]string{},
97+
Outbound: &[]string{},
98+
FutureInbound: &[]string{},
99+
FutureOutbound: &[]string{},
78100
},
79101
},
80102
},
@@ -83,9 +105,11 @@ func TestProjectIPAddressesSDKToTFModel(t *testing.T) {
83105
ProjectId: types.StringValue(dummyProjectID),
84106
Services: createExpectedServices(t, []projectipaddresses.TFClusterValueModel{
85107
{
86-
ClusterName: types.StringValue("cluster1"),
87-
Inbound: types.ListValueMust(types.StringType, []attr.Value{}),
88-
Outbound: types.ListValueMust(types.StringType, []attr.Value{}),
108+
ClusterName: types.StringValue("cluster1"),
109+
Inbound: types.ListValueMust(types.StringType, []attr.Value{}),
110+
Outbound: types.ListValueMust(types.StringType, []attr.Value{}),
111+
FutureInbound: types.ListValueMust(types.StringType, []attr.Value{}),
112+
FutureOutbound: types.ListValueMust(types.StringType, []attr.Value{}),
89113
},
90114
}),
91115
},

0 commit comments

Comments
 (0)