AWS SDK for Ruby
Developer Guide

Creating an Amazon EC2 VPC

The following example creates the virtual private cloud (VPC) MyGroovyVPC with the CIDR block Then it displays the VPC's ID.

The example creates a virtual network with 65,536 private IP addresses.

require 'aws-sdk-ec2' # v2: require 'aws-sdk' ec2 = 'us-west-2') vpc = ec2.create_vpc({ cidr_block: '' }) # So we get a public DNS vpc.modify_attribute({ enable_dns_support: { value: true } }) vpc.modify_attribute({ enable_dns_hostnames: { value: true } }) # Name our VPC vpc.create_tags({ tags: [{ key: 'Name', value: 'MyGroovyVPC' }]}) puts vpc.vpc_id