@@ -74,80 +74,40 @@ func ResourceDeployment() *schema.Resource {
7474 Optional : true ,
7575 Description : "Password for the first user of the deployment" ,
7676 },
77- "private_network" : {
78- Type : schema .TypeList ,
79- Optional : true ,
80- Computed : true ,
81- MaxItems : 1 ,
82- Description : "If set, creates a private endpoint. Provide pn_id." ,
83- AtLeastOneOf : []string {"private_network" , "public_network" },
84- Elem : & schema.Resource {
85- Schema : map [string ]* schema.Schema {
86- // Input: private network ID
87- "pn_id" : {
88- Type : schema .TypeString ,
89- Optional : true ,
90- Description : "UUID of the private network for the endpoint" ,
91- },
92- // Computed fields returned from API:
93- "id" : {
94- Type : schema .TypeString ,
95- Computed : true ,
96- Description : "ID of the private endpoint (computed)" ,
97- },
98- "dns_record" : {
99- Type : schema .TypeString ,
100- Computed : true ,
101- Description : "DNS record assigned to the private endpoint (computed)" ,
102- },
103- "protocol" : {
104- Type : schema .TypeString ,
105- Computed : true ,
106- Description : "Service protocol (e.g. \" tcp\" , \" https\" , \" mysql\" ) for the private endpoint" ,
107- },
108- "port" : {
109- Type : schema .TypeInt ,
110- Computed : true ,
111- Description : "TCP port number for the private endpoint" ,
112- },
113- },
114- },
115- },
116-
117- // Computed block: public_network (max 1). Only returned if a public endpoint exists.
118- "public_network" : {
119- Type : schema .TypeList ,
120- Optional : true ,
121- Computed : true ,
122- MaxItems : 1 ,
123- Description : "Details of the public endpoint (computed). At least one of private_network or public_network must be specified." ,
124- AtLeastOneOf : []string {"private_network" , "public_network" },
125- Elem : & schema.Resource {
126- Schema : map [string ]* schema.Schema {
127- "id" : {
128- Type : schema .TypeString ,
129- Computed : true ,
130- Description : "ID of the public endpoint (computed)" ,
131- },
132- "dns_record" : {
133- Type : schema .TypeString ,
134- Computed : true ,
135- Description : "DNS record for the public endpoint (computed)" ,
136- },
137- "protocol" : {
138- Type : schema .TypeString ,
139- Computed : true ,
140- Description : "Service protocol (e.g. \" tcp\" , \" https\" , \" mysql\" ) for the public endpoint" ,
141- },
142- "port" : {
143- Type : schema .TypeInt ,
144- Computed : true ,
145- Description : "TCP port number for the public endpoint" ,
77+ // Public endpoint (optional). If not specified, a public endpoint is created by default.
78+ // Private endpoints are not yet supported by the API.
79+ "public_network" : {
80+ Type : schema .TypeList ,
81+ Optional : true ,
82+ Computed : true ,
83+ MaxItems : 1 ,
84+ Description : "Public endpoint configuration. If not specified, a public endpoint is created by default." ,
85+ Elem : & schema.Resource {
86+ Schema : map [string ]* schema.Schema {
87+ "id" : {
88+ Type : schema .TypeString ,
89+ Computed : true ,
90+ Description : "ID of the public endpoint (computed)" ,
91+ },
92+ "dns_record" : {
93+ Type : schema .TypeString ,
94+ Computed : true ,
95+ Description : "DNS record for the public endpoint (computed)" ,
96+ },
97+ "protocol" : {
98+ Type : schema .TypeString ,
99+ Computed : true ,
100+ Description : "Service protocol (e.g. \" tcp\" , \" https\" , \" mysql\" ) for the public endpoint" ,
101+ },
102+ "port" : {
103+ Type : schema .TypeInt ,
104+ Computed : true ,
105+ Description : "TCP port number for the public endpoint" ,
106+ },
146107 },
147108 },
148109 },
149110 },
150- },
151111 }
152112}
153113
@@ -171,6 +131,14 @@ func resourceDeploymentCreate(ctx context.Context, d *schema.ResourceData, meta
171131 req .Tags = expandStringList (v .([]interface {}))
172132 }
173133
134+ // Build public endpoint for deployment creation (required)
135+ // Note: Private endpoints are not yet supported by the API
136+ req .Endpoints = []* datawarehouseapi.EndpointSpec {
137+ {
138+ Public : & datawarehouseapi.EndpointSpecPublicDetails {},
139+ },
140+ }
141+
174142 deployment , err := api .CreateDeployment (req , scw .WithContext (ctx ))
175143 if err != nil {
176144 return diag .FromErr (err )
@@ -181,40 +149,6 @@ func resourceDeploymentCreate(ctx context.Context, d *schema.ResourceData, meta
181149 return diag .FromErr (err )
182150 }
183151
184- // Create endpoints after deployment is ready
185- if v , ok := d .GetOk ("private_network" ); ok {
186- blk := v .([]interface {})[0 ].(map [string ]interface {})
187- if pnID , _ := blk ["pn_id" ].(string ); pnID != "" {
188- spec := & datawarehouseapi.EndpointSpec {
189- PrivateNetwork : & datawarehouseapi.EndpointSpecPrivateNetworkDetails {
190- PrivateNetworkID : pnID ,
191- },
192- }
193- _ , err := api .CreateEndpoint (& datawarehouseapi.CreateEndpointRequest {
194- Region : region ,
195- DeploymentID : deployment .ID ,
196- Endpoint : spec ,
197- }, scw .WithContext (ctx ))
198- if err != nil {
199- return diag .FromErr (err )
200- }
201- }
202- }
203-
204- if _ , ok := d .GetOk ("public_network" ); ok {
205- spec := & datawarehouseapi.EndpointSpec {
206- Public : & datawarehouseapi.EndpointSpecPublicDetails {},
207- }
208- _ , err := api .CreateEndpoint (& datawarehouseapi.CreateEndpointRequest {
209- Region : region ,
210- DeploymentID : deployment .ID ,
211- Endpoint : spec ,
212- }, scw .WithContext (ctx ))
213- if err != nil {
214- return diag .FromErr (err )
215- }
216- }
217-
218152 d .SetId (deployment .ID )
219153
220154 return resourceDeploymentRead (ctx , d , meta )
@@ -259,13 +193,6 @@ func resourceDeploymentRead(ctx context.Context, d *schema.ResourceData, meta in
259193 _ = d .Set ("public_network" , nil )
260194 }
261195
262- privateBlock , hasPrivate := flattenPrivateNetwork (deployment .Endpoints )
263- if hasPrivate {
264- _ = d .Set ("private_network" , privateBlock .([]map [string ]interface {}))
265- } else {
266- _ = d .Set ("private_network" , nil )
267- }
268-
269196 return nil
270197}
271198
0 commit comments