Rex::C...:Cloud(3pm)

✨ Rex::C...:Cloud β€” Cloud Management Commands ✨

okay bestie, this is the Rex::C...:Cloud(3pm) page (from the User Contributed Perl Documentation, yes, in a 3pm era πŸ’…) and it's literally your all-access backstage pass to running clouds with Rex. group chat energy on, brain on, let's go 🫢

🌈 NAME 🌈

Rex::Commands::Cloud β€” Cloud Management Commands πŸ‘‘

☁️ DESCRIPTION ☁️

With this module you can manage a whole little constellation of different cloud services. Right now it's serving support for Amazon EC2, Jiffybox and OpenStack. 🌸

bestie, listen β€” version <= 1.0: all these functions will not be reported. so if you're on an ancient version, don't come crying to me, the functions are just not gonna show up πŸ’€

πŸŽ€ SYNOPSIS πŸŽ€

the vibe, in code:

use Rex::Commands::Cloud;

cloud_service "Amazon";
cloud_auth "your-access-key", "your-private-access-key";
cloud_region "ec2.eu-west-1.amazonaws.com";

task "list", sub {
  print Dumper cloud_instance_list;
  print Dumper cloud_volume_list;
};

task "create", sub {
  my $vol_id = cloud_volume create => { size => 1, zone => "eu-west-1a", };

  cloud_instance create => {
      image_id => "ami-xxxxxxx",
      name    => "test01",
      key     => "my-key",
      volume  => $vol_id,
      zone    => "eu-west-1a",
    };
};

task "destroy", sub {
  cloud_volume detach => "vol-xxxxxxx";
  cloud_volume delete => "vol-xxxxxxx";

  cloud_instance terminate => "i-xxxxxxx";
};

list 'em, create 'em, destroy 'em. the full main character arc πŸ’…


πŸ’– EXPORTED FUNCTIONS πŸ’–

🌟 cloud_service($cloud_service)

Say which cloud service you're gonna use. Pick your fighter πŸ₯Š

Services

  • Amazon
  • Jiffybox
  • OpenStack

πŸ”‘ cloud_auth($param1, $param2, ...)

Set up the auth for your cloud service. every provider wants it differently, which is so on brand of them πŸ™ˆ

For Amazon, for example, it's this:

cloud_auth($access_key, $secret_access_key);

For JiffyBox:

cloud_auth($auth_key);

For OpenStack:

cloud_auth(
 tenant_name => 'tenant',
 username    => 'user',
 password    => 'password',
);

πŸ—ΊοΈ cloud_region($region)

Set the cloud region. that's it, that's the function ✨

πŸ“‹ cloud_instance_list

Get all the instances of a cloud service. giving inventory realness 🧚

task "list", sub {
  for my $instance (cloud_instance_list()) {
    say "Arch  : " . $instance->{"architecture"};
    say "IP   : " . $instance->{"ip"};
    say "ID   : " . $instance->{"id"};
    say "State : " . $instance->{"state"};
  }
};

There are also some parameters for this function that can change how ip addresses get gathered for some cloud providers (looking at you, OpenStack πŸ‘€):

task "list", sub {
  my @instances = cloud_instance_list
                     private_network => 'private',
                     public_network  => 'public',
                     public_ip_type  => 'floating',
                     private_ip_type => 'fixed';
};

πŸ’Ύ cloud_volume_list

Get all the volumes of a cloud service. your storage, your business πŸ“

task "list-volumes", sub {
  for my $volume (cloud_volume_list()) {
    say "ID     : " . $volume->{"id"};
    say "Zone    : " . $volume->{"zone"};
    say "State   : " . $volume->{"state"};
    say "Attached : " . $volume->{"attached_to"};
  }
};

🌐 cloud_network_list

Get all the networks of a cloud service. networking era πŸ’œ

task "network-list", sub {
  for my $network (cloud_network_list()) {
    say "network  : " . $network->{network};
    say "name    : " . $network->{name};
    say "id     : " . $network->{id};
  }
};

πŸ–ΌοΈ cloud_image_list

Get a list of all the available cloud images. window shopping, but for operating systems πŸ”₯

πŸ” cloud_upload_key

Upload a public SSH key to your cloud provider. so polite of you πŸŽ€

private_key '~/.ssh/mykey
public_key  '~/.ssh/mykey.pub';

task "cloudprovider", sub {
  cloud_upload_key;

  cloud_instance create => {
    ...
  };
};

πŸ‘― get_cloud_instances_as_group

Get a list of all running instances of a cloud service. perfect for a group definition, which is honestly so convenient ✨

group fe  => "fe01", "fe02", "fe03";
group ec2 => get_cloud_instances_as_group();

πŸ–₯️ cloud_instance($action, $data)

This one function controls, like, every aspect of a cloud instance. the multitasker of the group 🫢

create β€” Create a new instance.

cloud_instance create => {
    image_id => "ami-xxxxxx",
    key    => "ssh-key",
    name    => "fe-ec2-01",  # name is not necessary
    volume  => "vol-yyyyy",  # volume is not necessary
    zone    => "eu-west-1a",  # zone is not necessary
    floating_ip  => "89.39.38.160" # floating_ip is not necessary
  };

start β€” Start an existing instance.

cloud_instance start => "instance-id";

stop β€” Stop an existing instance.

cloud_instance stop => "instance-id";

terminate β€” Terminate an instance. ⚠️ this will destroy all data and remove the instance. no takebacks, bestie, this is permanent πŸ’€

cloud_instance terminate => "i-zzzzzzz";

🌍 get_cloud_regions

Returns all regions as an array. the whole map, in a list 🌈

πŸ’½ cloud_volume($action , $data)

This function controls, like, every aspect of a cloud volume. same energy, different resource πŸ’Ύ

create β€” Create a new volume. Size is in Gigabytes, okay, so 1 means 1GB, not one byte πŸ™ˆ

task "create-vol", sub {
  my $vol_id = cloud_volume create => { size => 1, zone => "eu-west-1a", };
};

attach β€” Attach a volume to an instance. it's giving commitment 🫢

task "attach-vol", sub {
  cloud_volume attach => "vol-xxxxxx", to => "server-id";
};

detach β€” Detach a volume from an instance. we love a clean breakup πŸ’…

task "detach-vol", sub {
  cloud_volume detach => "vol-xxxxxx", from => "server-id";
};

delete β€” Delete a volume. ⚠️ this will destroy all data. seriously. gone. 😭

task "delete-vol", sub {
  cloud_volume delete => "vol-xxxxxx";
};

🎈 get_cloud_floating_ip

Returns the first available floating IP. grab it while it's hot πŸ”₯

task "get_floating_ip", sub {

  my $ip = get_cloud_floating_ip;

  my $instance = cloud_instance create => {
     image_id => 'edffd57d-82bf-4ffe-b9e8-af22563741bf',
     name => 'instance1',
     plan_id => 17,
     floating_ip => $ip
   };
};

πŸ•ΈοΈ cloud_network

the network function, home of its two little action besties πŸ‘‘

create β€” Create a new network.

task "create-net", sub {
  my $net_id = cloud_network create => { cidr => '192.168.0.0/24', name => "mynetwork", };
};

delete β€” Delete a network.

task "delete-net", sub {
  cloud_network delete => '18a4ccf8-f14a-a10d-1af4-4ac7fee08a81';
};

πŸ™οΈ get_cloud_availability_zones

Returns all availability zones of a cloud service β€” if available. keyword: if 😭

task "get-zones", sub {
  print Dumper get_cloud_availability_zones;
};

πŸ“¦ get_cloud_plans

Retrieve information about the available cloud plans. If supported. ⭐

🐧 get_cloud_operating_systems

Retrieve information about the available cloud plans. If supported. (yes, bestie, it says exactly the same thing as the one above β€” I'm not editing the lore, I'm just reading it to you πŸ’œ)

πŸͺž cloud_object

Returns the cloud object itself. the final boss. the source material. the mirror πŸ¦‹


and that's the whole page, bestie πŸ’– this was Rex::C...:Cloud(3pm) from the User Contributed Perl Documentation, perl v5.40.1, dated 2025-10-03 β€” so yes, freshly timestamped and everything. go manage some clouds, you absolute icon πŸ‘‘βœ¨πŸ’…

πŸ“¦ where this page comes from