Terraform ebs volume

user6826691

I am new to terraform, have created 3 ec2 instances, and i have created 6 ebs volume. How do we attach 2 ebs volumes to each of the three instances?

#Create 6 EBS volumes and attach 2 per instance.
resource "aws_ebs_volume" "vertica_ebs" {
        count                           = "6"
        availability_zone               = "${var.availability_zone}"
        size                            = "500"
        type                            = "st1"

       }
    }

#Attach ebs volume
resource "aws_volume_attachment" "ebs_att" {
     count = "6"
volume {
     device_name = "/dev/sdf"
     volume_id = "[${element(aws_ebs_volume.vertica_ebs.*.id, count.index)}]"
}
volume{
     device_name = "/dev/sdg"
     volume_id = "[${element(aws_ebs_volume.vertica_ebs.*.id, count.index)}]"
}
     instance_id = "[${element(aws_instance.vertica1.*.id,count.index)}]"
}

Errors:

  • aws_volume_attachment.ebs_att #2: "device_name": required field is not set
  • aws_volume_attachment.ebs_att #2: "volume_id": required field is not set
  • aws_volume_attachment.ebs_att #2: : invalid or unknown key: volume
  • aws_volume_attachment.ebs_att #4: "device_name": required field is not set
  • aws_volume_attachment.ebs_att #4: "volume_id": required field is not set
  • aws_volume_attachment.ebs_att #4: : invalid or unknown key: volume
  • aws_volume_attachment.ebs_att #3: "device_name": required field is not set
  • aws_volume_attachment.ebs_att #3: "volume_id": required field is not set
  • aws_volume_attachment.ebs_att #3: : invalid or unknown key: volume
  • aws_volume_attachment.ebs_att #0: "volume_id": required field is not set
  • aws_volume_attachment.ebs_att #0: "device_name": required field is not set
  • aws_volume_attachment.ebs_att #0: : invalid or unknown key: volume
  • aws_volume_attachment.ebs_att #1: "device_name": required field is not set
  • aws_volume_attachment.ebs_att #1: "volume_id": required field is not set
  • aws_volume_attachment.ebs_att #1: : invalid or unknown key: volume
  • aws_volume_attachment.ebs_att #5: "volume_id": required field is not set
  • aws_volume_attachment.ebs_att #5: "device_name": required field is not set
  • aws_volume_attachment.ebs_att #5: : invalid or unknown key: volume
Mr.Budris

Note: this method will destroy and recreate the servers. Use 'aws volume attachment' method if this is unacceptable to you.

One way to approach this problem, and how I would solve it, is to attach the ebs volumes directly to the instance resource.

You can do this by adding an 'ebs_block_device' element to each server configuration, then running terraform apply. For example, each server resource you wished to add 2 ebs block devices to, would look like:

resource "aws_instance""example_instance"{
#INSTANCE CONFIGURATION VALUES  
    ebs_block_device{
      device_name = "/dev/sdf"
      volume_size = 500
      volume_type = "st1"
    }
    ebs_block_device{
      device_name = "/dev/sdg"
      volume_size = 500
      volume_type = "st1"
    }
}

Then run terraform plan, see that the block devices will be added to the servers and the servers. Using this method, the servers WILL BE DESTROYED AND RECREATED. If this is acceptable, run terraform apply to rebuild the servers with the additional volumes.

Check out the documentation around ebs_block_device and aws_instance here.

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

terraform ebs_block_device vsaws_ebs_volumeリソース

分類Dev

Kubernetes - Get EBS Volume of a Pod

分類Dev

Kubernetes AWS EBS Timeout waiting for volume state

分類Dev

Terraform applying huge index value for instance EBS block store

分類Dev

Amazon EC2: How to change instance type without losing data on attached EBS volume

分類Dev

TerraformのECSインスタンスにEBSボリュームを追加する方法

分類Dev

Terraformを使用して複数のEBSボリュームのスナップショットを作成する

分類Dev

CloudWatchとTerraformを使用してスケジュールされたEBSスナップショットを取得します

分類Dev

EBS volを手動で変更した後、すべてのリソースを再作成するTerraformテンプレート

分類Dev

Terraformを使用してEC2を介して作成するときに、AWS EBSにタグを追加するにはどうすればよいですか?

分類Dev

terraformデータソースを使用して最新のebsスナップショットを取得するにはどうすればよいですか?

分類Dev

EBS Snapshots, who manages backups?

分類Dev

リストからの対応する aws_instance リソースのみを含む Terraform ターゲット aws_volume_attachment

分類Dev

Terraformを使用して、以前のスナップショットを削除し、EBSボリュームの新しいスナップショットを作成します

分類Dev

Docker volume vs Kubernetes persistent volume

分類Dev

Microservice Application ... Docker Volume for Databases or no Docker Volume?

分類Dev

验证AWS中ebs卷的加密

分類Dev

restore with AWS EBS' snapshots on separate cluster

分類Dev

EBS読み取り速度

分類Dev

Can a Persistent Volume be resized?

分類Dev

Docker ADDとVOLUME

分類Dev

XMonad Volume configuration not working

分類Dev

Persistent Volume Issue on GKE

分類Dev

Calculations for the volume of a sphere is incorrect

分類Dev

How to open UDF Volume

分類Dev

Mount encrypted volume in Debian

分類Dev

Volume control applet disappeared

分類Dev

Chrome missing volume slider?

分類Dev

Removing vtkBoxWidget from an volume

Related 関連記事

  1. 1

    terraform ebs_block_device vsaws_ebs_volumeリソース

  2. 2

    Kubernetes - Get EBS Volume of a Pod

  3. 3

    Kubernetes AWS EBS Timeout waiting for volume state

  4. 4

    Terraform applying huge index value for instance EBS block store

  5. 5

    Amazon EC2: How to change instance type without losing data on attached EBS volume

  6. 6

    TerraformのECSインスタンスにEBSボリュームを追加する方法

  7. 7

    Terraformを使用して複数のEBSボリュームのスナップショットを作成する

  8. 8

    CloudWatchとTerraformを使用してスケジュールされたEBSスナップショットを取得します

  9. 9

    EBS volを手動で変更した後、すべてのリソースを再作成するTerraformテンプレート

  10. 10

    Terraformを使用してEC2を介して作成するときに、AWS EBSにタグを追加するにはどうすればよいですか?

  11. 11

    terraformデータソースを使用して最新のebsスナップショットを取得するにはどうすればよいですか?

  12. 12

    EBS Snapshots, who manages backups?

  13. 13

    リストからの対応する aws_instance リソースのみを含む Terraform ターゲット aws_volume_attachment

  14. 14

    Terraformを使用して、以前のスナップショットを削除し、EBSボリュームの新しいスナップショットを作成します

  15. 15

    Docker volume vs Kubernetes persistent volume

  16. 16

    Microservice Application ... Docker Volume for Databases or no Docker Volume?

  17. 17

    验证AWS中ebs卷的加密

  18. 18

    restore with AWS EBS' snapshots on separate cluster

  19. 19

    EBS読み取り速度

  20. 20

    Can a Persistent Volume be resized?

  21. 21

    Docker ADDとVOLUME

  22. 22

    XMonad Volume configuration not working

  23. 23

    Persistent Volume Issue on GKE

  24. 24

    Calculations for the volume of a sphere is incorrect

  25. 25

    How to open UDF Volume

  26. 26

    Mount encrypted volume in Debian

  27. 27

    Volume control applet disappeared

  28. 28

    Chrome missing volume slider?

  29. 29

    Removing vtkBoxWidget from an volume

ホットタグ

アーカイブ