Skip to content

Commit f44b4a9

Browse files
committed
docs: add vpc peering examples for GCP and AWS
fixes #62
1 parent 0e20100 commit f44b4a9

File tree

5 files changed

+130
-3
lines changed

5 files changed

+130
-3
lines changed

docs/resources/cluster.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ output "scylladbcloud_cluster_datacenter" {
4747
### Optional
4848

4949
- `alternator_write_isolation` (String) Default write isolation policy
50-
- `byoa_id` (Number) BYOA credential ID
50+
- `byoa_id` (Number) BYOA credential ID (only for AWS)
5151
- `cidr_block` (String) IPv4 CIDR of the cluster
5252
- `cloud` (String) Cluster name
5353
- `enable_dns` (Boolean) Whether to enable CNAME for seed nodes

docs/resources/vpc_peering.md

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ description: |-
1212
## Example Usage
1313

1414
```terraform
15-
# Create a VPC peering connection top the specified datacenter.
15+
# Create a VPC peering connection to the specified datacenter.
1616
resource "scylladbcloud_vpc_peering" "example" {
1717
cluster_id = 1337
1818
datacenter = "AWS_US_EAST_1"
@@ -30,6 +30,70 @@ output "scylladbcloud_vpc_peering_connection_id" {
3030
}
3131
```
3232

33+
## Example Usage for AWS
34+
35+
```terraform
36+
# End-to-end example for ScyllaDB Datacenter VPC peering on AWS.
37+
resource "aws_vpc" "app" {
38+
cidr_block = "10.0.0.0/16"
39+
}
40+
41+
data "aws_caller_identity" "current" {}
42+
43+
resource "scylladbcloud_vpc_peering" "example" {
44+
cluster_id = 1337
45+
datacenter = "AWS_EAST_1"
46+
47+
peer_vpc_id = aws_vpc.app.id
48+
peer_cidr_block = aws_vpc.app.cidr_block
49+
peer_region = "us-east-1"
50+
peer_account_id = data.aws_caller_identity.current.account_id
51+
52+
allow_cql = true
53+
}
54+
55+
resource "aws_vpc_peering_connection_accepter" "app" {
56+
vpc_peering_connection_id = scylladbcloud_vpc_peering.example.connection_id
57+
auto_accept = true
58+
}
59+
60+
resource "aws_route_table" "bench" {
61+
vpc_id = aws_vpc.app.id
62+
63+
route {
64+
cidr_block = scylladbcloud_cluster.example.cidr_block
65+
vpc_peering_connection_id = aws_vpc_peering_connection_accepter.app.vpc_peering_connection_id
66+
}
67+
}
68+
```
69+
70+
## Example Usage for GCP
71+
72+
```terraform
73+
# End-to-end example for ScyllaDB Datacenter network peering on GCP.
74+
resource "google_compute_network" "app" {
75+
name = "app"
76+
auto_create_subnetworks = true
77+
}
78+
79+
resource "scylladbcloud_vpc_peering" "example" {
80+
cluster_id = 1337
81+
datacenter = "GCE_US_CENTRAL_1"
82+
83+
peer_vpc_id = google_compute_network.app.name
84+
peer_region = "us-central1"
85+
peer_account_id = "exampleproject"
86+
87+
allow_cql = true
88+
}
89+
90+
resource "google_compute_network_peering" "app" {
91+
name = "app-peering"
92+
network = google_compute_network.app.self_link
93+
peer_network = scylladbcloud_vpc_peering.example.network_link
94+
}
95+
```
96+
3397
<!-- schema generated by tfplugindocs -->
3498
## Schema
3599

@@ -38,19 +102,20 @@ output "scylladbcloud_vpc_peering_connection_id" {
38102
- `cluster_id` (Number) Cluster ID
39103
- `datacenter` (String) Cluster datacenter name
40104
- `peer_account_id` (String) Peer Account ID
41-
- `peer_cidr_block` (String) Peer VPC CIDR block
42105
- `peer_region` (String) Peer VPC region
43106
- `peer_vpc_id` (String) Peer VPC ID
44107

45108
### Optional
46109

47110
- `allow_cql` (Boolean) Whether to allow CQL traffic
111+
- `peer_cidr_block` (String) Peer VPC CIDR block
48112
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
49113

50114
### Read-Only
51115

52116
- `connection_id` (String) VPC peering connection id
53117
- `id` (String) The ID of this resource.
118+
- `network_link` (String) (GCP) Cluster VPC network self_link
54119
- `vpc_peering_id` (Number) Cluster VPC Peering ID
55120

56121
<a id="nestedblock--timeouts"></a>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# End-to-end example for ScyllaDB Datacenter VPC peering on AWS.
2+
resource "aws_vpc" "app" {
3+
cidr_block = "10.0.0.0/16"
4+
}
5+
6+
data "aws_caller_identity" "current" {}
7+
8+
resource "scylladbcloud_vpc_peering" "example" {
9+
cluster_id = 1337
10+
datacenter = "AWS_EAST_1"
11+
12+
peer_vpc_id = aws_vpc.app.id
13+
peer_cidr_block = aws_vpc.app.cidr_block
14+
peer_region = "us-east-1"
15+
peer_account_id = data.aws_caller_identity.current.account_id
16+
17+
allow_cql = true
18+
}
19+
20+
resource "aws_vpc_peering_connection_accepter" "app" {
21+
vpc_peering_connection_id = scylladbcloud_vpc_peering.example.connection_id
22+
auto_accept = true
23+
}
24+
25+
resource "aws_route_table" "bench" {
26+
vpc_id = aws_vpc.app.id
27+
28+
route {
29+
cidr_block = scylladbcloud_cluster.example.cidr_block
30+
vpc_peering_connection_id = aws_vpc_peering_connection_accepter.app.vpc_peering_connection_id
31+
}
32+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# End-to-end example for ScyllaDB Datacenter network peering on GCP.
2+
resource "google_compute_network" "app" {
3+
name = "app"
4+
auto_create_subnetworks = true
5+
}
6+
7+
resource "scylladbcloud_vpc_peering" "example" {
8+
cluster_id = 1337
9+
datacenter = "GCE_US_CENTRAL_1"
10+
11+
peer_vpc_id = google_compute_network.app.name
12+
peer_region = "us-central1"
13+
peer_account_id = "exampleproject"
14+
15+
allow_cql = true
16+
}
17+
18+
resource "google_compute_network_peering" "app" {
19+
name = "app-peering"
20+
network = google_compute_network.app.self_link
21+
peer_network = scylladbcloud_vpc_peering.example.network_link
22+
}

templates/resources/vpc_peering.md.tmpl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ description: |-
1313

1414
{{ tffile (printf "examples/resources/%s/resource.tf" .Name)}}
1515

16+
## Example Usage for AWS
17+
18+
{{ tffile (printf "examples/resources/%s/aws.tf" .Name)}}
19+
20+
## Example Usage for GCP
21+
22+
{{ tffile (printf "examples/resources/%s/gcp.tf" .Name)}}
23+
1624
{{ .SchemaMarkdown | trimspace }}
1725

1826
## Import

0 commit comments

Comments
 (0)