rset(1) : Formulas

Amazon Web Services

fog is a ruby cloud services library that supports numerous provicers.

Instance Creation


interpreter=/usr/local/bin/ruby25

amazon:
    require "fog"
    ec2 = Fog::Compute.new :provider => 'AWS', :region => 'us-east-1'
    instance = ec2.servers.get("i-03e58c3325aa074ba")
    exit if instance
    response = ec2.run_instances(
      "ami-0467267b",
      1,
      1,
        "InstanceType"  => "t1.micro",
        "KeyName"       => "radman-aws",
        "SubnetId"      => "subnet-3bf94a72",
        "SecurityGroupId" => "sg-9f644fe5"
    )
    instance_id = response.body["instancesSet"].first["instanceId"]
    instance = ec2.servers.get(instance_id)
    instance.wait_for { ready? }
    puts instance.public_ip_address

Last updated on October 10, 2018