From fd63ed63e8cd8b9f609c92bb922a5307b6dc2712 Mon Sep 17 00:00:00 2001 From: Andriy Zahornyak Date: Mon, 23 Dec 2024 11:04:14 +0200 Subject: [PATCH] fix: removed template provider --- README.md | 3 --- main.tf | 10 ++-------- versions.tf | 4 ---- 3 files changed, 2 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 5e6b571..e473a65 100644 --- a/README.md +++ b/README.md @@ -25,14 +25,12 @@ module "ec2" { |------|---------| | [terraform](#requirement\_terraform) | >= 1.3 | | [aws](#requirement\_aws) | >= 4.45 | -| [template](#requirement\_template) | ~> 2.2 | ## Providers | Name | Version | |------|---------| | [aws](#provider\_aws) | >= 4.45 | -| [template](#provider\_template) | ~> 2.2 | ## Modules @@ -54,7 +52,6 @@ module "ec2" { | [aws_iam_role.instance_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource | | [aws_launch_template.as_template](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/launch_template) | resource | | [aws_ami.ami](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ami) | data source | -| [template_file.user_data](https://registry.terraform.io/providers/hashicorp/template/latest/docs/data-sources/file) | data source | ## Inputs diff --git a/main.tf b/main.tf index e2532fe..12ffe15 100644 --- a/main.tf +++ b/main.tf @@ -30,12 +30,6 @@ resource "aws_iam_instance_profile" "ec2_instance_profile" { role = aws_iam_role.instance_role[0].name } -data "template_file" "user_data" { - template = file(var.user_data_path) - - vars = var.vars -} - module "ec2_instance" { count = var.create_autoscaling_group ? 0 : 1 source = "terraform-aws-modules/ec2-instance/aws" @@ -53,7 +47,7 @@ module "ec2_instance" { vpc_security_group_ids = var.security_group_ids subnet_id = var.subnet_id iam_instance_profile = var.instance_profile != null ? var.instance_profile : aws_iam_instance_profile.ec2_instance_profile[0].name - user_data = base64encode(data.template_file.user_data.rendered) + user_data = base64encode(templatefile(var.user_data_path, var.vars)) user_data_replace_on_change = var.user_data_replace_on_change root_block_device = var.root_block_device } @@ -102,7 +96,7 @@ resource "aws_launch_template" "as_template" { name_prefix = var.server_name image_id = var.ami != null ? var.ami : data.aws_ami.ami.id instance_type = var.instance_type - user_data = base64encode(data.template_file.user_data.rendered) + user_data = base64encode(templatefile(var.user_data_path, var.vars)) iam_instance_profile { name = var.instance_profile != null ? var.instance_profile : aws_iam_instance_profile.ec2_instance_profile[0].name diff --git a/versions.tf b/versions.tf index b218cb1..b01be1f 100644 --- a/versions.tf +++ b/versions.tf @@ -5,9 +5,5 @@ terraform { source = "hashicorp/aws" version = ">= 4.45" } - template = { - source = "hashicorp/template" - version = "~> 2.2" - } } }