Skip to content

Commit

Permalink
EDSF-535 Add prefix to tarball/agent s3 bucket
Browse files Browse the repository at this point in the history
  • Loading branch information
linda.nasredin committed Feb 5, 2024
1 parent d510bc0 commit 2e11cb2
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion modules/aws/db-with-agent/iam_role.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ locals {
"s3:GetObject"
]
"Resource" : [
"arn:aws:s3:::${local.s3_bucket_and_prefix}/*",
"arn:aws:s3:::${local.installation_s3_bucket_and_prefix}/*",
]
}
]
Expand Down
6 changes: 3 additions & 3 deletions modules/aws/db-with-agent/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ locals {
db_type = var.db_type != null ? var.db_type : random_shuffle.db.result[0]
os_type = var.os_type != null ? var.os_type : random_shuffle.os.result[0]

s3_object = var.binaries_location.s3_object != null ? var.binaries_location.s3_object : local.os_params[local.os_type].installation_filename
s3_key = var.binaries_location.s3_prefix != null ? join("/", [var.binaries_location.s3_prefix, local.s3_object]) : local.s3_object
s3_bucket_and_prefix = var.binaries_location.s3_prefix != null ? join("/", [var.binaries_location.s3_bucket, var.binaries_location.s3_prefix]) : var.binaries_location.s3_bucket
installation_s3_object = var.binaries_location.s3_object != null ? var.binaries_location.s3_object : local.os_params[local.os_type].installation_filename
installation_s3_key = var.binaries_location.s3_prefix != null ? join("/", [var.binaries_location.s3_prefix, local.installation_s3_object]) : local.installation_s3_object
installation_s3_bucket_and_prefix = var.binaries_location.s3_prefix != null ? join("/", [var.binaries_location.s3_bucket, var.binaries_location.s3_prefix]) : var.binaries_location.s3_bucket
}

resource "random_shuffle" "db" {
Expand Down
4 changes: 2 additions & 2 deletions modules/aws/db-with-agent/userdata.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ locals {
sudo ./aws/install
export PATH=$PATH:/usr/local/bin:/usr/local/bin
echo "Downloading agent:"
INSTALLATION_FILE=${local.s3_object}
aws s3 cp s3://${var.binaries_location.s3_bucket}/${local.s3_key} . --region ${var.binaries_location.s3_region}
INSTALLATION_FILE=${local.installation_s3_object}
aws s3 cp s3://${var.binaries_location.s3_bucket}/${local.installation_s3_key} . --region ${var.binaries_location.s3_region}
chmod +x ./"$INSTALLATION_FILE"
echo "Installing agent:"
./"$INSTALLATION_FILE" -n -d ${local.agent_installation_dir}
Expand Down
2 changes: 1 addition & 1 deletion modules/aws/sonar-base-instance/iam_role.tf
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ locals {
"s3:GetObject"
]
"Resource" : [
"arn:aws:s3:::${local.s3_bucket_and_prefix}/*",
"arn:aws:s3:::${local.installation_s3_bucket_and_prefix}/*",
]
}
]
Expand Down
8 changes: 4 additions & 4 deletions modules/aws/sonar-base-instance/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ locals {
[for sg in aws_security_group.dsf_base_sg : sg.id],
var.security_group_ids)

# For example, if the binaries_location.s3_key is "path/to/file.zip", then the s3_bucket_prefix will be "path/to"
# If the binaries_location.s3_key is "file.zip", then the s3_bucket_prefix will be null
s3_bucket_prefix = try(regex("^(.*)/[^/]+", var.binaries_location.s3_key)[0], null)
s3_bucket_and_prefix = local.s3_bucket_prefix != null ? join("/", [var.binaries_location.s3_bucket, local.s3_bucket_prefix]) : var.binaries_location.s3_bucket
# For example, if the binaries_location.s3_key is "path/to/file.zip", then the installation_s3_prefix will be "path/to"
# If the binaries_location.s3_key is "file.zip", then the installation_s3_prefix will be null
installation_s3_prefix = try(regex("^(.*)/[^/]+", var.binaries_location.s3_key)[0], null)
installation_s3_bucket_and_prefix = local.installation_s3_prefix != null ? join("/", [var.binaries_location.s3_bucket, local.installation_s3_prefix]) : var.binaries_location.s3_bucket
}

resource "aws_eip" "dsf_instance_eip" {
Expand Down

0 comments on commit 2e11cb2

Please sign in to comment.