Can anyone help me pass Environment credentials from Drone Secrets, into Environment variable in terraform please?
This is my Yaml file, nothing complicated:
kind: pipeline
name: default
steps:
- name: Pipeline1
image: “jmccann/drone-terraform”
environment:
TF_VAR_AWS_ACCESS_KEY_ID:
from_secret: AWS_ACCESS_KEY_ID
TF_VAR_AWS_SECRET_ACCESS_KEY:
from secret: AWS_SECRET_ACCESS_KEY
#commands:
#echo $$TF_VAR_AWS_ACCESS_KEY_ID
#echo $$TF_VAR_AWS_SECRET_ACCESS_KEY
This is my Main.tf file, where I have referenced the variables for the AWS credentials they don’t seem to be visible to terraform. Am I doing something wrong here? My environment variables are prefixed with TF_VAR_ which I’ve read is required for Terraform to find them in it’s process. Why is Terraform not seeing them AWS credentials from the pipeline?
terraform {
required_providers {
aws = {
source = “hashicorp/aws”
version = “~> 3.0”
}
}
}
variable “AWS_ACCESS_KEY_ID” {
default = “”
}
variable “AWS_SECRET_ACCESS_KEY” {
default = “”
}
Configure the AWS Provider
provider “aws” {
region = “us-east-1”
access_key = var.AWS_ACCESS_KEY_ID
secret_key = var.AWS_SECRET_ACCESS_KEY
}
resource “aws_s3_bucket” “bmw-bucket-a” {
bucket = “my-tf-test-bucket”
acl = “private”
tags = {
Name = “MW test big Bucket”
Environment = “Dev”
}
}
#comment1
This is my terrafom error which is coming back from AWS!
Error: error configuring Terraform AWS Provider: no valid credential sources for Terraform AWS Provider found. 8s
Thank you