AWS SDK for Ruby
Developer Guide

Creating a Public Subnet for Amazon EC2

The following example creates a public subnet MyGroovySubnet in the us-west-2 region and the Availablity Zone us-west-2a. The example attaches the public subnet to a VPC with the ID VPC_ID that uses the CIDR block, and then displays the subnet's ID.

The public subnet created in this example has 256 private IP addresses within the VPC.

require 'aws-sdk-ec2' # v2: require 'aws-sdk' ec2 = 'us-west-2') subnet = ec2.create_subnet({ vpc_id: VPC_ID, cidr_block: '', availability_zone: 'us-west-2a' }) subnet.create_tags({ tags: [{ key: 'Name', value: 'MyGroovySubnet' }]}) puts