Skip to content

Commit

Permalink
Merge pull request #19 from muzfuz/remove-template-data-query
Browse files Browse the repository at this point in the history
Removes deprecated `data.template_file` query
  • Loading branch information
cuotos authored Dec 18, 2024
2 parents 75f6800 + 39370fa commit c76376d
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ locals {
"name" : "amzn2-ami-hvm-2.0*"
}
}
user_data = templatefile("${path.module}/user_data.sh", {
additional_user_data = var.additional_user_data != null ? var.additional_user_data : ""
})
common_tags = merge({
"tf-workspace" : terraform.workspace
"creator" : local.username
Expand Down Expand Up @@ -99,19 +102,12 @@ resource "aws_iam_instance_profile" "profile" {
role = aws_iam_role.role.name
}

data "template_file" "user_data" {
template = file("${path.module}/user_data.sh")
vars = {
additional_user_data = var.additional_user_data != null ? var.additional_user_data : ""
}
}

# Create the EC2 compute server
resource "aws_instance" "instance" {
key_name = var.key_name != "" ? var.key_name : null
instance_type = var.instance_type
ami = var.ami != "" ? var.ami : data.aws_ami.this.image_id
user_data = data.template_file.user_data.rendered
user_data = local.user_data
iam_instance_profile = aws_iam_instance_profile.profile.id
subnet_id = var.subnet_id
associate_public_ip_address = var.associate_public_ip_address
Expand Down

0 comments on commit c76376d

Please sign in to comment.