Skip to content

Commit 4ed6df5

Browse files
Dev implement service instance sharing resource (#1) (#132)
Co-authored-by: Sylwester Lewandowski <[email protected]>
1 parent b489be4 commit 4ed6df5

11 files changed

+836
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
page_title: "cloudfoundry_service_instance_sharing Resource - terraform-provider-cloudfoundry"
3+
subcategory: ""
4+
description: |-
5+
Provides a resource for managing service instance sharing in Cloud Foundry.
6+
---
7+
8+
# cloudfoundry_service_instance_sharing (Resource)
9+
10+
Provides a resource for managing service instance sharing in Cloud Foundry.
11+
12+
## Example Usage
13+
14+
```terraform
15+
data "cloudfoundry_org" "my-org" {
16+
name = var.org_name
17+
}
18+
19+
data "cloudfoundry_space" "current-space" {
20+
name = "current-space"
21+
org = data.cloudfoundry_org.my-org.id
22+
}
23+
24+
data "cloudfoundry_space" "space-to-share-with" {
25+
name = var.space_name
26+
org = data.cloudfoundry_org.my-org.id
27+
}
28+
29+
data "cloudfoundry_space" "another-space-to-share-with" {
30+
name = var.space_name
31+
org = data.cloudfoundry_org.my-org.id
32+
}
33+
34+
# existing service instance
35+
data "cloudfoundry_service_instance" "svc" {
36+
name = var.service_instance_name
37+
space = data.cloudfoundry_space.current-space.id
38+
}
39+
40+
resource "cloudfoundry_service_instance_sharing" "instance_sharing" {
41+
service_instance = data.cloudfoundry_service_instance.svc.id
42+
spaces = [data.cloudfoundry_space.space-to-share-with.id, data.cloudfoundry_space.another-space-to-share-with.id]
43+
}
44+
```
45+
46+
<!-- schema generated by tfplugindocs -->
47+
## Schema
48+
49+
### Required
50+
51+
- `service_instance` (String) The ID of the service instance to share.
52+
- `spaces` (Set of String) The IDs of the spaces to share the service instance with.
53+
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
data "cloudfoundry_org" "my-org" {
2+
name = var.org_name
3+
}
4+
5+
data "cloudfoundry_space" "current-space" {
6+
name = "current-space"
7+
org = data.cloudfoundry_org.my-org.id
8+
}
9+
10+
data "cloudfoundry_space" "space-to-share-with" {
11+
name = var.space_name
12+
org = data.cloudfoundry_org.my-org.id
13+
}
14+
15+
data "cloudfoundry_space" "another-space-to-share-with" {
16+
name = var.space_name
17+
org = data.cloudfoundry_org.my-org.id
18+
}
19+
20+
# existing service instance
21+
data "cloudfoundry_service_instance" "svc" {
22+
name = var.service_instance_name
23+
space = data.cloudfoundry_space.current-space.id
24+
}
25+
26+
resource "cloudfoundry_service_instance_sharing" "instance_sharing" {
27+
service_instance = data.cloudfoundry_service_instance.svc.id
28+
spaces = [data.cloudfoundry_space.space-to-share-with.id, data.cloudfoundry_space.another-space-to-share-with.id]
29+
}

go.sum

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/C
9393
github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
9494
github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY=
9595
github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
96+
9697
github.com/hashicorp/hc-install v0.9.2 h1:v80EtNX4fCVHqzL9Lg/2xkp62bbvQMnvPQ0G+OmtO24=
9798
github.com/hashicorp/hc-install v0.9.2/go.mod h1:XUqBQNnuT4RsxoxiM9ZaUk0NX8hi2h+Lb6/c0OZnC/I=
9899
github.com/hashicorp/hcl/v2 v2.23.0 h1:Fphj1/gCylPxHutVSEOf2fBOh1VE4AuLV7+kbJf3qos=
Lines changed: 270 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,270 @@
1+
---
2+
version: 2
3+
interactions:
4+
- id: 0
5+
request:
6+
proto: HTTP/1.1
7+
proto_major: 1
8+
proto_minor: 1
9+
content_length: 55
10+
transfer_encoding: []
11+
trailer: {}
12+
host: api.x.x.x.x.com
13+
remote_addr: ""
14+
request_uri: ""
15+
body: |
16+
{"data":[{"guid":"02c0cc92-6ecc-44b1-b7b2-096ca19ee143"}, {"guid":"121c3a95-0f82-45a6-8ff2-1920b2067edb"}]}
17+
form: {}
18+
headers:
19+
Authorization:
20+
- Bearer redacted
21+
Content-Type:
22+
- application/json
23+
User-Agent:
24+
- Go-CF-Client/3.0
25+
url: https://api.x.x.x.x.com/v3/service_instances/5e2976bb-332e-41e1-8be3-53baafea9296/relationships/shared_spaces
26+
method: POST
27+
response:
28+
proto: HTTP/2.0
29+
proto_major: 2
30+
proto_minor: 0
31+
transfer_encoding: []
32+
trailer: {}
33+
content_length: -1
34+
uncompressed: false
35+
body: '{"data":[{"guid":"02c0cc92-6ecc-44b1-b7b2-096ca19ee143"}, {"guid":"121c3a95-0f82-45a6-8ff2-1920b2067edb"}]}'
36+
headers:
37+
Content-Type:
38+
- application/json; charset=utf-8
39+
Date:
40+
- Mon, 08 Apr 2024 05:46:03 GMT
41+
Referrer-Policy:
42+
- strict-origin-when-cross-origin
43+
Server:
44+
- nginx
45+
Strict-Transport-Security:
46+
- max-age=31536000; includeSubDomains; preload;
47+
X-B3-Spanid:
48+
- 5d39517517b023e0
49+
X-B3-Traceid:
50+
- eb5c25e31153450e5d39517517b023e0
51+
X-Content-Type-Options:
52+
- nosniff
53+
X-Download-Options:
54+
- noopen
55+
X-Frame-Options:
56+
- SAMEORIGIN
57+
X-Permitted-Cross-Domain-Policies:
58+
- none
59+
X-Ratelimit-Limit:
60+
- "20000"
61+
X-Ratelimit-Remaining:
62+
- "18000"
63+
X-Ratelimit-Reset:
64+
- "1711364588"
65+
X-Runtime:
66+
- "0.025567"
67+
X-Vcap-Request-Id:
68+
- eb5c25e3-1153-450e-5d39-517517b023e0::f68173e6-bc61-4835-a38a-100217e10639
69+
X-Xss-Protection:
70+
- 1; mode=block
71+
status: 200 OK
72+
code: 200
73+
duration: 1.438484375s
74+
- id: 1
75+
request:
76+
proto: HTTP/1.1
77+
proto_major: 1
78+
proto_minor: 1
79+
content_length: 0
80+
transfer_encoding: []
81+
trailer: {}
82+
host: api.x.x.x.x.com
83+
remote_addr: ""
84+
request_uri: ""
85+
body: ""
86+
form: {}
87+
headers:
88+
Authorization:
89+
- Bearer redacted
90+
User-Agent:
91+
- Go-CF-Client/3.0
92+
url: https://api.x.x.x.x.com/v3/service_instances/5e2976bb-332e-41e1-8be3-53baafea9296/shared_spaces
93+
method: GET
94+
response:
95+
proto: HTTP/2.0
96+
proto_major: 2
97+
proto_minor: 0
98+
transfer_encoding: []
99+
trailer: {}
100+
content_length: -1
101+
uncompressed: false
102+
body: '{"data":[{"guid":"02c0cc92-6ecc-44b1-b7b2-096ca19ee143"}, {"guid":"121c3a95-0f82-45a6-8ff2-1920b2067edb"}]}'
103+
headers:
104+
Content-Type:
105+
- application/json; charset=utf-8
106+
Date:
107+
- Mon, 25 Mar 2024 10:39:34 GMT
108+
Referrer-Policy:
109+
- strict-origin-when-cross-origin
110+
Server:
111+
- nginx
112+
Strict-Transport-Security:
113+
- max-age=31536000; includeSubDomains; preload;
114+
X-B3-Spanid:
115+
- 7031327687a56f81
116+
X-B3-Traceid:
117+
- de8d237a1f2045057031327687a56f81
118+
X-Content-Type-Options:
119+
- nosniff
120+
X-Download-Options:
121+
- noopen
122+
X-Frame-Options:
123+
- SAMEORIGIN
124+
X-Permitted-Cross-Domain-Policies:
125+
- none
126+
X-Ratelimit-Limit:
127+
- "20000"
128+
X-Ratelimit-Remaining:
129+
- "18000"
130+
X-Ratelimit-Reset:
131+
- "1711364588"
132+
X-Runtime:
133+
- "0.058984"
134+
X-Vcap-Request-Id:
135+
- de8d237a-1f20-4505-7031-327687a56f81::f3bea4eb-8c5a-432a-8d19-f256a2758e80
136+
X-Xss-Protection:
137+
- 1; mode=block
138+
status: 200 OK
139+
code: 200
140+
duration: 225.980057ms
141+
- id: 2
142+
request:
143+
proto: HTTP/1.1
144+
proto_major: 1
145+
proto_minor: 1
146+
content_length: 0
147+
transfer_encoding: []
148+
trailer: {}
149+
host: api.x.x.x.x.com
150+
remote_addr: ""
151+
request_uri: ""
152+
body: ""
153+
form: {}
154+
headers:
155+
Authorization:
156+
- Bearer redacted
157+
User-Agent:
158+
- Go-CF-Client/3.0
159+
url: https://api.x.x.x.x.com/v3/service_instances/5e2976bb-332e-41e1-8be3-53baafea9296/relationships/shared_spaces/02c0cc92-6ecc-44b1-b7b2-096ca19ee143
160+
method: DELETE
161+
response:
162+
proto: HTTP/2.0
163+
proto_major: 2
164+
proto_minor: 0
165+
transfer_encoding: []
166+
trailer: {}
167+
content_length: 0
168+
uncompressed: false
169+
body: ""
170+
headers:
171+
Date:
172+
- Mon, 25 Mar 2024 10:39:37 GMT
173+
Referrer-Policy:
174+
- strict-origin-when-cross-origin
175+
Server:
176+
- nginx
177+
Strict-Transport-Security:
178+
- max-age=31536000; includeSubDomains; preload;
179+
X-B3-Spanid:
180+
- 705e6fa76fcf3408
181+
X-B3-Traceid:
182+
- 45373a79229e437c705e6fa76fcf3408
183+
X-Content-Type-Options:
184+
- nosniff
185+
X-Download-Options:
186+
- noopen
187+
X-Frame-Options:
188+
- SAMEORIGIN
189+
X-Permitted-Cross-Domain-Policies:
190+
- none
191+
X-Ratelimit-Limit:
192+
- "20000"
193+
X-Ratelimit-Remaining:
194+
- "18000"
195+
X-Ratelimit-Reset:
196+
- "1711364588"
197+
X-Runtime:
198+
- "0.030300"
199+
X-Vcap-Request-Id:
200+
- 45373a79-229e-437c-705e-6fa76fcf3408::d3a15966-63f3-4613-a6c5-25d1cdad8f07
201+
X-Xss-Protection:
202+
- 1; mode=block
203+
status: 204 No Content
204+
code: 204
205+
duration: 204.222897ms
206+
- id: 3
207+
request:
208+
proto: HTTP/1.1
209+
proto_major: 1
210+
proto_minor: 1
211+
content_length: 0
212+
transfer_encoding: []
213+
trailer: {}
214+
host: api.x.x.x.x.com
215+
remote_addr: ""
216+
request_uri: ""
217+
body: ""
218+
form: {}
219+
headers:
220+
Authorization:
221+
- Bearer redacted
222+
User-Agent:
223+
- Go-CF-Client/3.0
224+
url: https://api.x.x.x.x.com/v3/service_instances/5e2976bb-332e-41e1-8be3-53baafea9296/relationships/shared_spaces/121c3a95-0f82-45a6-8ff2-1920b2067edb
225+
method: DELETE
226+
response:
227+
proto: HTTP/2.0
228+
proto_major: 2
229+
proto_minor: 0
230+
transfer_encoding: []
231+
trailer: {}
232+
content_length: 0
233+
uncompressed: false
234+
body: ""
235+
headers:
236+
Date:
237+
- Mon, 25 Mar 2024 10:39:37 GMT
238+
Referrer-Policy:
239+
- strict-origin-when-cross-origin
240+
Server:
241+
- nginx
242+
Strict-Transport-Security:
243+
- max-age=31536000; includeSubDomains; preload;
244+
X-B3-Spanid:
245+
- 705e6fa76fcf3408
246+
X-B3-Traceid:
247+
- 45373a79229e437c705e6fa76fcf3408
248+
X-Content-Type-Options:
249+
- nosniff
250+
X-Download-Options:
251+
- noopen
252+
X-Frame-Options:
253+
- SAMEORIGIN
254+
X-Permitted-Cross-Domain-Policies:
255+
- none
256+
X-Ratelimit-Limit:
257+
- "20000"
258+
X-Ratelimit-Remaining:
259+
- "18000"
260+
X-Ratelimit-Reset:
261+
- "1711364588"
262+
X-Runtime:
263+
- "0.030300"
264+
X-Vcap-Request-Id:
265+
- 45373a79-229e-437c-705e-6fa76fcf3408::d3a15966-63f3-4613-a6c5-25d1cdad8f07
266+
X-Xss-Protection:
267+
- 1; mode=block
268+
status: 204 No Content
269+
code: 204
270+
duration: 204.222897ms

0 commit comments

Comments
 (0)