퍼블릭 클라우드
[Terraform ] Terraform 다중(Multiple) Provider 구성
변군이글루
2021. 10. 12. 14:48
반응형
Terraform 다중(Multiple) Provider 구성
provider.tf 편집
$ cat provider.tf
terraform {
required_providers {
aws= {
source = "hashicorp/aws"
version = "~> 3.27"
}
}
required_version = ">= 0.14.9"
}
provider "aws" {
shared_credentials_file = "~/.aws/credentials"
region = "us-east-1"
profile = "sangchulkr"
}
#alternate
provider "aws" {
region = "ap-northeast-2"
alias = "kr"
profile = "sangchulkr"
}
provider "aws" {
region = "ap-southeast-1"
alias = "sg"
profile = "sangchulkr"
}
main.tf 편집
$ cat main.tf
module "key_pair_va" {
source = "./modules/terraform-aws-key-pair"
key_name = "4wxyz"
public_key = file("~/aws-key-pair/4wxyz.pub")
}
module "key_pair_kr" {
providers = {
aws = aws.kr
}
source = "./modules/terraform-aws-key-pair"
key_name = "4wxyz"
public_key = file("~/aws-key-pair/4wxyz.pub")
}
module "key_pair_sg" {
providers = {
aws = aws.sg
}
source = "./modules/terraform-aws-key-pair"
key_name = "4wxyz"
public_key = file("~/aws-key-pair/4wxyz.pub")
}
728x90
반응형