Skip to content

Commit

Permalink
feat: allow users to pass pre-start script
Browse files Browse the repository at this point in the history
  • Loading branch information
creynolds15 committed May 1, 2023
1 parent f3589ff commit 56266f5
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# GCP Tamr VM module

## v2.2.0 - April 28th 2023
* Following optional input variables now available
* pre_start_script_content
* Allow users to supply custom script to prepare VM

## v2.1.0 - April 25th 2023
* Following optional input variables now available
* metadata
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ This modules creates:
| tamr\_zip\_uri | gcs location to download tamr zip from | `string` | n/a | yes |
| labels | labels to attach to created resources | `map(string)` | `{}` | no |
| metadata | custom metadata to attach to created VM | `map(string)` | `{}` | no |
| pre\_start\_script\_content | custom script to run prior to startup\_script | `string` | `""` | no |
| tamr\_external\_ip | Create and attach an external ip to tamr VM | `bool` | `false` | no |
| tamr\_instance\_deletion\_protection | Enabled deletion protection for the tamr VM | `bool` | `true` | no |
| tamr\_instance\_disk\_size | size of the boot disk | `number` | `100` | no |
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.0
2.2.0
1 change: 1 addition & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ locals {
external_ip = var.tamr_external_ip == true ? 1 : 0

startup_script = templatefile("${path.module}/templates/startup_script.sh.tmpl", {
pre_start_script = var.pre_start_script_content
tamr_zip_uri = var.tamr_zip_uri
tamr_config = var.tamr_config_file
tamr_home_directory = var.tamr_instance_install_directory
Expand Down
7 changes: 7 additions & 0 deletions templates/startup_script.sh.tmpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#!/bin/bash

# run any custom commands to prepare VM
%{ if pre_start_script != "" }
${pre_start_script}
%{ endif }

# create tamr user, to run tamr
adduser --shell /bin/bash --home /home/tamr tamr

Expand All @@ -12,6 +17,8 @@ ${tamr_config}
EOF
)



# check if tamr has been installed on the VM, if not download and install it
if [[ ! -f ${tamr_home_directory}/tamr/start.sh ]]; then
# download tamr install
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ variable "tamr_config_file" {
description = "Override generated tamr configuration. The tamr configuration is specified using a yaml file, in the format that is documented (https://docs.tamr.com/previous/docs/configuration-configuring-unify#section-setting-configuration-variables) for configuring “many variables” at once."
}

variable "pre_start_script_content" {
default = ""
type = string
description = "custom script to run prior to startup_script"
}

#
# file system
#
Expand Down

0 comments on commit 56266f5

Please sign in to comment.