Difference between revisions of "Terraform resource: aws volume attachment"

From wikieduonline
Jump to navigation Jump to search
Line 11: Line 11:
 
   instance_id = aws_instance.web.id
 
   instance_id = aws_instance.web.id
 
  }
 
  }
<pre>
 
resource "aws_instance" "web" {
 
  ami              = "ami-21f78e11"
 
  availability_zone = "us-west-2a"
 
  instance_type    = "t2.micro"
 
 
  tags = {
 
    Name = "HelloWorld"
 
  }
 
}
 
 
resource "aws_ebs_volume" "example" {
 
  availability_zone = "us-west-2a"
 
  size              = 1
 
}
 
</pre>
 
  
 +
resource "aws_instance" "web" {
 +
  ami              = "ami-21f78e11"
 +
  availability_zone = "us-west-2a"
 +
  instance_type    = "t2.micro"
 +
 +
  tags = {
 +
    Name = "HelloWorld"
 +
  }
 +
}
 +
 +
resource "aws_ebs_volume" "example" {
 +
  availability_zone = "us-west-2a"
 +
  size              = 1
 +
}
  
 
== Related ==
 
== Related ==

Revision as of 13:06, 29 May 2023


  skip_destroy = true

Official example

resource "aws_volume_attachment" "ebs_att" {
  device_name = "/dev/sdh"
  volume_id   = aws_ebs_volume.example.id
  instance_id = aws_instance.web.id
}
resource "aws_instance" "web" {
  ami               = "ami-21f78e11"
  availability_zone = "us-west-2a"
  instance_type     = "t2.micro"

  tags = {
    Name = "HelloWorld"
  }
}

resource "aws_ebs_volume" "example" {
  availability_zone = "us-west-2a"
  size              = 1
}

Related

See also

Advertising: