AWS namespace

Amazon Web Services. This namespace contains declarative primitives resource types that implement common methods: find(), create(), delete(), converge()

Sub-namespaces

AWS::util
Misc AWS utilities to make your life easier
1 types, 3 multimethods

Constants, variables and other

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

Types

27 types, which are descendants of types listed below, are not shown for brevity
AWS::Res
AWS resource
Direct subtypes: 13
AWS::ResDef
AWS Resource definition
Direct subtypes: 14
AWS::RouteBox
Internal type. Please do not use.
AWS::IpPermBox
Internal type. Please do not use.

Methods and Multimethods

AWS::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))
}
AWS::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
AWS::cli_tags_filters(h:Hash)
Convert hash to Name=tag:...,Values=... strings suitable for passing to AWS CLI as filters.

Example

filters = AWS::cli_filters({'vpc-id': ...})
vpcs = ``aws ec2 describe-vpcs --filters $*filters``
AWS::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.
AWS::regions(cb:Fun)
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 = AWS::regions({ ``aws ec2 describe-instances --region $A $*filters`` })
AWS::zones()internal
Internal method. Please do not use. It does not support regions yet.

Returns

Arr of Str
run(r:AWS::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:AWS::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)
AWS::update_tags(r:AWS::Res, props:Hash)
Don't call directly, use converge(). API subject to change. Update tags using AWS CLI "aws ec2 create-tags" and "aws ec2 delete-tags". The required AWS CLI is computed from current tags, which are expected to be in r.props.Tags, and props.Tags

Returns

Do not count on this value.
id(r:AWS::Res)
Get unique identifier of a resource

Example

AWS::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:AWS::ResDef, **kw:Hash)
Initialize ResDef from kw. Defaults: null for .regions and empty hash for .Tags
init(rd:AWS::ResDef, _ngs_name:Str)
Initialize ResDef from _ngs_name. Sets .regions to null, .Tags to empty hash and .Name to _ngs_name.
init(rd:AWS::ResDef, _ngs_tags:Hash)
Initialize ResDef from _ngs_tags. Sets .regions to null and .Tags to _ngs_tags.
init(rd:AWS::SecGroup, anchor:Arr)deprecated
Initialize SecGroup from Arr of [name, vpc_id].
init(rd:AWS::SecGroup, Name:Str, VpcId:Any)
Initialize SecGroup from security group name and vpc.

Example

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

Example

# TODO: example
==(a:AWS::IpPermBox, b:AWS::IpPermBox)internal
Internal method. Please do not use.
==
This multimethod has additional 17 method(s) not listed above, defined in other namespace(s)
users_ids(r:AWS::SecGroup)
Declarative primitive to convert AWS Security Group to array of hashes with GroupId and UserId keys. Looks like it's badly named. Candidate for renaming. Additional plan is to eliminate the need for this method.

Returns

Arr of Hash. Each Hash has: GroupId, UserId

Example

sg = AwsSecGroup(...) # servers behing ELB
# Allow traffic from ELB to the servers
sg.converge(..., IpPermissions = [{UserIdGroupPairs = elb_sg.users_ids(), ...}])
# In future, should be:
sg.converge(..., IpPermissions = [{UserIdGroupPairs = elb_sg, ...}])
users_ids
This multimethod has additional 1 method(s) not listed above, defined in other namespace(s)
latest(rd:AWS::Image)
Declarative primitive for referencing latest AWS AMI resources. Will probably be reworked to be special anchor item.

Example

AWS::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)
AWS::wait_state(r:AWS::InstanceRes, state_name:Str)
Declarative primitive for waiting for AWS Instance resource to reach given state

Parameters

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

Returns

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

Returns

Array of Str. Each Str format "key-type base64key"
AWS::add_to_known_hosts(r:AWS::Instance, prop_name:Str)experimental
Declarative primitive for adding ssh host fingerprints of AWS Instance resource to known hosts.
AWS::add_to_known_hosts(r:AWS::InstanceRes, ip_or_hostname:Any)experimental
Declarative primitive for adding ssh host fingerprints of AWS Instance resource to known hosts.
code(r:AWS::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 9 method(s) not listed above, defined in other namespace(s)
AWS::validate(rd:AWS::RecordSet)
Declarative primitive for validating AWS Route53 RecordSet
AWS::pollute(do_warn:Any=true)
Undocumented
AWS::q(id:Str, **kw:Hash)WIP
Work in progress, do not use!

Example

AWS::q("vpc-11111111")  # references specific vpc
AWS::q(id:Str, **kw:Hash)WIP
Work in progress, do not use!

Example

AWS::q("vpc")  # references all vpcs
AWS::q("vpc", Tags={"env": "proxy-lab"})
AWS::is_resource_code(s:Str)
Undocumented