Skip to content

Commit c07765e

Browse files
committed
docs: add gcp peering example
1 parent fb25bb0 commit c07765e

File tree

5 files changed

+313
-10
lines changed

5 files changed

+313
-10
lines changed

docs/resources/env_aws.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,6 @@ data "altinitycloud_env_aws_status" "this" {
196196
name = altinitycloud_env_aws.this.name
197197
wait_for_applied_spec_revision = altinitycloud_env_aws.this.spec_revision
198198
}
199-
200-
resource "aws_vpc_peering_connection_accepter" "peer" {
201-
vpc_peering_connection_id = data.altinitycloud_env_aws_status.this.peering_connections[0].id
202-
auto_accept = true
203-
}
204199
```
205200

206201
<!-- schema generated by tfplugindocs -->

docs/resources/env_gcp.md

Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,234 @@ Optional:
188188

189189

190190

191+
<a id="nestedatt--maintenance_windows"></a>
192+
### Nested Schema for `maintenance_windows`
193+
194+
Required:
195+
196+
- `days` (List of String) Days on which maintenance can take place.
197+
198+
Possible values:
199+
- "MONDAY"
200+
- "TUESDAY"
201+
- "WEDNESDAY"
202+
- "THURSDAY"
203+
- "FRIDAY"
204+
- "SATURDAY"
205+
- "SUNDAY"
206+
- `hour` (Number) Hour of the day in [0, 23] range.
207+
- `length_in_hours` (Number) Maintenance window length in hours. 4h min, 24h max.
208+
- `name` (String) Maintenance window identifier
209+
210+
Optional:
211+
212+
- `enabled` (Boolean) Set to `true` if maintenance window is enabled, `false` otherwise. (default `false`)
213+
214+
215+
<a id="nestedatt--peering_connections"></a>
216+
### Nested Schema for `peering_connections`
217+
218+
Required:
219+
220+
- `network_name` (String) Target network name.
221+
222+
Optional:
223+
224+
- `project_id` (String) Target network's project ID.
225+
226+
### GCP environment with Network peering:
227+
```terraform
228+
terraform {
229+
required_providers {
230+
google = {
231+
source = "hashicorp/google"
232+
version = "~> 4.0"
233+
}
234+
altinitycloud = {
235+
source = "altinity/altinitycloud"
236+
}
237+
}
238+
}
239+
240+
provider "google" {
241+
}
242+
243+
resource "google_project" "this" {
244+
project_id = "YYYYYYYYYYYYYYYYYY"
245+
name = "ZZZZZZZZZZZZZZZZZZ"
246+
auto_create_network = false
247+
}
248+
249+
resource "google_project_iam_member" "this" {
250+
for_each = toset([
251+
# https://cloud.google.com/iam/docs/understanding-roles
252+
"roles/compute.admin",
253+
"roles/container.admin",
254+
"roles/dns.admin",
255+
"roles/storage.admin",
256+
"roles/storage.hmacKeyAdmin",
257+
"roles/iam.serviceAccountAdmin",
258+
"roles/iam.serviceAccountKeyAdmin",
259+
"roles/iam.serviceAccountTokenCreator",
260+
"roles/iam.serviceAccountUser",
261+
"roles/iam.workloadIdentityPoolAdmin",
262+
"roles/serviceusage.serviceUsageAdmin",
263+
"roles/resourcemanager.projectIamAdmin",
264+
"roles/iap.tunnelResourceAccessor"
265+
])
266+
project = google_project.this.id
267+
role = each.key
268+
member = "group:[email protected]"
269+
}
270+
271+
resource "altinitycloud_env_gcp" "this" {
272+
name = "acme-staging"
273+
gcp_project_id = google_project.this.project_id
274+
region = "us-east1"
275+
zones = ["us-east1-b", "us-east1-d"]
276+
cidr = "10.67.0.0/21"
277+
278+
load_balancers = {
279+
private = {
280+
enabled = true
281+
}
282+
}
283+
284+
node_groups = [
285+
{
286+
node_type = "e2-standard-2"
287+
capacity_per_zone = 10
288+
reservations = ["SYSTEM", "ZOOKEEPER"]
289+
},
290+
{
291+
node_type = "n2d-standard-2"
292+
capacity_per_zone = 10
293+
reservations = ["CLICKHOUSE"]
294+
}
295+
]
296+
297+
peering_connections = {
298+
project_id = "peering-project-id" # Replace with actual peering project ID
299+
network_name = "peering-network-name" # Replace with actual peering network name
300+
}
301+
}
302+
303+
// Since the environment provisioning is an async process, this data source is used to wait for environment to be fully provisioned.
304+
data "altinitycloud_env_gcp_status" "this" {
305+
name = altinitycloud_env_gcp.this.name
306+
wait_for_applied_spec_revision = altinitycloud_env_gcp.this.spec_revision
307+
}
308+
```
309+
310+
<!-- schema generated by tfplugindocs -->
311+
## Schema
312+
313+
### Required
314+
315+
- `cidr` (String) VPC CIDR block from the private IPv4 address ranges as specified in RFC 1918 (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16). At least /21 required. **[IMMUTABLE]**
316+
317+
Examples:
318+
- "10.136.0.0/21"
319+
- "172.20.0.0/21"
320+
- `gcp_project_id` (String) ID of the GCP project ([docs](https://support.google.com/googleapi/answer/7014113?hl=en#:~:text=The%20project%20ID%20is%20a,ID%20or%20create%20your%20own.)) in which to provision GCP resources. **[IMMUTABLE]**
321+
- `name` (String) A globally-unique environment identifier. **[IMMUTABLE]**
322+
323+
- All environment names must start with your account name as prefix.
324+
- ⚠️ Changing environment name after creation will force a resource replacement.
325+
326+
Examples:
327+
- "acme-staging" (where "acme" is your account name)
328+
- `node_groups` (Attributes List) List of node groups. At least one required. (see [below for nested schema](#nestedatt--node_groups))
329+
- `region` (String) GCP region ([docs](https://cloud.google.com/about/locations)). **[IMMUTABLE]**
330+
331+
Examples:
332+
- "us-west1".
333+
334+
### Optional
335+
336+
- `allow_delete_while_disconnected` (Boolean) Set to `true` to allow deletion of the environment while it is disconnected from the cloud connect. If the the environment is not connected during the deletion process you will end up in a delete timeout (default `false`).
337+
- `custom_domain` (String) Custom domain.
338+
339+
Examples:
340+
- "example.com"
341+
- "foo.bar.com"
342+
343+
Before specifying custom domain, please create the following DNS records:
344+
- CNAME _acme-challenge.example.com. $env_name.altinity.cloud.
345+
- (optional, public load balancer)
346+
CNAME *.example.com. _.$env_name.altinity.cloud.
347+
- (optional, internal load balancer)
348+
CNAME *.internal.example.com. _.internal.$env_name.altinity.cloud.
349+
- (optional, vpce)
350+
CNAME *.vpce.example.com. _.vpce.$env_name.altinity.cloud.
351+
- `force_destroy` (Boolean) Locks the environment for accidental deletion when running `terraform destroy` command. Your environment will be deleted, only when setting this parameter to `true`. Once this parameter is set to `true`, there must be a successful `terraform apply` run (before running the `terraform destroy`) to update this value in the state. Without a successful `terraform apply` after this parameter is set, this flag will have no effect. (default `false`)
352+
- `force_destroy_clusters` (Boolean) By default, the destroy operation will not delete any provisioned clusters and the deletion will fail until the clusters get removed. Set to `true` to remove all provisioned clusters as part of the environment deletion process.
353+
- `load_balancers` (Attributes) Load balancers configuration. (see [below for nested schema](#nestedatt--load_balancers))
354+
- `load_balancing_strategy` (String) Load balancing strategy for the environment.
355+
356+
Possible Values:
357+
- "ROUND_ROBIN": load balance traffic across all zones in round-robin fashion (default)
358+
- "ZONE_BEST_EFFORT": keep traffic within same zone
359+
- `maintenance_windows` (Attributes List) List of maintenance windows during which automatic maintenance is permitted. By default updates are applied as soon as they are available. (see [below for nested schema](#nestedatt--maintenance_windows))
360+
- `peering_connections` (Attributes List) Network peering configuration. (see [below for nested schema](#nestedatt--peering_connections))
361+
- `private_service_consumers` (List of String) List of project IDs representing the network's private service consumers.
362+
- `skip_deprovision_on_destroy` (Boolean) Set to `true` will delete without waiting for environment deprovisioning. Use this with precaution, it may end up with dangling resources in your cloud provider (default `false`).
363+
- `zones` (List of String) Explicit list of GCP zones. At least 2 required.
364+
Examples:
365+
- ["us-west1a", "us-west1b"]
366+
367+
### Read-Only
368+
369+
- `id` (String) ID of the environment (automatically generated based on the name)
370+
- `spec_revision` (Number) Spec revision
371+
372+
<a id="nestedatt--node_groups"></a>
373+
### Nested Schema for `node_groups`
374+
375+
Required:
376+
377+
- `capacity_per_zone` (Number) Maximum number of instances per availability zone.
378+
- `node_type` (String) List of node groups. At least one required.
379+
- `reservations` (Set of String) Types of workload that are allowed to be scheduled onto the nodes that belong to this group.
380+
381+
Possible values:
382+
- "SYSTEM" (at least one node group must include a SYSTEM reservation)
383+
- "CLICKHOUSE"
384+
- "ZOOKEEPER"
385+
386+
Optional:
387+
388+
- `name` (String) Unique (among environment node groups) node group identifier.
389+
- `zones` (List of String) Availability zones. Check possible available zones in your cloud provider documentation
390+
391+
392+
<a id="nestedatt--load_balancers"></a>
393+
### Nested Schema for `load_balancers`
394+
395+
Optional:
396+
397+
- `internal` (Attributes) Internal load balancer configuration. Accessible via `*.internal.$env_name.altinity.cloud`. (see [below for nested schema](#nestedatt--load_balancers--internal))
398+
- `public` (Attributes) Public load balancer configuration. Accessible via `*.$env_name.altinity.cloud`. (see [below for nested schema](#nestedatt--load_balancers--public))
399+
400+
<a id="nestedatt--load_balancers--internal"></a>
401+
### Nested Schema for `load_balancers.internal`
402+
403+
Optional:
404+
405+
- `enabled` (Boolean) Set to `true` if load balancer is enabled, `false` otherwise. (default `false`)
406+
- `source_ip_ranges` (List of String) IP addresses/blocks to allow traffic from (default `"0.0.0.0/0"`).
407+
408+
409+
<a id="nestedatt--load_balancers--public"></a>
410+
### Nested Schema for `load_balancers.public`
411+
412+
Optional:
413+
414+
- `enabled` (Boolean) Set to `true` if load balancer is enabled, `false` otherwise. (default `false`)
415+
- `source_ip_ranges` (List of String) IP addresses/blocks to allow traffic from (default `"0.0.0.0/0"`).
416+
417+
418+
191419
<a id="nestedatt--maintenance_windows"></a>
192420
### Nested Schema for `maintenance_windows`
193421

examples/resources/altinitycloud_env_aws/peering/main.tf

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,3 @@ data "altinitycloud_env_aws_status" "this" {
5757
name = altinitycloud_env_aws.this.name
5858
wait_for_applied_spec_revision = altinitycloud_env_aws.this.spec_revision
5959
}
60-
61-
resource "aws_vpc_peering_connection_accepter" "peer" {
62-
vpc_peering_connection_id = data.altinitycloud_env_aws_status.this.peering_connections[0].id
63-
auto_accept = true
64-
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
terraform {
2+
required_providers {
3+
google = {
4+
source = "hashicorp/google"
5+
version = "~> 4.0"
6+
}
7+
altinitycloud = {
8+
source = "altinity/altinitycloud"
9+
}
10+
}
11+
}
12+
13+
provider "google" {
14+
}
15+
16+
resource "google_project" "this" {
17+
project_id = "YYYYYYYYYYYYYYYYYY"
18+
name = "ZZZZZZZZZZZZZZZZZZ"
19+
auto_create_network = false
20+
}
21+
22+
resource "google_project_iam_member" "this" {
23+
for_each = toset([
24+
# https://cloud.google.com/iam/docs/understanding-roles
25+
"roles/compute.admin",
26+
"roles/container.admin",
27+
"roles/dns.admin",
28+
"roles/storage.admin",
29+
"roles/storage.hmacKeyAdmin",
30+
"roles/iam.serviceAccountAdmin",
31+
"roles/iam.serviceAccountKeyAdmin",
32+
"roles/iam.serviceAccountTokenCreator",
33+
"roles/iam.serviceAccountUser",
34+
"roles/iam.workloadIdentityPoolAdmin",
35+
"roles/serviceusage.serviceUsageAdmin",
36+
"roles/resourcemanager.projectIamAdmin",
37+
"roles/iap.tunnelResourceAccessor"
38+
])
39+
project = google_project.this.id
40+
role = each.key
41+
member = "group:[email protected]"
42+
}
43+
44+
resource "altinitycloud_env_gcp" "this" {
45+
name = "acme-staging"
46+
gcp_project_id = google_project.this.project_id
47+
region = "us-east1"
48+
zones = ["us-east1-b", "us-east1-d"]
49+
cidr = "10.67.0.0/21"
50+
51+
load_balancers = {
52+
private = {
53+
enabled = true
54+
}
55+
}
56+
57+
node_groups = [
58+
{
59+
node_type = "e2-standard-2"
60+
capacity_per_zone = 10
61+
reservations = ["SYSTEM", "ZOOKEEPER"]
62+
},
63+
{
64+
node_type = "n2d-standard-2"
65+
capacity_per_zone = 10
66+
reservations = ["CLICKHOUSE"]
67+
}
68+
]
69+
70+
peering_connections = {
71+
project_id = "peering-project-id" # Replace with actual peering project ID
72+
network_name = "peering-network-name" # Replace with actual peering network name
73+
}
74+
}
75+
76+
// Since the environment provisioning is an async process, this data source is used to wait for environment to be fully provisioned.
77+
data "altinitycloud_env_gcp_status" "this" {
78+
name = altinitycloud_env_gcp.this.name
79+
wait_for_applied_spec_revision = altinitycloud_env_gcp.this.spec_revision
80+
}

templates/resources/env_gcp.md.tmpl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ description: |-
1616

1717
{{ .SchemaMarkdown | trimspace }}
1818

19+
### GCP environment with Network peering:
20+
{{tffile "examples/resources/altinitycloud_env_gcp/peering/main.tf"}}
21+
22+
{{ .SchemaMarkdown | trimspace }}
23+
1924
{{- if .HasImport }}
2025
## Import
2126

0 commit comments

Comments
 (0)