株式会社ヴァンデミックシステム

Blog

<スポンサーリンク>

  • countで台数指定
  • "ec2-%02d", count.index + 1でタグ名をインクリメント
resource "aws_instance" "ec2" {
  count                       = 3
  ami                         = "ami-0f310fced6141e627"
  instance_type               = "t3.micro"
  subnet_id                   = aws_subnet.private_subnet-1a.id
  vpc_security_group_ids      = [aws_security_group.ec2_security_group
                                .id]
  tags = {
    Name = "${format("ec2-%02d", count.index + 1)}"
  }
}

<スポンサーリンク>

コメントを残す

Allowed tags:  you may use these HTML tags and attributes: <a href="">, <strong>, <em>, <h1>, <h2>, <h3>
Please note:  all comments go through moderation.

*

日本語が含まれない投稿は無視されますのでご注意ください。(スパム対策)