본문 바로가기

반응형

terraform

terraform apply 명령어 terraform apply 명령어 terraform apply 명령어는 테라폼 구성 파일로 정의한 인프라스트럭처를 실제로 생성하거나 업데이트하는 데 사용되는 명령어입니다. terraform apply [옵션] terraform apply --auto-approve terraform apply --auto-approve 명령어는 테라폼으로 정의한 인프라스트럭처를 실제로 생성하거나 업데이트할 때, 변경 사항을 자동으로 승인하고 인터랙션 없이 실행하는 옵션을 포함한 명령어입니다. 일반적으로 terraform apply를 실행하면, 변경 사항을 확인하는 단계에서 사용자에게 변경 사항을 표시하고 직접 승인 여부를 묻게 됩니다. 이때 --auto-approve 옵션을 사용하면 이 과정을 건너뛰고, 테라폼이 자동으.. 더보기
테라폼(Terraform) 디버깅 활성화 테라폼(Terraform) 디버깅 활성화 테라폼 계획 출력 terraform plan 테라폼 디버스(debug) 화면 출력 TF_LOG=DEBUG terraform plan 테라폼 디버스(debug) 파일 출력(terraform-debug.log 파일에 저장) TF_LOG=DEBUG TF_LOG_PATH=/tmp/terraform-debug.log terraform plan tail -10f /tmp/terraform-debug.log $ tail -10f /tmp/terraform-debug.log 2021-05-18T14:52:31.226+0900 [WARN] plugin.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavaila.. 더보기
[Terraform] 테라폼 인스턴스(private) 생성 테라폼 인스턴스(private) 생성 메인 모듈 $ vim main.tf #####레디스 서버 module "redisserver" { source = "../../../modules/ec2/instance/private/" prefix = module.vpc.out_prefix suffix = module.vpc.out_suffix env = module.vpc.out_env region = module.vpc.out_region instance_count = 1 name = "redis1" group_name = "redis" #aws_amis = "ami-0742b4e673072066f" instance_type = "t3a.medium" disk_size = "8" key_name = "keype.. 더보기
[Terraform] 테라폼 인스턴스(public) 생성 테라폼 인스턴스(public) 생성 메인 모듈 $ vim main.tf #####웹 서버 module "webserver" { source = "../../../modules/ec2/instance/" prefix = module.vpc.out_prefix suffix = module.vpc.out_suffix env = module.vpc.out_env region = module.vpc.out_region instance_count = 2 name = "web1" group_name = "web" #aws_amis = "ami-03ca998611da0fe12" instance_type = "t3a.medium" disk_size = "8" key_name = "keypem" subnet_id = mo.. 더보기
[Terraform] 테라폼 리소스 태그 지정(tags) -2 테라폼 리소스 태그 지정(tags) key_pair 편집 - key_pair 모듈 $ vim key_pair.tf ###keypair 생성 resource "aws_key_pair" "this" { count = var.create ? 1 : 0 key_name = var.key_name public_key = var.public_key lifecycle { ignore_changes = [ tags.CreatedDate ] } tags = merge( var.customer_tags, { Name = "${var.suffix}-rds01" } ) } vars.tf 편집 - key_pair 모듈 변수 $ vim vars.tf variable "customer_tags" {} main.tf 편집 - 메인 .. 더보기
[Terraform] 테라폼 리소스 태그 지정(tags) -1 테라폼 리소스 태그 지정(tags) VPC 모듈 vpc.tf 편집 $ vim vpc.tf ###### # locals ###### locals { default_tags = { CreateUser = "terraform" Owner = "sangchul" Project = "blog" Service = "network" } } ###### # VPC ###### resource "aws_vpc" "this" { cidr_block = var.cidr_block enable_dns_hostnames = var.enable_dns_hostnames enable_dns_support = var.enable_dns_support instance_tenancy = var.instance_tenancy lifecy.. 더보기
테라폼 vpc peering import(terraform import) 테라폼 vpc peering import(terraform import) vpc peering connection import [버지니아 리전] vpc resources 파일 생성 vim peering.tf #####VPC 페어링 resource "aws_vpc_peering_connection" "vatosg" {} terraform import aws_vpc_peering_connection.vatosg pcx-03c5b $ terraform import aws_vpc_peering_connection.vatosg pcx-03c5b aws_vpc_peering_connection.vatosg: Importing from ID "pcx-03c5b"... aws_vpc_peering_connection... 더보기
[Terraform] 테라폼 output 명령어 테라폼 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 $ vi.. 더보기

728x90
반응형