From df51aef151c21a870ad4bb5e927e5bd30677845f Mon Sep 17 00:00:00 2001 From: Vlad Borovtsov Date: Thu, 25 Jan 2024 14:54:36 +0100 Subject: [PATCH] drop template and local from versions; using built-in function templatefile instead of deprecated template provider --- data.tf | 10 +--------- ec2_user_data.sh.tpl => ec2_user_data.sh.tftpl | 0 main.tf | 6 +++++- versions.tf | 7 ------- 4 files changed, 6 insertions(+), 17 deletions(-) rename ec2_user_data.sh.tpl => ec2_user_data.sh.tftpl (100%) diff --git a/data.tf b/data.tf index dc0b84d..2084283 100644 --- a/data.tf +++ b/data.tf @@ -2,18 +2,10 @@ data "aws_caller_identity" "current" {} data "aws_region" "current" {} -data "template_file" "ec2_user_data" { - template = file("${path.module}/ec2_user_data.sh.tpl") - - vars = { - openvpn_token = var.openvpn_token - } -} - data "aws_ami" "ubuntu_22_04" { most_recent = true filter { - name = "name" + name = "name" # Ubuntu 22.04 LTS amd64 image in us-east-1. If upgrade is needed, you would need to re-connect to openvpn. values = ["ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-20230601"] } diff --git a/ec2_user_data.sh.tpl b/ec2_user_data.sh.tftpl similarity index 100% rename from ec2_user_data.sh.tpl rename to ec2_user_data.sh.tftpl diff --git a/main.tf b/main.tf index 7083e7d..85cd837 100644 --- a/main.tf +++ b/main.tf @@ -48,7 +48,11 @@ resource "aws_instance" "this" { ignore_changes = all } - user_data = var.vpn_enabled ? data.template_file.ec2_user_data.rendered : null + user_data = var.vpn_enabled ? templatefile("${path.module}/ec2_user_data.sh.tftpl", + { + openvpn_token = var.openvpn_token + } + ) : null tags = { Terraform = "true" diff --git a/versions.tf b/versions.tf index e9e24aa..1d23dfe 100644 --- a/versions.tf +++ b/versions.tf @@ -3,13 +3,6 @@ terraform { aws = { source = "hashicorp/aws" } - template = { - source = "hashicorp/template" - } - local = { - source = "hashicorp/local" - version = "~> 1.2" - } } required_version = ">= 0.13" }