AWS SDK for Ruby
Developer Guide

Creating an Internet Gateway and Attaching It to a VPC in Amazon EC2

The following example creates an internet gateway MyGroovyIGW, attaches it to a VPC that has ID VPC_ID, and then displays the internet gateway's ID.

require 'aws-sdk-ec2' # v2: require 'aws-sdk' ec2 = 'us-west-2') igw = ec2.create_internet_gateway igw.create_tags({ tags: [{ key: 'Name', value: 'MyGroovyIGW' }]}) igw.attach_to_vpc(vpc_id: VPC_ID) puts