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 10.200.0.0/16. 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 = Aws::EC2::Resource.new(region: 'us-west-2') vpc = ec2.create_vpc({ cidr_block: '10.200.0.0/16' }) # 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