I configured AWS provider in Terraform by providing an access key and secret as environment variables according to the documentation:

$ export AWS_ACCESS_KEY_ID="anaccesskey"
$ export AWS_SECRET_ACCESS_KEY="asecretkey"

I now want to view those variables on the console as well as other environment variables configured on my system but I can't find the right command.

Update: I found out that I didn't configure the AWS provider like I thought. The AWS CLI was already configured with my credentials stored in AWS credentials file: ~/.aws/credentials.

3 Answers 3


On your command line, run printenv

Reference: https://man7.org/linux/man-pages/man1/printenv.1.html

  • Indeed, running printenv returns system environment variables but I don't recognize any of them to be Terraform variables, such as the mentioned access key ID and secret access key. Any suggestions on how to run a similar command under Terraform's context?
    – randvir
    Commented Jul 29, 2020 at 3:53
  • @randvir Terraform uses that same "context". terraform.io/docs/commands/environment-variables.html
    – Woodland
    Commented Jul 29, 2020 at 16:02
  • 1
    I found out my question is flawed. I discovered that I configured the AWS CLI to store credentials inside the AWS credentials file, not inside environment variables. Your answer helped me realize I'm looking in the wrong place and also taught me how to view environment variables. Thanks.
    – randvir
    Commented Aug 8, 2020 at 11:29

Your current shell environment variables, which are also including terraform-related ones can be listed by env command or you can do it in tf file:

terraform {
  required_version = ">= 0.12.0"

resource "null_resource" "get_tf_env" {
  provisioner "local-exec" {
    command = "env"
    interpreter = ["bash", "-c"]

According to official docs you can only feed terraform with the envs starting with TF_*.


printenv | grep TF_VAR will list all variables that you defined.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.