티스토리 뷰

반응형

EC2

resource "aws_instance" "common_ec2" {
// 생략

  count = var.instance_count

  tags = {
    Name = "Common-EC2-${count.index}"
  }

  provisioner "local-exec" {
    command = "echo ${self.private_ip} >> ./output/common_backend.txt"
  }
}

 

CLB

resource "aws_elb" "LB_Public" {
  name = "LB"
  // 생략

  listener {
    lb_port = 80
    lb_protocol = "HTTP"
    instance_port = 80
    instance_protocol = "HTTP"
  }

  instances = aws_instance.common_ec2.*.id

  provisioner "local-exec" {
    command = "echo ${self.dns_name} > output/publicLB.txt"
  }
}

variables

variable "instance_count" {
  type = number
  default = 1
}
댓글
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/11   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
글 보관함