AWS2 namespace

Amazon Web Services. This namespace is under development. Use at your own risk. This namespace contains resource types that implement common methods: find(), create(), delete(), converge()

Constants, variables and other

AMI_OWNER_DEBIAN
The string "379101102735"
AMI_OWNER_AMAZON
The string "801119661308"

Types

35 types, which are descendants of types listed below, are not shown for brevity
AWS2::CreateOnly
A Box for a property which is to be used only at creation time, not when a resource is updated
AWS2::Res
AWS resource
Direct subtypes: 17
AWS2::ResDef
AWS Resource definition
Direct subtypes: 18
AWS2::Parameter
A Box for a property which is to be used only at creation time, not when a resource is updated

Methods and Multimethods

AWS2::cli_tags(h:Hash)
Convert hash to Key=...,Value=... strings suitable for passing to AWS CLI.

Returns

Arr of Str

Example

diff = Diff(current_tags, target_tags)
if (tags = cli_tags(diff.add + diff.change)) {
	r.run('add tags', %(aws ec2 create-tags --resources ${r.id()} --tags $*tags))
}
AWS2::cli_filters(h:Hash)
Convert Hash with AWS filters to command line arguments. Key-value pairs in which value is null or an EmptyBox object are discarded. TODO: make it JSON when keys or values contain special characters such as = or ,

Returns

Arr of Str
AWS2::cli_tags_filters(h:Hash)
Convert hash to Name=tag:...,Values=... strings suitable for passing to AWS CLI as filters.

Example

filters = AWS2::cli_filters({'vpc-id': ...})
vpcs = ``aws ec2 describe-vpcs --filters $*filters``
AWS2::regions()
Get list of AWS regions. If NGS_AWS_REGIONS environment variable is set, it is used as comma separated list. Otherwise AWS CLI command describe-regions is used. In future, the results of AWS CLI call might be cached.
AWS2::regions(cb:Fun, regs:Arr=[])
Call cb in parallel threads, each with AWS region name as argument.

Parameters

cbMust return an array. regions() sets ._Region in the result and flattens the results

Returns

Arr

Example

ins = AWS2::regions({ ``aws ec2 describe-instances --region $A $*filters`` })
AWS2::regions(cp:CommandsPipeline, regs:Arr=[])
Undocumented
AWS2::zones()internal
Internal method. Please do not use. It does not support regions yet.

Returns

Arr of Str
run(r:AWS2::Res, log_pfx:Str, cp:CommandsPipeline, do_decode:Any=true)internal
Run a command. Internal method. Please do not use outside the AWS library.
run(rd:AWS2::ResDef, log_pfx:Str, cp:CommandsPipeline, do_decode:Any=true)internal
Run an external command related to the resource definition. Will not run the command if rd.dry_run is true.

Parameters

do_decodeWhether to decode the output

Returns

Either parsed output or finished CommandsPipeline (processes in CommandsPipeline finished)
run
This multimethod has additional 2 method(s) not listed above, defined in other namespace(s)
id(r:AWS2::Res)
Get unique identifier of a resource

Example

AWS2::Instance().find().resources[0].id()  # i-0011b2.....
id
This multimethod has additional 2 method(s) not listed above, defined in other namespace(s)
init(rd:AWS2::ResDef, **kw:Hash)
Initialize ResDef from kw. Defaults: null for ._Region and empty hash for .Tags
init(rd:AWS2::ResDef, _ngs_tags:Hash)
Initialize ResDef from _ngs_tags. Sets ._Region to null and .Tags to _ngs_tags.
init(p:AWS2::Parameter, res_type:Type, param_name:Str, param_value:Any)
Undocumented
init(rd:AWS2::SecGroup, GroupName:Str, VpcId:Any)
Initialize SecGroup from security group name and vpc.

Example

AWS2::SecGroup("https-server", AWS2::Vpc(...))
init(rd:AWS2::Instance, **kwargs:Hash)
Initialize Instance (ResDef) from kwargs
init(rd:AWS2::Zone, Name:Str)
Undocumented
init
This multimethod has additional 139 method(s) not listed above, defined in other namespace(s)
find(rd:AWS2::ResDef)
Undocumented
find(rd:AWS2::Subnet)
Declarative primitive for finding AWS Subnet resources
find(rd:AWS2::Image)
Declarative primitive for finding AWS AMI resources
find(rd:AWS2::Instance)
Declarative primitive for finding AWS Instance resources
find(rd:AWS2::Elb)
Declarative primitive for finding AWS Elastic Load Balancer resources
find(rd:AWS2::Zone)
Declarative primitive for finding AWS Route53 hosted zones resources
find(rd:AWS2::RecordSet)
Declarative primitive for finding AWS Route53 RecordSet
find(rd:AWS2::Volume)
Declarative primitive for finding AWS VPC resources
find(rd:AWS2::Snapshot)
Declarative primitive for finding AWS VPC resources. Warning: Owner ids starting with zero must be passed as strings.
find(rd:AWS2::Eip)
Undocumented
find(rd:AWS2::Any)
EXPERIMENTAL! Do not use!
find
This multimethod has additional 14 method(s) not listed above, defined in other namespace(s)
create(rd:AWS2::ResDef, **orig_props:Hash)
Undocumented
create(rd:AWS2::Subnet, **props:Hash)internal
Declarative primitive for creating AWS Subnet resources
create(rd:AWS2::Instance, **props:Hash)internal
Declarative primitive for creating AWS Instance resources
create(rd:AWS2::Elb, **props:Hash)internal
Declarative primitive for creating AWS Elastic Load Balancer resources
create(rd:AWS2::RecordSet, **props:Hash)internal
Declarative primitive for creating AWS Route53 RecordSet resources
create
This multimethod has additional 8 method(s) not listed above, defined in other namespace(s)
update(r:AWS2::Res, orig_props:Hash)
Undocumented
update(sg:AWS2::SecGroupRes, props:Hash)internal
Declarative primitive for updating AWS Security Group resources
update(r:AWS2::SubnetRes, props:Hash)internal
Declarative primitive for updating AWS Subnet resources
update(r:AWS2::InstanceRes, props:Hash)internal
Declarative primitive for updating AWS Instance resources
update(elb:AWS2::ElbRes, props:Hash)internal
Declarative primitive for updating AWS Elastic Load Balancer resources
update(z:AWS2::ZoneRes, props:Hash)
Undocumented
update(rrset:AWS2::RecordSetRes, props:Hash)internal
Declarative primitive for updating AWS Route53 RecordSet resources
update
This multimethod has additional 9 method(s) not listed above, defined in other namespace(s)
delete(r:AWS2::Res)
Undocumented
delete(r:AWS2::SecGroupRes)
Declarative primitive for deleting AWS Security Group resources
delete(r:AWS2::SubnetRes)
Declarative primitive for deleting AWS Subnet resources
delete(r:AWS2::InstanceRes)
Declarative primitive for deleting AWS Instance resources
delete(r:AWS2::ElbRes)
Declarative primitive for deleting AWS Elastic Load Balancer resources
delete(z:AWS2::ZoneRes)
Undocumented
delete(r:AWS2::RecordSetRes)
Declarative primitive for deleting AWS Route53 RecordSet resources
delete(d:AWS2::DistributionRes)
Undocumented
delete
This multimethod has additional 9 method(s) not listed above, defined in other namespace(s)
==(a:_RouteBox, b:_RouteBox)internal
Internal method. Please do not use.

Example

# TODO: example
==(a:_IpPermBox, b:_IpPermBox)internal
Internal method. Please do not use.
==
This multimethod has additional 16 method(s) not listed above, defined in other namespace(s)
users_ids(r:AWS2::SecGroup)
Undocumented
users_ids
This multimethod has additional 1 method(s) not listed above, defined in other namespace(s)
latest(rd:AWS2::Image)
Declarative primitive for referencing latest AWS AMI resources. Will probably be reworked to be special anchor item.

Example

AWS2::Image(OwnerId=AWS_AMI_OWNER_DEBIAN, Name=Pfx('debian-jessie-amd64-hvm'), RootDeviceType='ebs', VolumeType='gp2').latest()
latest
This multimethod has additional 1 method(s) not listed above, defined in other namespace(s)
AWS2::wait_state(r:AWS2::InstanceRes, state_name:Str)
Declarative primitive for waiting for AWS Instance resource to reach given state

Parameters

state_nametypeically "running" or "stopped" (less common)

Returns

r
AWS2::get_console_output(r:AWS2::InstanceRes)
Declarative primitive for getting console output of AWS Instance resource
AWS2::get_ssh_host_keys(r:AWS2::InstanceRes)
Declarative primitive for getting ssh host fingerprints of AWS Instance resource

Returns

Array of Str. Each Str format "key-type base64key"
AWS2::add_to_known_hosts(r:AWS2::Instance, prop_name:Str)experimental
Declarative primitive for adding ssh host fingerprints of AWS Instance resource to known hosts.
AWS2::add_to_known_hosts(r:AWS2::InstanceRes, ip_or_hostname:Any)experimental
Declarative primitive for adding ssh host fingerprints of AWS Instance resource to known hosts.
code(r:AWS2::InstanceRes)experimental
EXPERIMENTAL! Do not use! Converts Instance resources to NGS code. Right now it works in the most primitive way.
code
This multimethod has additional 12 method(s) not listed above, defined in other namespace(s)
AWS2::route53_resource_id(id:Str)
Undocumented
AWS2::pollute(do_warn:Any=true)
Undocumented
AWS2::q(s:Str, **kw:Hash)
Undocumented
AWS2::is_resource_code(s:Str)
Undocumented