Skip to content

snowplow-devops/terraform-google-service-ce

Repository files navigation

Release CI License Registry

terraform-google-service-ce

A Terraform module which forms the base of all ce deployments for Snowplow OS services where we deploy a group of nodes running one or more services. This module serves to reduce the boilerplate code that we incur otherwise to simplify maintenance across all of our OS modules.

The default startup-script.sh that is pre-pended to all servers launched contains a few helpful bash functions:

  1. get_instance_id: Will return the instance/id of the server which we use primarily for Telemetry capture
  2. get_application_memory_mb: Will return the amount of memory that can be assigned to a service running on the box. It factors in a minimum allocation for the operating system and then returns a percentage of the available memory to assign.
  • Default is 80% of the available memory to the service and 384mb for the Operating System left available
  • Both settings can be overriden with positional arguments (e.g. get_application_memory_mb 60 500 would allocate 60% to the service and 500mb to the OS)

Requirements

Name Version
terraform >= 1.0.0
google >= 3.44.0

Providers

Name Version
google >= 3.44.0

Modules

No modules.

Resources

Name Type
google_compute_health_check.hc resource
google_compute_instance_template.tpl resource
google_compute_region_instance_group_manager.grp resource
google_compute_image.ubuntu_20_04 data source

Inputs

Name Description Type Default Required
instance_group_version_name A name to give to the instance group version control (e.g. app_name + app_version) string n/a yes
name A name which will be pre-pended to the resources created string n/a yes
network The name of the network to deploy within string n/a yes
region The name of the region to deploy within string n/a yes
service_account_email The name of the service account email address to bind to the deployment string n/a yes
user_supplied_script The user-data script extension to execute string n/a yes
associate_public_ip_address Whether to assign a public ip address to this instance; if false this instance must be behind a Cloud NAT to connect to the internet bool true no
health_check_path The path to bind for health checks string "" no
ingress_port The port that the service will be bound to and exposed over HTTP number -1 no
labels The labels to append to this resource map(string) {} no
machine_type The machine type to use string "e2-small" no
named_port_http The name to give to the bound port on the instance group string "" no
ssh_block_project_keys Whether to block project wide SSH keys bool true no
ssh_key_pairs The list of SSH key-pairs to add to the servers
list(object({
user_name = string
public_key = string
}))
[] no
subnetwork The name of the sub-network to deploy within; if populated will override the 'network' setting string "" no
target_size The number of servers to deploy number 1 no
ubuntu_20_04_source_image The source image to use which must be based of of Ubuntu 20.04; by default the latest community version is used string "" no

Outputs

Name Description
health_check_id Identifier for the health check on the instance group
health_check_self_link The URL for the health check on the instance group
instance_group_url The full URL of the instance group created by the manager
manager_id Identifier for the instance group manager
manager_self_link The URL for the instance group manager
named_port_http The name of the port exposed by the instance group
named_port_value The named port value (e.g. 8080)

Copyright and license

The Google Service CE project is Copyright 2023-present Snowplow Analytics Ltd.

Licensed under the Snowplow Community License. (If you are uncertain how it applies to your use case, check our answers to frequently asked questions.)

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.