Skip to content

Terraform aws provider profile ignored in some cases #40

Description

@arraen

Describe the bug
Different results with aws provider profile and AWS_PROFILE env variable

System (please complete the following information):

  • OS: Linux
  • OS Version: 5.15.79.1
  • Tool Version: 0.14.4
  • Tool Installation Method: manual
  • Credential Process invoked via: terraform

To Reproduce
Steps to reproduce the behavior:

  1. Try to run terraform with aws provider profile variable set to "env-qa" (AWS_PROFILE env not set)
  2. Terraform will try to to apply to "env-prod" env actually
  3. run AWS_PROFILE=env-qa terraform apply
  4. Terraform will try to to apply to "env-qa" env

Expected behavior
As I understand it should work in the same way

Additional context
terraform config:

variable "aws_profile" {
default = "env-qa"
}

terraform {
required_version = ">= 1.2.3"
required_providers {
aws = {
source = "hashicorp/aws"
version = "4.23.0"
}
}
backend "s3" {
profile = "env-prod"
encrypt = true
dynamodb_table = "terraform-lock"
bucket = "env-terraform"
key = "infra/main.tf"
region = "region"
}
}

provider "aws" {
profile = var.aws_profile
default_tags {
tags = {
Service = "service"
Environment = local.env
Owner = "terraform"
}
}
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions