-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding a hash to the user data scripts so terraform will see changes exist and replace them as needed #49
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
locals { | ||
web_user_data_content = sensitive(templatefile("${path.module}/templates/web_user_data.sh", local.web_interpolation_vars)) | ||
worker_user_data_content = sensitive(templatefile("${path.module}/templates/worker_user_data.sh", local.worker_interpolation_vars)) | ||
Comment on lines
+2
to
+3
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you happen to double check that using sensitive here translates to the value being obfuscated when used in the terraforming of the s3 object below? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i did see that the values were obfuscated in the terraform or what i believe was this file. Obviously the file has all the keys in plain text in s3. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://developer.hashicorp.com/terraform/language/functions/sensitive this shows the same use from hashicorp |
||
} | ||
|
||
resource "aws_s3_bucket" "user_data" { | ||
bucket = var.user_data_bucket_name | ||
} | ||
|
@@ -55,14 +60,17 @@ resource "aws_s3_object" "cw_agent_prometheus_init" { | |
}) | ||
} | ||
|
||
|
||
resource "aws_s3_object" "web_user_data" { | ||
bucket = aws_s3_bucket.user_data.id | ||
key = "web_user_data.sh" | ||
content = sensitive(templatefile("${path.module}/templates/web_user_data.sh", local.web_interpolation_vars)) | ||
bucket = aws_s3_bucket.user_data.id | ||
key = "web_user_data.sh" | ||
content = local.web_user_data_content | ||
source_hash = md5(local.web_user_data_content) | ||
} | ||
|
||
resource "aws_s3_object" "worker_user_data" { | ||
bucket = aws_s3_bucket.user_data.id | ||
key = "worker_user_data.sh" | ||
content = sensitive(templatefile("${path.module}/templates/worker_user_data.sh", local.worker_interpolation_vars)) | ||
bucket = aws_s3_bucket.user_data.id | ||
key = "worker_user_data.sh" | ||
content = local.worker_user_data_content | ||
source_hash = md5(local.worker_user_data_content) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you store the loaded template file contents into a local car so we're not loading it twice? Small thing, but I think it will make this read slightly better and require changes in less places in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated