본문 바로가기

반응형

퍼블릭 클라우드

[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.. 더보기
[Terraform] 테라폼 ALB 대상 그룹 등록 ALB(Application Load Balancer) 대상 그룹 등록 EC2 모듈 ec2.tf 편집 $ vim ec2.tf ... output "server_id" { value = join(", ", aws_instance.instance.*.id) } ALB 모듈 alb.tf 편집 $ vim abl.tf ... resource "aws_alb_target_group_attachment" "attachment" { count = 2 target_group_arn = aws_alb_target_group.targetgroup.arn target_id = element(split(",", var.server_id), count.index) port = 80 } 메인 모듈 main.tf 편집 $ vim m.. 더보기
[Terraform] 테라폼 join 함수(function) 테라폼 join 함수(function) : join은 주어진 구분 기호를 사용하여 주어진 문자열 목록의 모든 요소를 ​​함께 연결하여 문자열을 생성합니다 instance 모듈 instance.tf 편집 $ vim instance.tf ... ################################################### ##################### OUTPUTS ##################### ################################################### output "server_id" { value = join(", ", aws_instance.instance.*.id) } output "server_id" { value = join(", .. 더보기
[Terraform] 테라폼 concat 함수(function) 테라폼 concat 함수(function) : concat은 둘 이상의 목록을 가져와서 단일 목록으로 결합합니다. instance 모듈 instance.tf 편집 resource "aws_instance" "instance" { count = var.instance_count instance_type = var.instance_type ami = lookup(var.aws_amis, var.aws_region) key_name = var.key_name subnet_id = element(var.subnet_id, count.index) vpc_security_group_ids = var.vpc_security_group_ids associate_public_ip_address = var.associat.. 더보기
[VPN] Amazon Linux 2에 WireGuard를 설치하는 방법 Amazon Linux 2에 WireGuard를 설치하는 방법 ### epel 리포지토리 설치 $ amazon-linux-extras install epel ### wireguard 리포지토리 설치 $ curl -sL https://copr.fedorainfracloud.org/coprs/jdoss/wireguard/repo/epel-7/jdoss-wireguard-epel-7.repo -o /etc/yum.repos.d/wireguard.repo ### wireguard 패키지 설치 $ yum install wireguard-dkms wireguard-tools 더보기

728x90
반응형