module

Krikri::PluginHelpers::Ec2Api

Shared EC2 Query API client for the amazon.aws.* cloud plugins (ec2_key, ec2_security_group, ec2_instance, the *_info lookups).

Every module in the cluster is the same wire pattern the aws_ec2 inventory plugin (inventory_plugins.cr) already speaks: a SigV4-signed POST of form-encoded Action=<Name>&Version=2016-11-15&<params> to ec2.<region>.amazonaws.com, with the XML response body parsed on the way back. This helper wraps exactly that so the six plugins share one signing/POST/error path instead of six copies.

Credentials resolve from the same environment variables the aws_ec2 inventory plugin reads (AWS_ACCESS_KEY_ID/AWS_ACCESS_KEY, AWS_SECRET_ACCESS_KEY/AWS_SECRET_KEY, AWS_SESSION_TOKEN/ AWS_SECURITY_TOKEN); region comes from the module's own region param first, then AWS_REGION/AWS_DEFAULT_REGION - the same fallback chain the inventory plugin uses.

The plugins run wherever krikri-playbook executes their task (the target host, or locally for ansible_connection=local / delegate_to: localhost), so the credentials must be present in that process's environment - same contract real Ansible's aws modules have, just without the boto profile machinery.

Constants

EC2_API_VERSION = "2016-11-15"

Class methods

call(region : String, action : String, params : URI::Params, credentials : Credentials) : XML::Node

One signed EC2 Query API call. params is the flat form body (Action/Version added here unless already present); returns the parsed XML document root. Raises Error on HTTP failure - the EC2 API's own <Errors><Error><Message> text is surfaced when present.

Source
call(region : String | Nil, action : String, params : Hash(String, String) | Array(Tuple(String, String))) : XML::Node

Convenience wrapper: resolve everything, one call, flat params.

Source
child(node : XML::Node, name : String) : XML::Node | Nil

First direct child element with the given name (EC2 XML responses are namespace-qualified; XML::Node#name in Crystal strips the namespace prefix, so plain-name comparison is what the aws_ec2 inventory plugin already relies on).

Source
children(node : XML::Node, name : String) : Array(XML::Node)

All direct child elements with the given name - for the repeated <item> elements of response sets (reservationSet, ipPermissionsSet, tagSet, ...).

Source
filter_params(filters : Array(Tuple(String, Array(String)))) : Array(Tuple(String, String))

Filter.N.Name / Filter.N.Value.M pairs - one filter name with one or more values, numbered from 1 in call order.

Source
items(node : XML::Node, set_name : String) : Array(XML::Node)

A response set's <item> children - e.g. reservationSet/item, ipPermissionsSet/item, tagSet/item.

Source
parse_tags(node : XML::Node) : Hash(String, String)

tagSet items -> {"Name" => "web", ...}

Source
resolve_credentials
Source
resolve_region(param : String | Nil) : String
Source
response_message(body : String) : String | Nil

Pull the human-readable <Message> out of an EC2 error response - the API returns HTTP 4xx with an XML body like <ErrorResponse><Errors><Error>...<Message>...</Message>.

Source
tag_params(tags : Hash(String, String)) : Array(Tuple(String, String))

Tag.N.Key / Tag.N.Value pairs (CreateTags/DeleteTags shape).

Source
text(node : XML::Node, name : String) : String | Nil

child(...).content, nil when the element is missing; empty string normalized to nil (EC2 omits optional elements rather than sending empty ones, but belt-and-suspenders costs nothing).

Source
to_form_params(params : Hash(String, String) | Array(Tuple(String, String))) : URI::Params
Source
transport=(proc : Proc(String, String, String) | Nil) : Nil
Source
transport?
Source

Nested types