Skip to content

Commit f3589ff

Browse files
authored
Merge pull request #26 from Datatamer/fix_startup_script
DSD-2248: Allow users to specify custom metadata
2 parents 6549815 + 12e6b3d commit f3589ff

File tree

8 files changed

+2825
-46
lines changed

8 files changed

+2825
-46
lines changed

.gitleaks.toml

Lines changed: 2802 additions & 0 deletions
Large diffs are not rendered by default.

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# GCP Tamr VM module
22

3+
## v2.1.0 - April 25th 2023
4+
* Following optional input variables now available
5+
* metadata
6+
* Allows flexibility for the user of this module to supply custom metadata
7+
* Creates configuration file as Tamr functional user to avoid permissions issues
8+
39
## v2.0.0 - July 18th 2022
410
* Remove overlap with config module
511

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ This modules creates:
3838
| tamr\_instance\_zone | zone to deploy tamr vm | `string` | n/a | yes |
3939
| tamr\_zip\_uri | gcs location to download tamr zip from | `string` | n/a | yes |
4040
| labels | labels to attach to created resources | `map(string)` | `{}` | no |
41+
| metadata | custom metadata to attach to created VM | `map(string)` | `{}` | no |
4142
| tamr\_external\_ip | Create and attach an external ip to tamr VM | `bool` | `false` | no |
4243
| tamr\_instance\_deletion\_protection | Enabled deletion protection for the tamr VM | `bool` | `true` | no |
4344
| tamr\_instance\_disk\_size | size of the boot disk | `number` | `100` | no |

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.0.0
1+
2.1.0

main.tf

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,15 @@ resource "google_compute_address" "external_ip" {
4040
}
4141

4242
# tamr vm
43+
#tfsec:ignore:google-compute-enable-shielded-vm-im tfsec:ignore:google-compute-enable-shielded-vm-vtpm tfsec:ignore:google-compute-no-project-wide-ssh-keys
4344
resource "google_compute_instance" "tamr" {
4445
name = var.tamr_instance_name
4546
machine_type = var.tamr_instance_machine_type
4647
zone = var.tamr_instance_zone
4748
project = var.tamr_instance_project
4849
deletion_protection = var.tamr_instance_deletion_protection
4950

51+
#tfsec:ignore:google-compute-vm-disk-encryption-customer-key
5052
boot_disk {
5153
initialize_params {
5254
image = var.tamr_instance_image
@@ -74,14 +76,17 @@ resource "google_compute_instance" "tamr" {
7476
{ "role" = "tamr" },
7577
)
7678

79+
#tfsec:ignore:google-compute-no-default-service-account
7780
service_account {
7881
scopes = ["cloud-platform"]
7982
email = var.tamr_instance_service_account
8083
}
8184

82-
metadata = {
83-
shutdown-script-url = "gs://${var.tamr_filesystem_bucket}/${google_storage_bucket_object.shutdown_script.name}"
84-
}
85+
metadata = merge(var.metadata,
86+
{
87+
shutdown-script-url = "gs://${var.tamr_filesystem_bucket}/${google_storage_bucket_object.shutdown_script.name}"
88+
}
89+
)
8590

8691
# NOTE: we are using the startup_script field instead of the `startup-script-url` pair in metadata, in order to force
8792
# a recreation of the tamr VM after a configuration change. We want the tamr vm to be fully declarative and to not be

templates/dataproc.yaml.tmpl

Lines changed: 0 additions & 41 deletions
This file was deleted.

templates/startup_script.sh.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ if [[ ! -f ${tamr_home_directory}/tamr/start.sh ]]; then
2020
sudo -S -u tamr -i /bin/bash -c 'unzip ${tamr_home_directory}/unify.zip -d ${tamr_home_directory}'
2121

2222
# apply custom config
23-
echo -e "$${TAMR_CONFIG}" > ${tamr_home_directory}/tamr/conf/unify-custom-config.yaml
23+
sudo -S -u tamr -i /bin/bash -c 'echo -e "$${TAMR_CONFIG}" > ${tamr_home_directory}/tamr/conf/unify-custom-config.yaml'
2424
chown -R tamr:tamr ${tamr_home_directory}/tamr/conf/unify-custom-config.yaml
2525
fi
2626

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ variable "labels" {
9191
description = "labels to attach to created resources"
9292
}
9393

94+
variable "metadata" {
95+
default = {}
96+
type = map(string)
97+
description = "custom metadata to attach to created VM"
98+
}
99+
94100
variable "tamr_config_file" {
95101
type = string
96102
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."

0 commit comments

Comments
 (0)