I have two files: a Terraform variables file (vars.tf), and a Makefile.

What I want to be able to do, is to have the Makefile 'read' some of the variables in the Terraform vars.tf file.

The vars.tf file:

variable "region" {
    default = "us-west-1"
    description = "AWS Region"
variable "profile" {
    default = "bobs-profile"
    description = "Please enter your AWS CLI profile name"
variable "env" {
    default = "dev"
    description = "Please label the environment this infrastructure will be deployed to eg dev, uat, prod"

I would like to be able to call the variables listed in the vars.tf file in my Makefile - here is a short example:

.SHELL := /usr/bin/bash
.PHONY: apply plan prep
CURRENT_FOLDER=$(shell basename "$$(pwd)")

I would like, for example, the values of:

  • $(ENV)
  • $(REGION)

To be pulled from the Terraform vars.tf file, so that the Makefile will be run with the variables as follows:


Is there a way that I can achieve this?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.