Skip to content

Commit 4d5efbc

Browse files
authored
Merge pull request #119 from OpenVPN/update-all-examples
Enhance Terraform resources and examples for CloudConnexa
2 parents e7b8578 + 44b4b37 commit 4d5efbc

File tree

30 files changed

+13006
-302
lines changed

30 files changed

+13006
-302
lines changed

docs/resources/access_group.md

Lines changed: 237 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -13,82 +13,278 @@ Use `cloudconnexa_access_group` to create an Access group.
1313
## Example Usage
1414

1515
```terraform
16-
# Easy example to allow all resources in source and destination
17-
resource "cloudconnexa_access_group" "full_mesh" {
18-
name = "Access Group name"
19-
description = "Add your description here"
16+
# Prerequisites: User groups for different access levels
17+
resource "cloudconnexa_user_group" "developers" {
18+
name = "developers"
19+
description = "Development team"
20+
all_regions_included = true
21+
connect_auth = "ON_PRIOR_AUTH"
22+
internet_access = "SPLIT_TUNNEL_ON"
23+
max_device = "5"
24+
}
25+
26+
resource "cloudconnexa_user_group" "admins" {
27+
name = "admins"
28+
description = "System administrators"
29+
all_regions_included = true
30+
connect_auth = "EVERY_TIME"
31+
internet_access = "SPLIT_TUNNEL_OFF"
32+
max_device = "3"
33+
}
34+
35+
resource "cloudconnexa_user_group" "contractors" {
36+
name = "contractors"
37+
description = "External contractors"
38+
all_regions_included = false
39+
connect_auth = "EVERY_TIME"
40+
internet_access = "RESTRICTED_INTERNET"
41+
max_device = "2"
42+
}
43+
44+
# Networks for different environments
45+
resource "cloudconnexa_network" "production" {
46+
name = "production-network"
47+
description = "Production environment network"
48+
egress = true
49+
internet_access = "SPLIT_TUNNEL_OFF"
50+
}
51+
52+
resource "cloudconnexa_network" "staging" {
53+
name = "staging-network"
54+
description = "Staging environment network"
55+
egress = true
56+
internet_access = "SPLIT_TUNNEL_ON"
57+
}
58+
59+
resource "cloudconnexa_network" "development" {
60+
name = "development-network"
61+
description = "Development environment network"
62+
egress = false
63+
internet_access = "SPLIT_TUNNEL_ON"
64+
}
65+
66+
# Host for database access
67+
resource "cloudconnexa_host" "database_server" {
68+
name = "database-server"
69+
description = "Production database server"
70+
}
71+
72+
# Applications on networks
73+
resource "cloudconnexa_network_application" "prod_api" {
74+
name = "production-api"
75+
description = "Production API application"
76+
network_id = cloudconnexa_network.production.id
77+
78+
routes {
79+
domain = "api.production.example.com"
80+
allow_embedded_ip = false
81+
}
82+
83+
config {
84+
service_types = ["HTTPS", "SSH"]
85+
}
86+
}
87+
88+
resource "cloudconnexa_network_application" "staging_api" {
89+
name = "staging-api"
90+
description = "Staging API application"
91+
network_id = cloudconnexa_network.staging.id
92+
93+
routes {
94+
domain = "api.staging.example.com"
95+
allow_embedded_ip = false
96+
}
97+
98+
config {
99+
service_types = ["HTTPS", "SSH"]
100+
}
101+
}
102+
103+
resource "cloudconnexa_host_application" "database_app" {
104+
name = "database-application"
105+
description = "Database access application"
106+
host_id = cloudconnexa_host.database_server.id
107+
108+
routes {
109+
domain = "db.production.example.com"
110+
allow_embedded_ip = false
111+
}
112+
113+
config {
114+
service_types = ["CUSTOM"]
115+
custom_service_types {
116+
protocol = "TCP"
117+
from_port = 5432
118+
to_port = 5432
119+
}
120+
}
121+
}
122+
123+
# 1. Full mesh access (emergency/admin use case)
124+
resource "cloudconnexa_access_group" "emergency_full_access" {
125+
name = "Emergency Full Access"
126+
description = "Emergency access group for critical situations - grants full access to admins"
127+
20128
source {
129+
type = "USER_GROUP"
130+
all_covered = false
131+
children = [cloudconnexa_user_group.admins.id]
132+
}
133+
134+
destination {
21135
type = "NETWORK"
22136
all_covered = true
23137
}
24-
source {
138+
139+
destination {
25140
type = "HOST"
26141
all_covered = true
27142
}
143+
}
144+
145+
# 2. Production access (admin-only)
146+
resource "cloudconnexa_access_group" "production_access" {
147+
name = "Production Access"
148+
description = "Production environment access for administrators only"
149+
28150
source {
29151
type = "USER_GROUP"
30-
all_covered = true
152+
all_covered = false
153+
children = [cloudconnexa_user_group.admins.id]
31154
}
155+
32156
destination {
33157
type = "NETWORK"
34158
all_covered = true
159+
parent = cloudconnexa_network.production.id
160+
}
161+
}
162+
163+
# 3. Staging access (admins and developers)
164+
resource "cloudconnexa_access_group" "staging_access" {
165+
name = "Staging Access"
166+
description = "Staging environment access for admins and developers"
167+
168+
source {
169+
type = "USER_GROUP"
170+
all_covered = false
171+
children = [
172+
cloudconnexa_user_group.admins.id,
173+
cloudconnexa_user_group.developers.id
174+
]
35175
}
176+
36177
destination {
37-
type = "HOST"
178+
type = "NETWORK"
38179
all_covered = true
180+
parent = cloudconnexa_network.staging.id
39181
}
40-
destination {
182+
}
183+
184+
# 4. Development access (all internal users)
185+
resource "cloudconnexa_access_group" "development_access" {
186+
name = "Development Access"
187+
description = "Development environment access for all internal users"
188+
189+
source {
41190
type = "USER_GROUP"
191+
all_covered = false
192+
children = [
193+
cloudconnexa_user_group.admins.id,
194+
cloudconnexa_user_group.developers.id
195+
]
196+
}
197+
198+
destination {
199+
type = "NETWORK"
42200
all_covered = true
201+
parent = cloudconnexa_network.development.id
43202
}
44203
}
45204
46-
# More advanced example
47-
resource "cloudconnexa_user_group" "ug01" {
48-
name = "ug01"
49-
all_regions_included = true
50-
connect_auth = "ON_PRIOR_AUTH"
51-
internet_access = "SPLIT_TUNNEL_ON"
52-
max_device = "3"
53-
}
205+
# 5. Database access (admin-only, specific application)
206+
resource "cloudconnexa_access_group" "database_access" {
207+
name = "Database Access"
208+
description = "Direct database access for administrators only"
54209
55-
resource "cloudconnexa_network" "this" {
56-
description = "Test network"
57-
egress = true
58-
name = "my_test_network"
59-
internet_access = "SPLIT_TUNNEL_ON"
60-
}
210+
source {
211+
type = "USER_GROUP"
212+
all_covered = false
213+
children = [cloudconnexa_user_group.admins.id]
214+
}
61215
62-
# "cloudconnexa_network_application" added here to create at least 1 entity which will be "child" to resource "cloudconnexa_network"
63-
# otherwise creation of resource "cloudconnexa_access_group" "limited_example1" will fail.
64-
resource "cloudconnexa_network_application" "example1" {
65-
name = "example-application-1"
66-
description = "Managed by Terraform"
67-
network_id = cloudconnexa_network.this.id
68-
routes {
69-
domain = "example-application-1.com"
70-
allow_embedded_ip = false
216+
destination {
217+
type = "HOST"
218+
all_covered = false
219+
children = [cloudconnexa_host_application.database_app.id]
71220
}
221+
}
72222
73-
config {
74-
service_types = ["ANY"]
223+
# 6. Contractor limited access (staging only, specific applications)
224+
resource "cloudconnexa_access_group" "contractor_access" {
225+
name = "Contractor Limited Access"
226+
description = "Limited access for external contractors to staging environment"
227+
228+
source {
229+
type = "USER_GROUP"
230+
all_covered = false
231+
children = [cloudconnexa_user_group.contractors.id]
75232
}
76233
77-
depends_on = [cloudconnexa_network.this]
234+
destination {
235+
type = "NETWORK"
236+
all_covered = false
237+
children = [cloudconnexa_network_application.staging_api.id]
238+
}
78239
}
79240
80-
resource "cloudconnexa_access_group" "limited_example1" {
81-
name = "limited_example1"
82-
description = "Add your description here"
241+
# 7. Cross-environment user group access (developers can access other developers)
242+
resource "cloudconnexa_access_group" "dev_to_dev_communication" {
243+
name = "Developer Communication"
244+
description = "Allow developers to communicate with each other across environments"
245+
83246
source {
84247
type = "USER_GROUP"
85248
all_covered = false
86-
children = [cloudconnexa_user_group.ug01.id]
249+
children = [cloudconnexa_user_group.developers.id]
87250
}
251+
88252
destination {
89-
type = "NETWORK"
90-
all_covered = true
91-
parent = cloudconnexa_network.this.id
253+
type = "USER_GROUP"
254+
all_covered = false
255+
children = [cloudconnexa_user_group.developers.id]
256+
}
257+
}
258+
259+
# Outputs for access group management
260+
output "access_groups" {
261+
description = "Created access groups and their IDs"
262+
value = {
263+
emergency_full_access = cloudconnexa_access_group.emergency_full_access.id
264+
production_access = cloudconnexa_access_group.production_access.id
265+
staging_access = cloudconnexa_access_group.staging_access.id
266+
development_access = cloudconnexa_access_group.development_access.id
267+
database_access = cloudconnexa_access_group.database_access.id
268+
contractor_access = cloudconnexa_access_group.contractor_access.id
269+
dev_to_dev_communication = cloudconnexa_access_group.dev_to_dev_communication.id
270+
}
271+
}
272+
273+
output "network_info" {
274+
description = "Network information for reference"
275+
value = {
276+
production = cloudconnexa_network.production.id
277+
staging = cloudconnexa_network.staging.id
278+
development = cloudconnexa_network.development.id
279+
}
280+
}
281+
282+
output "user_group_info" {
283+
description = "User group information for reference"
284+
value = {
285+
developers = cloudconnexa_user_group.developers.id
286+
admins = cloudconnexa_user_group.admins.id
287+
contractors = cloudconnexa_user_group.contractors.id
92288
}
93289
}
94290
```

0 commit comments

Comments
 (0)