I have a Git Repository with Terraform code that is being deployed into AWS. I am adding Localstack to this repository so that I can do higher-level validation testing before a plan and apply into my real AWS account. In order to use Localstack I have to create a new provider with the custom endpoint:
provider "aws" {
alias = "real"
region = "${local.aws_region}"
}
provider "aws" {
alias = "fake"
region = "${local.aws_region}"
access_key = "fake"
secret_key = "fake"
skip_credentials_validation = true
skip_metadata_api_check = true
skip_requesting_account_id = true
endpoints {
dynamodb = "http://localhost:4566"
lambda = "http://localhost:4566"
kinesis = "http://localhost:4566"
}
}
How can I use one provider for Localstack and one provider with AWS without duplicating my code?