Difference between revisions of "Terraform multiple providers"
Jump to navigation
Jump to search
↑ https://www.terraform.io/language/providers/configuration
(Created page with "https://www.terraform.io/language/providers/configuration#alias-multiple-provider-configurations alias == See also == * {{Terraform}}") |
|||
(14 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | https://www.terraform.io/language/providers/configuration | + | You can optionally define multiple configurations for the same [[provider]], and select which one to use on a per-resource or per-module basis. <ref>https://www.terraform.io/language/providers/configuration</ref> |
− | alias | + | == Example == |
+ | |||
+ | |||
+ | # 1st provider configuration; resources that begin with `aws_` will use it as the default, and it can be referenced as `aws`. | ||
+ | provider "aws" { | ||
+ | region = "us-east-1" | ||
+ | } | ||
+ | |||
+ | # 2nd provider configuration for other region ; resources can reference this as `aws.mywestregion`. | ||
+ | provider "aws" { | ||
+ | alias = "mywestregion" | ||
+ | region = "us-west-2" | ||
+ | } | ||
+ | |||
+ | terraform { | ||
+ | required_providers { | ||
+ | mycloud = { | ||
+ | source = "mycorp/mycloud" | ||
+ | version = "~> 1.0" | ||
+ | configuration_aliases = [ mycloud.alternate ] | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | resource "aws_instance" "foo" { | ||
+ | provider = aws.west | ||
+ | |||
+ | # ... | ||
+ | } | ||
+ | |||
+ | == Errors == | ||
+ | * [[Error: Duplicate provider configuration]] | ||
+ | |||
+ | == Related == | ||
+ | |||
+ | * [[Terraform providers: provider|Terraform providers]] | ||
+ | * <code>[[alias]]</code> | ||
+ | * [[Terraform Associate]] | ||
+ | * [[AWS Roles]]: <code>[[OrganizationAccountAccessRole]]</code> | ||
== See also == | == See also == | ||
− | * {{ | + | * {{terraform providers}} |
+ | * {{Certifications}} | ||
+ | |||
+ | [[Category:Terraform]] |
Latest revision as of 20:13, 5 April 2023
You can optionally define multiple configurations for the same provider, and select which one to use on a per-resource or per-module basis. [1]
Contents
Example[edit]
# 1st provider configuration; resources that begin with `aws_` will use it as the default, and it can be referenced as `aws`. provider "aws" { region = "us-east-1" } # 2nd provider configuration for other region ; resources can reference this as `aws.mywestregion`. provider "aws" { alias = "mywestregion" region = "us-west-2" } terraform { required_providers { mycloud = { source = "mycorp/mycloud" version = "~> 1.0" configuration_aliases = [ mycloud.alternate ] } } } resource "aws_instance" "foo" { provider = aws.west # ... }
Errors[edit]
Related[edit]
See also[edit]
- Terraform provider:
AWS, Cloudflare
,GoogleWorkspace
,Kubernetes, Helm, .terraform/providers/
,template
,tfe
,providers.tf, dns, hashicorp/, hashicorp/tls
, Terraform provider versioning, Libvirt, datadog,terraform providers, required_version, onepassword
,rancher2
,time, terraform.tf
- Certifications: Security certifications, Enterprise architecture, Coursera, AWS certifications, CertiProf, Pearson VUE, Terraform Associate, Freecram, ExamLabs
Advertising: