Library to compose and run AWS cli commands.
my $vpc_id = aws_vpc_create(
region => 'us-west',
cidr => '1.2.3/18',
job_id => 'abc123456');
Create a new AWS VPC with a specified CIDR block and tag it with the OpenQA job ID Returns the VPC ID
my $vpc_id = aws_vpc_get_id(
region => 'us-west',
job_id => 'abc123456');
Retrieve the VPC ID associated with a specific OpenQA job Returns the VPC ID
my $ret = aws_vpc_delete(
region => 'us-west',
vpc_id => 'vpc-456');
Delete the VPC, do not assert but return the exit code of the command.
my $sg_id = aws_security_group_create(
region => 'uswest',
group_name => 'something',
description => 'be or not to be',
vpc_id => 'vpc123456',
job_is => '7890');
Create an AWS security group within a VPC and tag it with the OpenQA job ID
Returns the security group ID
my $ret = aws_security_group_delete(
region => 'uswest',
group_name => 'something',
description => 'be or not to be',
vpc_id => 'vpc123456',
job_is => '7890');
Delete the security group, do not assert but return the exit code of the command.
my $sg_id = aws_security_group_get_id(region => 'europe', job_id => '12345');
Retrieve the security group ID associated with a specific OpenQA job Returns the security group ID
aws_security_group_authorize_ingress(
sg_id => ,
protocol => ,
port =>,
cidr =>,
region => );
Add an ingress rule to a security group allowing traffic from a specific CIDR block
my $subnet_id = aws_subnet_create(
region => 'us-west-1',
cidr => '10.0.1.0/24',
vpc_id => 'vpc-12345',
job_id => '67890'
);
Create a subnet within a VPC with a specified CIDR block and tag it with the OpenQA job ID Returns the subnet ID
my @subnet_ids = aws_subnet_get_ids(
region => 'us-west-1',
job_id => '67890'
);
Retrieve the list of subnet IDs associated with a specific OpenQA job Returns the list of subnet IDs
my $ret = aws_subnet_delete(
region => 'us-west-1',
job_id => '67890'
);
Delete the subnets associated with the job, do not assert but return the exit code of the command.
my $igw_id = aws_internet_gateway_create
region => 'us-west-1',
job_id => '67890'
);
Create an internet gateway and tag it with the OpenQA job ID Returns the internet gateway ID
my $igw_id = aws_internet_gateway_get_id(
region => 'us-west-1',
job_id => '67890'
);
Retrieve the internet gateway ID associated with a specific OpenQA job Returns the internet gateway ID
aws_internet_gateway_attach(
vpc_id => 'vpc-12345',
igw_id => 'igw-abcde',
region => 'us-west-1'
);
Attach an internet gateway to a VPC
my $ret = aws_internet_gateway_delete(
job_id => '6789',
vpc_id => 'vpc-12345',
region => 'us-west-1'
);
Delete the internet gateway, do not assert but return the exit code of the command.
my $route_table_id = aws_route_table_create(
region => 'us-west-1',
vpc_id => 'vpc-12345'
);
Create a route table within a VPC Returns the route table ID
aws_route_table_associate(
subnet_id => 'subnet-12345',
route_table_id => 'rtb-abcde',
region => 'us-west-1'
);
Associate a route table with a subnet
my $ret = aws_route_table_delete(
vpc_id => 'subnet-12345',
region => 'us-west-1'
);
Delete the route table(s), do not assert but return the first non-zero exit code of the commands, or 0 on success.
aws_route_create(
route_table_id => 'rtb-12345',
destination_cidr_block => '0.0.0.0/0',
igw_id => 'igw-abcde',
region => 'us-west-1'
);
Create a route in a route table pointing to an internet gateway
my $instance_id = aws_vm_create(
instance_type => 't2.micro',
image_name => 'sles-15-sp3',
subnet_id => 'subnet-12345',
sg_id => 'sg-abcde',
ssh_key => 'my-key',
region => 'us-west-1',
job_id => '67890'
);
Launch an EC2 instance with specified configuration and tag it with the OpenQA job ID Returns the instance ID
my $instance_id = aws_vm_get_id(
region => 'us-west-1',
job_id => '67890'
);
Retrieve the EC2 instance ID associated with a specific OpenQA job Returns the instance ID
aws_vm_wait_status_ok(
instance_id => 'i-12345'
);
Wait for an EC2 instance to reach 'running' state with a timeout of 600 seconds
my $ip = aws_get_ip_address(
instance_id => 'i-12345'
);
Retrieve the public IP address of an EC2 instance Returns the public IP address
my $ret = aws_vm_terminate(
region => 'us-west-1',
instance_id => 'i-12345'
);
Terminate an EC2 instance and wait for it to be terminated, do not assert but return the exit code of the command.
aws_ssh_key_pair_import(
ssh_key => 'my-key',
pub_key_path => '/path/to/key.pub'
);
Import an SSH public key pair into AWS EC2 for instance authentication
my $attach_id = aws_tgw_vpc_attachment_get_id(region => 'us-west-1', job_id => 'job-123');
Retrieve the TGW attachment ID associated with a specific OpenQA job. Returns the TGW attachment ID as a string. Only the first element found is returned.
my $res = aws_filter_query(cmd => 'describe-instances', filter => 'Name=instance-id,Values=i-123', query => 'Reservations[*].Instances[*].InstanceId');
Generic function to compose a aws cli command with filter and query. Returns the script output.
my $tgw_id = aws_tgw_get_id(mirror_tag => 'my-project');
Return the Transit Gateway ID associated with a specific Project tag.
my @subnets = aws_vpc_get_subnets(vpc_id => 'vpc-123', region => 'us-east-1');
Return a list of subnets for a VPC, one per Availability Zone.
my $rt_ids = aws_vpc_get_routing_tables(vpc_id => 'vpc-123', region => 'us-east-1');
Get routing table IDs for a VPC that have external connections (non-local).
my $res = aws_tgw_attachment_get(name => 'my-attachment');
Get a description of one or more transit-gateway-attachments. Returns an array reference of hash references (list of dicts). return value = [ {State => 'pending'} ...]
aws_tgw_attachment_create(
transit_gateway_id => 'tgw-123',
vpc_id => 'vpc-456',
subnet_id_list => ['subnet-1'],
name => 'my-attach'
);
Create a Transit Gateway VPC attachment and wait until it is available. Returns true if the attachment becomes available within the timeout, false otherwise.
aws_tgw_attachment_delete(id => 'tgwa-123');
Delete a Transit Gateway VPC attachment and wait until it is deleted. Returns true if the attachment is successfully deleted (or if wait is set to 0), false if it times out while waiting for the deleted state.
aws_route_create_tgw(rtable_id => 'rtb-1', target_ip_net => '10.0.0.0/8', trans_gw_id => 'tgw-1');
Add a route to a Transit Gateway in a routing table.