lib/sles4sap/aws_cli.pm

SYNOPSIS

Library to compose and run AWS cli commands.

aws_vpc_create

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

region - AWS region where to create the VPC
cidr - CIDR block for the VPC (e.g., '10.0.0.0/16')
job_id - OpenQA job identifier for tagging

aws_vpc_get_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

region - AWS region where the VPC is located
job_id - OpenQA job identifier used to tag the VPC

aws_vpc_delete

aws_vpc_delete(
    region => 'us-west',
    vpc_id => 'vpc-456');

Delete the VPC

region - AWS region where the VPC is located
vpc_id - ID of the VPC to delete

aws_security_group_create

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

region - AWS region where to create the security group
group_name - name for the security group
description - description of the security group purpose
vpc_id - ID of the VPC where the security group will be created
job_id - OpenQA job identifier used to tag the VPC

aws_security_group_delete

my $sg_id = aws_security_group_delete(
    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

region - AWS region where to create the security group
job_id - OpenQA job identifier used to tag the VPC

aws_security_group_get_id

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

region - AWS region where the security group is located
job_id - OpenQA job identifier used to tag the security group

aws_security_group_authorize_ingress

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

sg_id - ID of the security group to modify
protocol - protocol for the rule (e.g., 'tcp', 'udp', 'icmp')
port - port number or port range for the rule
cidr - CIDR block allowed to access (e.g., '0.0.0.0/0' for all)
region - AWS region where the security group is located

aws_subnet_create

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

region - AWS region where to create the subnet
cidr - CIDR block for the subnet (e.g., '10.0.1.0/24')
vpc_id - ID of the VPC where the subnet will be created
job_id - OpenQA job identifier used to tag the security group

aws_subnet_get_id

my $subnet_id = aws_subnet_get_id(
    region => 'us-west-1',
    job_id => '67890'
);

Retrieve the subnet ID associated with a specific OpenQA job Returns the subnet ID

region - AWS region where the subnet is located
job_id - OpenQA job identifier used to tag the subnet

aws_subnet_delete

aws_subnet_delete(
    region => 'us-west-1',
    job_id => '67890'
);

Delete subnet

region - AWS region where the subnet is located
job_id - OpenQA job identifier used to tag the subnet

aws_internet_gateway_create

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

region - AWS region where to create the internet gateway
job_id - OpenQA job identifier used to tag the security group

aws_internet_gateway_get_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

region - AWS region where the internet gateway is located
job_id - OpenQA job identifier used to tag the internet gateway

aws_internet_gateway_attach

aws_internet_gateway_attach(
    vpc_id => 'vpc-12345',
    igw_id => 'igw-abcde',
    region => 'us-west-1'
);

Attach an internet gateway to a VPC

vpc_id - ID of the VPC to attach the gateway to
igw_id - ID of the internet gateway to attach
region - AWS region where the resources are located

aws_internet_gateway_delete

aws_internet_gateway_delete(
    job_id => '6789',
    vpc_id => 'vpc-12345',
    region => 'us-west-1'
);

Delete internet gateway

region - AWS region where the resources are located
vpc_id - ID of the VPC to attach the gateway to
job_id - OpenQA job identifier for tagging

aws_route_table_create

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

region - AWS region where to create the route table
vpc_id - ID of the VPC where the route table will be created

aws_route_table_associate

aws_route_table_associate(
    subnet_id => 'subnet-12345',
    route_table_id => 'rtb-abcde',
    region => 'us-west-1'
);

Associate a route table with a subnet

subnet_id - ID of the subnet to associate
route_table_id - ID of the route table to associate
region - AWS region where the resources are located

aws_route_table_delete

aws_route_table_delete(
    vpc_id => 'subnet-12345',
    region => 'us-west-1'
);

Delete a route table

vpc_id - ID of the VPC
region - AWS region where the resources are located

aws_route_create

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

route_table_id - ID of the route table where to create the route
destination_cidr_block - destination CIDR block for the route (e.g., '0.0.0.0/0' for default route)
igw_id - ID of the internet gateway as the route target
region - AWS region where the resources are located

aws_vm_create

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

instance_type - EC2 instance type (e.g., 't2.micro', 'm5.large')
image_name - Name to use for the instance
owner - Image owner, used to serch the AMI
subnet_id - ID of the subnet where to launch the instance
sg_id - ID of the security group to assign to the instance
ssh_key - name of the SSH key pair for instance access
region - AWS region where to launch the instance
job_id - OpenQA job identifier used to tag the internet gateway

aws_vm_get_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

region - AWS region where the instance is located
job_id - OpenQA job identifier used to tag the instance

aws_vm_wait_status_ok

aws_vm_wait_status_ok(
    instance_id => 'i-12345'
);

Wait for an EC2 instance to reach 'running' state with a timeout of 600 seconds

instance_id - ID of the instance to monitor

aws_get_ip_address

my $ip = aws_get_ip_address(
    instance_id => 'i-12345'
);

Retrieve the public IP address of an EC2 instance Returns the public IP address

instance_id - ID of the instance

aws_vm_terminate

aws_vm_terminate(
    region => 'us-west-1',
    instance_id => 'i-12345'
);

Terminate an EC2 instance and wait for it to be terminated.

region - AWS region where the instance is located
instance_id - ID of the instance to terminate

aws_ssh_key_pair_import

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

ssh_key - name to assign to the imported key pair in AWS
pub_key_path - filesystem path to the public key file