퍼블릭 클라우드
[Terraform] 테라폼 output 명령어
변군이글루
2021. 4. 22. 08:57
반응형
테라폼 output 명령어
: terraform 출력 명령은 상태 파일에서 출력 변수의 값을 추출하는데 사용됩니다
VPC 모듈 - output
$ vim vpc.tf
output "out_prefix" {
value = var.prefix
}
output "out_suffix" {
value = var.suffix
}
output "out_env" {
value = var.env
}
output "out_region" {
value = var.aws_region
}
output "out_aws_vpc_id" {
value = aws_vpc.this.id
}
output "out_aws_vpc_cidr" {
value = aws_vpc.this.cidr_block
}
main 모듈 - output
$ vim output.tf
#####VPC 정보
output "vpc_id" {
description = "VPC ID 출력"
value = module.vpc.out_aws_vpc_id
}
output "vpc_cidr" {
description = "VPC에 할당한 CIDR 블록"
value = module.vpc.out_aws_vpc_cidr
}
####서브넷 정보
output "subnet_public" {
description = "Public Subnet ID 리스트 출력"
value = module.vpc.out_public
}
output "subnet_private" {
description = "Private Subnet ID 리스트 출력"
value = module.vpc.out_private
}
output "subnet_mgmt" {
description = "MGMT Subnet ID 리스트 출력"
value = module.vpc.out_mgmt
}
#####Internet Gateway
output "internet_gateway" {
description = "The ID of the default network ACL"
value = module.vpc.out_aws_internet_gateway_id
}
#####네트워크 ACLs
output "network_acl_id" {
description = "The ID of the default network ACL"
value = module.vpc.out_default_network_acl_id
}
#####라우팅 테이블
output "route_table_subnet_public" {
description = "Public Route Table ID 리스트"
value = module.vpc.out_public_route_table_ids
}
output "route_table_subnet_private" {
description = "Private Route Table ID 리스트"
value = module.vpc.out_private_route_table_ids
}
출력(output)
terraform output
(or terraform output -json)
$ terraform output 10034 08:48:33
internet_gateway = "igw-0a52c"
network_acl_id = "acl-0c107"
rdb_subnetgroup_id = "default-rds01"
rds_securitygroup_id = "sg-07b36"
route_table_subnet_private = "rtb-0b60f"
route_table_subnet_public = "rtb-09661"
security_group_default = "sg-0671f"
security_group_idc = "sg-05dba"
security_group_office = "sg-0e0d6"
subnet_mgmt = [
"subnet-034ca",
"subnet-097c9",
]
subnet_private = [
"subnet-03e8d",
"subnet-02a22",
]
subnet_public = [
"subnet-01eb4",
"subnet-051b4",
]
vpc_cidr = "10.31.0.0/16"
vpc_id = "vpc-0054a"
Terraform CLI > Command: output
https://www.terraform.io/docs/cli/commands/output.html
Command: output - Terraform by HashiCorp
The `terraform output` command is used to extract the value of an output variable from the state file.
www.terraform.io
728x90
반응형