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
Class methods
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.
Convenience wrapper: resolve everything, one call, flat params.
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).
All direct child elements with the given name - for the repeated <item> elements of response sets (reservationSet, ipPermissionsSet, tagSet, ...).
Filter.N.Name / Filter.N.Value.M pairs - one filter name with one or more values, numbered from 1 in call order.
A response set's <item> children - e.g. reservationSet/item, ipPermissionsSet/item, tagSet/item.
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>.
Tag.N.Key / Tag.N.Value pairs (CreateTags/DeleteTags shape).
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).