Skip to content

Commit

Permalink
fix: removed template provider
Browse files Browse the repository at this point in the history
  • Loading branch information
zahornyak committed Dec 23, 2024
1 parent 608cba7 commit fd63ed6
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 15 deletions.
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,12 @@ module "ec2" {
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.45 |
| <a name="requirement_template"></a> [template](#requirement\_template) | ~> 2.2 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.45 |
| <a name="provider_template"></a> [template](#provider\_template) | ~> 2.2 |

## Modules

Expand All @@ -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

Expand Down
10 changes: 2 additions & 8 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
}
Expand Down Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,5 @@ terraform {
source = "hashicorp/aws"
version = ">= 4.45"
}
template = {
source = "hashicorp/template"
version = "~> 2.2"
}
}
}

0 comments on commit fd63ed6

Please sign in to comment.