Skip to content

Commit

Permalink
[GDB-10293] Added support for custom owner ID for the AMIs and change…
Browse files Browse the repository at this point in the history
…d default owner ID
  • Loading branch information
simonzhekoff committed May 27, 2024
1 parent d354fb3 commit c7e16ae
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ module "graphdb" {

ami_id = var.ami_id
graphdb_version = var.graphdb_version
aws_custom_owner_id = var.aws_custom_owner_id

# Managed Disks

Expand Down
2 changes: 1 addition & 1 deletion modules/graphdb/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ data "aws_caller_identity" "current" {}
data "aws_ami" "graphdb" {
count = var.ami_id != null ? 0 : 1

owners = ["770034820396"] # Ontotext
owners = var.aws_custom_owner_id != null ? [var.aws_custom_owner_id] : ["679593333241"]
most_recent = true

filter {
Expand Down
23 changes: 22 additions & 1 deletion modules/graphdb/templates/01_wait_node_count.sh.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,29 @@ if [ "$instance_refresh_status" != "[]" ]; then
# Check if any volumes are available
if [ -n "$available_volumes" ]; then
log_with_timestamp "Found an available volume in $AZ."
break
log_with_timestamp "Found volumes: $available_volumes"

# Verify the volume is still available 3 times over 10 seconds (Handles instance_refresh VMs spawned in another AZ)
checks_passed=0
for i in {1..3}; do
sleep 10
still_available=$(aws ec2 describe-volumes --volume-ids $available_volumes --query "Volumes[?State=='available'].VolumeId" --output text)
if [ -n "$still_available" ]; then
checks_passed=$((checks_passed + 1))
else
checks_passed=0
break
fi
done

if [ $checks_passed -eq 3 ]; then
log_with_timestamp "Confirmed the volume is still available after 30 seconds."
break
else
log_with_timestamp "Volume $available_volumes was no longer available upon re-check. Continuing to wait..."
fi
fi

sleep 5
ELAPSED=$((ELAPSED + 5))
done
Expand Down
5 changes: 5 additions & 0 deletions modules/graphdb/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ variable "aws_subscription_id" {
type = string
}

variable "aws_custom_owner_id" {
description = "Define custom owner ID for AMI images"
type = string
}

# GraphDB Parameters

variable "graphdb_admin_password" {
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ variable "aws_region" {
type = string
}

variable "aws_custom_owner_id" {
description = "Define custom owner ID for AMI images"
type = string
default = null
}

# Backup configurations
variable "deploy_backup" {
description = "Deploy backup module"
Expand Down

0 comments on commit c7e16ae

Please sign in to comment.