Skip to content
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

feat: allow users to choose which user data script to apply #13

Merged
merged 10 commits into from
Oct 31, 2024
7 changes: 5 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ resource "aws_lambda_function" "database_lambda" {
WEBSERVER_HOSTNAME = var.turbo_deploy_hostname
WEBSERVER_HTTP_PORT = var.turbo_deploy_http_port
WEBSERVER_HTTPS_PORT = var.turbo_deploy_https_port
USER_SCRIPTS = jsonencode(keys(var.user_scripts))
AMI_FILTERS = base64gzip(jsonencode(var.image_filter_groups))
}
}
Expand Down Expand Up @@ -479,6 +480,7 @@ resource "aws_lambda_function" "my_tf_function" {
HOSTED_ZONE_ID = var.zone_id
PUBLIC_KEY = aws_key_pair.admin_key.key_name
PROFILE_NAME = aws_iam_instance_profile.turbodeploy_profile.name
USER_SCRIPTS = jsonencode(keys(var.user_scripts))
}
}
depends_on = [
Expand All @@ -494,10 +496,11 @@ resource "aws_lambda_event_source_mapping" "terraform_event_mapping" {
}

resource "aws_s3_object" "file_upload" {
for_each = var.user_scripts
bucket = aws_s3_bucket.s3_terraform_state.bucket
key = "user-data-scripts/user-data.sh"
key = "user-data-scripts/${each.key}.sh"
content_type = "text/plain"
content = var.user_scripts
content = each.value
}

resource "aws_key_pair" "admin_key" {
Expand Down
4 changes: 2 additions & 2 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ variable "ec2_attributes" {

variable "user_scripts" {
description = "The user data to use when launching the instance"
type = string
default = ""
type = map(string)
default = null
}

variable "zone_id" {
Expand Down