lib/cloudstrap/amazon/ec2.rb in cloudstrap-0.39.0.pre vs lib/cloudstrap/amazon/ec2.rb in cloudstrap-0.40.0.pre
- old
+ new
@@ -281,17 +281,19 @@
end
Contract KeywordArgs[
cidr_block: Optional[String],
vpc_id: Optional[String],
- subnet_id: Optional[String]
+ subnet_id: Optional[String],
+ availability_zone: Optional[String]
] => ArrayOf[::Aws::EC2::Types::Subnet]
- def subnets(cidr_block: nil, vpc_id: nil, subnet_id: nil)
+ def subnets(cidr_block: nil, vpc_id: nil, subnet_id: nil, availability_zone: nil)
subnets
.select { |subnet| subnet_id.nil? || subnet.subnet_id == subnet_id }
.select { |subnet| vpc_id.nil? || subnet.vpc_id == vpc_id }
.select { |subnet| cidr_block.nil? || subnet.cidr_block == cidr_block }
+ .select { |subnet| availability_zone.nil? || subnet.availability_zone == availability_zone }
end
Contract Args[Any] => Any
def subnets!(**properties)
subnets!
@@ -309,11 +311,12 @@
subnet(properties)
end
Contract KeywordArgs[
cidr_block: String,
- vpc_id: String
+ vpc_id: String,
+ availability_zone: Optional[String]
] => ::Aws::EC2::Types::Subnet
def create_subnet(**properties)
call_api(:create_subnet, properties).subnet
.tap { subnets! }
rescue ::Aws::EC2::Errors::InvalidSubnetConflict
@@ -409,9 +412,25 @@
end
Contract String => Bool
def valid_region?(region_name)
region_names.include? region_name
+ end
+
+ Contract None => ArrayOf[Aws::EC2::Types::AvailabilityZone]
+ def availability_zones!
+ @availability_zones = call_api(:describe_availability_zones)
+ .availability_zones
+ end
+
+ Contract None => ArrayOf[Aws::EC2::Types::AvailabilityZone]
+ def availability_zones
+ @availability_zones ||= availability_zones!
+ end
+
+ Contract None => ArrayOf[String]
+ def availability_zone_names
+ availability_zones.map(&:zone_name)
end
private
def client