Hi,
I am trying to provision on-spot instance but its getting failed with below error
Error: reading EC2 Spot Instance Request (sir-ecXXXXX): reading block devices: InvalidVolume.NotFound: The volume ‘vol-XXXXXXXXXXXXXXXX’ does not exist.
I did try to add volume but no luck. This is my code
resource “aws_spot_instance_request” “onspot_instance” {
ami = local.image_id_app
spot_price = local.spot_price
instance_type = local.instance_type
spot_type = local.spot_type
wait_for_fulfillment = “true”
subnet_id = local.private_subnet_az_a
iam_instance_profile = “RoleForSSM”
tags = local.common_tags
}
resource “aws_ebs_volume” “extra” {
availability_zone = local.AZ_A
size = 10
tags = {
Name = “TestVolume”
}
}
resource “aws_volume_attachment” “ebs_attach” {
device_name = “/dev/sdf”
volume_id = aws_ebs_volume.extra.id
instance_id = aws_spot_instance_request.onspot_instance.id
}
Can anyone please suggest what am I doing wrong