Right now I have an EBS storage volume in the us-east-2b
availability zone. However, I have some code that is automating the process of creating an instance and it's using us-east-2
as its availability zone. The problem is that the instance seems to be created in whatever availability zone it wants -- us-east-2a
, us-east-2b
, us-east-2c
... and so when I try to attach a volume to the instance, it gives me the following error:
Aws::EC2::Errors::InvalidVolumeZoneMismatch (The volume 'vol-XXXX' is not in the same availability zone as instance 'i-XXXX')
In order to provide some consistency and avoid having this problem, I'd just like to create an instance in a specific availability zone such as us-east-2b
so that it matches the same of the EBS storage volume.
I'm also using the ruby aws-sdk
for this. Any idea if this is possible?
If I try specifying us-east-2b
, then I get the following error:
2.5.1 :080 > @ec2 = Aws::EC2::Resource.new(region: 'us-east-2b')
Traceback (most recent call last):
2: from (irb):80
1: from (irb):80:in `new'
ArgumentError (:region option must a region name, not an availability zone name; try `us-east-2' instead of `us-east-2b')
so I don't understand how it's possible to solve this problem. Do I need to just keep re-creating instances in the xxx-2
availability zone until I magically end up in xxx-2b
? Or do I need to figure out another way to keep replicating snapshots back and forth so that the EBS storage volume is consistent across all 3 availability zones in us-east-2a/b/c
?