Skip to content

Commit

Permalink
feat(ssm): custom user data (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
Young-ook authored May 12, 2021
1 parent 367de98 commit 0dd74c0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
1 change: 1 addition & 0 deletions examples/fis/tc1.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ node_groups = [
max_size = 3
desired_size = 3
instance_type = "t3.small"
user_data = "#!/bin/bash\nyum update -y\nyum install -y httpd\nsystemctl start httpd\nsystemctl enable httpd"
}
]
10 changes: 1 addition & 9 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,12 @@ data "aws_ami" "al2" {
}
}

data "template_file" "boot" {
for_each = { for ng in var.node_groups : ng.name => ng }
template = <<EOT
#!/bin/bash
set -ex
EOT
}

resource "aws_launch_template" "asg" {
for_each = { for ng in var.node_groups : ng.name => ng }
name = join("-", [local.name, each.key])
tags = merge(local.default-tags, var.tags)
image_id = lookup(each.value, "image_id", data.aws_ami.al2[each.key].id)
user_data = base64encode(data.template_file.boot[each.key].rendered)
user_data = base64encode(lookup(each.value, "user_data", ""))
instance_type = lookup(each.value, "instance_type", "t3.medium")
key_name = lookup(each.value, "key_name", null)

Expand Down

0 comments on commit 0dd74c0

Please sign in to comment.