-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added submodule for cloud memorystore (memcache) (#22)
- Loading branch information
1 parent
2bdf5f3
commit 6067568
Showing
22 changed files
with
593 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* Copyright 2019 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
provider "google-beta" { | ||
version = "~> 3.31.0" | ||
} | ||
|
||
module "private-service-access" { | ||
source = "GoogleCloudPlatform/sql-db/google//modules/private_service_access" | ||
version = "3.2.0" | ||
project_id = var.project | ||
vpc_network = "default" | ||
} | ||
|
||
module "memcache" { | ||
source = "../../modules/memcache" | ||
name = var.name | ||
project = can(module.private-service-access.peering_completed) ? var.project : "" | ||
memory_size_mb = var.memory_size_mb | ||
enable_apis = var.enable_apis | ||
cpu_count = var.cpu_count | ||
region = var.region | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* Copyright 2019 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
|
||
output "project_id" { | ||
value = var.project | ||
} | ||
|
||
output "name" { | ||
value = var.name | ||
} | ||
|
||
output "region" { | ||
value = var.region | ||
} | ||
|
||
output "cpu_count" { | ||
value = var.cpu_count | ||
} | ||
|
||
output "memory_size_mb" { | ||
value = var.memory_size_mb | ||
} | ||
|
||
output "output_id" { | ||
value = module.memcache.id | ||
} | ||
|
||
output "output_region" { | ||
value = module.memcache.region | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/** | ||
* Copyright 2019 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
variable "project" { | ||
description = "The ID of the project in which the resource belongs to." | ||
type = string | ||
} | ||
|
||
variable "name" { | ||
description = "Name of memcache instance." | ||
type = string | ||
default = "example-memcache" | ||
} | ||
|
||
variable "region" { | ||
description = "Region to create test instance." | ||
type = string | ||
default = "us-east1" | ||
} | ||
|
||
variable "memory_size_mb" { | ||
description = "Memory size of test instance." | ||
type = number | ||
default = 1024 | ||
} | ||
|
||
variable "cpu_count" { | ||
description = "Number of cpu's for test instance." | ||
type = number | ||
default = 1 | ||
} | ||
|
||
variable "enable_apis" { | ||
description = "Flag for enabling memcache.googleapis.com in your project" | ||
type = bool | ||
default = true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* Copyright 2019 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
terraform { | ||
required_version = ">= 0.12" | ||
required_providers { | ||
google = ">= 3.14.0" | ||
google-beta = ">= 3.31.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# [Google Cloud Memorystore Terraform Module](https://registry.terraform.io/modules/terraform-google-modules/memorystore/google/) | ||
|
||
A Terraform module for creating a fully functional Google Memorystore (memcache) instance. | ||
|
||
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --> | ||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|------|-------------|:----:|:-----:|:-----:| | ||
| authorized\_network | The full name of the Google Compute Engine network to which the instance is connected. If left unspecified, the default network will be used. | string | `"null"` | no | | ||
| cpu\_count | Number of CPUs per node | number | `"1"` | no | | ||
| display\_name | An arbitrary and optional user-provided name for the instance. | string | `"null"` | no | | ||
| enable\_apis | Flag for enabling memcache.googleapis.com in your project | bool | `"true"` | no | | ||
| labels | The resource labels to represent user provided metadata. | map(string) | `<map>` | no | | ||
| memory\_size\_mb | Memcache memory size in MiB. Defaulted to 1024 | number | `"1024"` | no | | ||
| name | The ID of the instance or a fully qualified identifier for the instance. | string | n/a | yes | | ||
| node\_count | Number of nodes in the memcache instance. | number | `"1"` | no | | ||
| params | Parameters for the memcache process | map(string) | `"null"` | no | | ||
| project | The ID of the project in which the resource belongs to. | string | n/a | yes | | ||
| region | The GCP region to use. | string | n/a | yes | | ||
| reserved\_ip\_range | The CIDR range of internal addresses that are reserved for this instance. | string | `"null"` | no | | ||
| zones | Zones where memcache nodes should be provisioned. If not provided, all zones will be used. | list(string) | `"null"` | no | | ||
|
||
## Outputs | ||
|
||
| Name | Description | | ||
|------|-------------| | ||
| id | The memorystore instance ID. | | ||
| region | The region the instance lives in. | | ||
|
||
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** | ||
* Copyright 2019 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
resource "google_memcache_instance" "self" { | ||
depends_on = [module.enable_apis] | ||
provider = google-beta | ||
project = var.project | ||
zones = var.zones | ||
name = var.name | ||
region = var.region | ||
authorized_network = var.authorized_network | ||
node_count = var.node_count | ||
display_name = var.display_name == null ? var.display_name : var.name | ||
labels = var.labels | ||
|
||
node_config { | ||
cpu_count = var.cpu_count | ||
memory_size_mb = var.memory_size_mb | ||
} | ||
|
||
dynamic "memcache_parameters" { | ||
for_each = var.params == null ? [] : [var.params] | ||
content { | ||
params = memcache_parameters.value | ||
} | ||
} | ||
|
||
} | ||
|
||
|
||
module "enable_apis" { | ||
source = "terraform-google-modules/project-factory/google//modules/project_services" | ||
version = "8.0.1" | ||
|
||
project_id = var.project | ||
enable_apis = var.enable_apis | ||
|
||
activate_apis = [ | ||
"memcache.googleapis.com", | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* Copyright 2019 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
output "id" { | ||
description = "The memorystore instance ID." | ||
value = google_memcache_instance.self.id | ||
} | ||
|
||
output "region" { | ||
description = "The region the instance lives in." | ||
value = google_memcache_instance.self.region | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/** | ||
* Copyright 2019 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
variable "region" { | ||
description = "The GCP region to use." | ||
type = string | ||
} | ||
|
||
variable "project" { | ||
description = "The ID of the project in which the resource belongs to." | ||
type = string | ||
} | ||
|
||
variable "enable_apis" { | ||
description = "Flag for enabling memcache.googleapis.com in your project" | ||
type = bool | ||
default = true | ||
} | ||
|
||
variable "name" { | ||
description = "The ID of the instance or a fully qualified identifier for the instance." | ||
type = string | ||
} | ||
|
||
variable "authorized_network" { | ||
description = "The full name of the Google Compute Engine network to which the instance is connected. If left unspecified, the default network will be used." | ||
type = string | ||
default = null | ||
} | ||
|
||
variable "node_count" { | ||
description = "Number of nodes in the memcache instance." | ||
type = number | ||
default = 1 | ||
} | ||
|
||
variable "cpu_count" { | ||
description = "Number of CPUs per node" | ||
type = number | ||
default = 1 | ||
} | ||
|
||
variable "memory_size_mb" { | ||
description = "Memcache memory size in MiB. Defaulted to 1024" | ||
type = number | ||
default = 1024 | ||
} | ||
|
||
variable "zones" { | ||
description = "Zones where memcache nodes should be provisioned. If not provided, all zones will be used." | ||
type = list(string) | ||
default = null | ||
} | ||
|
||
variable "display_name" { | ||
description = "An arbitrary and optional user-provided name for the instance." | ||
type = string | ||
default = null | ||
} | ||
|
||
variable "reserved_ip_range" { | ||
description = "The CIDR range of internal addresses that are reserved for this instance." | ||
type = string | ||
default = null | ||
} | ||
|
||
variable "labels" { | ||
description = "The resource labels to represent user provided metadata." | ||
type = map(string) | ||
default = {} | ||
} | ||
|
||
variable "params" { | ||
description = "Parameters for the memcache process" | ||
type = map(string) | ||
default = null | ||
} |
Oops, something went wrong.