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) Source: autoload/AWS.ngs:52
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) Source: autoload/AWS.ngs:59
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) Source: autoload/AWS.ngs:70
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() Source: autoload/AWS.ngs:87
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) Source: autoload/AWS.ngs:94
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 Source: autoload/AWS.ngs:108
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 Source: autoload/AWS.ngs:120
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 Source: autoload/AWS.ngs:190
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) Source: autoload/AWS.ngs:127
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) Source: autoload/AWS.ngs:156
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) Source: autoload/AWS.ngs:168
Initialize ResDef from kw. Defaults: null for .regions and empty hash for .Tags
init(rd:AWS::ResDef, _ngs_name:Str) Source: autoload/AWS.ngs:180
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) Source: autoload/AWS.ngs:183
Initialize ResDef from _ngs_tags. Sets .regions to null and .Tags to _ngs_tags.
init(rd:AWS::SecGroup, anchor:Arr)deprecated Source: autoload/AWS.ngs:496
Initialize SecGroup from Arr of [name, vpc_id].
init(rd:AWS::SecGroup, Name:Str, VpcId:Any) Source: autoload/AWS.ngs:503
Initialize SecGroup from security group name and vpc.

Example

AWS::SecGroup("https-server", AWS::Vpc(...))
init(rd:AWS::Instance, **kwargs:Hash) Source: autoload/AWS.ngs:759
Initialize Instance (ResDef) from kwargs
init
This multimethod has additional 93 method(s) not listed above, defined in other namespace(s)
find(rd:AWS::Vpc) Source: autoload/AWS.ngs:253
Declarative primitive for finding AWS VPC resources
find(rd:AWS::Igw) Source: autoload/AWS.ngs:330
Declarative primitive for finding AWS InternetGateway resources
find(rd:AWS::RouteTable) Source: autoload/AWS.ngs:421
Declarative primitive for finding AWS RouteTable resources
find(rd:AWS::SecGroup) Source: autoload/AWS.ngs:525
Declarative primitive for finding AWS Security Group resources
find(rd:AWS::Subnet) Source: autoload/AWS.ngs:642
Declarative primitive for finding AWS Subnet resources
find(rd:AWS::Image) Source: autoload/AWS.ngs:703
Declarative primitive for finding AWS AMI resources
find(rd:AWS::Instance) Source: autoload/AWS.ngs:772
Declarative primitive for finding AWS Instance resources
find(rd:AWS::Elb) Source: autoload/AWS.ngs:1078
Declarative primitive for finding AWS Elastic Load Balancer resources
find(rd:AWS::Zone) Source: autoload/AWS.ngs:1232
Declarative primitive for finding AWS Route53 hosted zones resources
find(rd:AWS::RecordSet) Source: autoload/AWS.ngs:1279
Declarative primitive for finding AWS Route53 RecordSet
find(rd:AWS::Volume) Source: autoload/AWS.ngs:1390
Declarative primitive for finding AWS VPC resources
find(rd:AWS::Snapshot) Source: autoload/AWS.ngs:1431
Declarative primitive for finding AWS VPC resources. Warning: Owner ids starting with zero must be passed as strings.
find(rd:AWS::Eip) Source: autoload/AWS.ngs:1476
Declarative primitive for finding AWS Elastic IP resources
find(rd:AWS::Any) Source: autoload/AWS.ngs:1661
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 Source: autoload/AWS.ngs:272
Declarative primitive for creating AWS VPC resources
create(rd:AWS::Igw, **props:Hash)internal Source: autoload/AWS.ngs:345
Declarative primitive for creating AWS InternetGateway resources
create(rd:AWS::SecGroup, **props:Hash)internal Source: autoload/AWS.ngs:574
Declarative primitive for creating AWS Security Group resources
create(rd:AWS::Subnet, **props:Hash)internal Source: autoload/AWS.ngs:658
Declarative primitive for creating AWS Subnet resources
create(rd:AWS::Instance, **props:Hash)internal Source: autoload/AWS.ngs:827
Declarative primitive for creating AWS Instance resources
create(rd:AWS::Elb, **props:Hash)internal Source: autoload/AWS.ngs:1105
Declarative primitive for creating AWS Elastic Load Balancer resources
create(rd:AWS::RecordSet, **props:Hash)internal Source: autoload/AWS.ngs:1320
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 Source: autoload/AWS.ngs:284
Declarative primitive for updating AWS VPC resources
update(r:AWS::IgwRes, props:Hash)internal Source: autoload/AWS.ngs:358
Declarative primitive for creating AWS InternetGateway resources
update(r:AWS::RouteTableRes, props:Hash)internal Source: autoload/AWS.ngs:433
Declarative primitive for updating AWS RouteTable resources
update(sg:AWS::SecGroupRes, props:Hash)internal Source: autoload/AWS.ngs:588
Declarative primitive for updating AWS Security Group resources
update(r:AWS::SubnetRes, props:Hash)internal Source: autoload/AWS.ngs:673
Declarative primitive for updating AWS Subnet resources
update(r:AWS::InstanceRes, props:Hash)internal Source: autoload/AWS.ngs:855
Declarative primitive for updating AWS Instance resources
update(elb:AWS::ElbRes, props:Hash)internal Source: autoload/AWS.ngs:1127
Declarative primitive for updating AWS Elastic Load Balancer resources
update(rrset:AWS::RecordSetRes, props:Hash)internal Source: autoload/AWS.ngs:1337
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) Source: autoload/AWS.ngs:294
Declarative primitive for deleting AWS VPC resources
delete(r:AWS::IgwRes) Source: autoload/AWS.ngs:388
Declarative primitive for deleting AWS InternetGateway resources
delete(r:AWS::RouteTableRes) Source: autoload/AWS.ngs:473
Declarative primitive for deleting AWS RouteTable resources
delete(r:AWS::SecGroupRes) Source: autoload/AWS.ngs:621
Declarative primitive for deleting AWS Security Group resources
delete(r:AWS::SubnetRes) Source: autoload/AWS.ngs:680
Declarative primitive for deleting AWS Subnet resources
delete(r:AWS::InstanceRes) Source: autoload/AWS.ngs:900
Declarative primitive for deleting AWS Instance resources
delete(r:AWS::ElbRes) Source: autoload/AWS.ngs:1204
Declarative primitive for deleting AWS Elastic Load Balancer resources
delete(r:AWS::RecordSetRes) Source: autoload/AWS.ngs:1355
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 Source: autoload/AWS.ngs:404
Internal method. Please do not use.

Example

# TODO: example
==(a:AWS::IpPermBox, b:AWS::IpPermBox)internal Source: autoload/AWS.ngs:565
Internal method. Please do not use.
==
This multimethod has additional 16 method(s) not listed above, defined in other namespace(s)
users_ids(r:AWS::SecGroup) Source: autoload/AWS.ngs:516
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) Source: autoload/AWS.ngs:732
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) Source: autoload/AWS.ngs:934
Declarative primitive for waiting for AWS Instance resource to reach given state

Parameters

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

Returns

r
AWS::get_console_output(r:AWS::InstanceRes) Source: autoload/AWS.ngs:954
Declarative primitive for getting console output of AWS Instance resource
AWS::get_ssh_host_keys(r:AWS::InstanceRes) Source: autoload/AWS.ngs:971
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 Source: autoload/AWS.ngs:979
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 Source: autoload/AWS.ngs:991
Declarative primitive for adding ssh host fingerprints of AWS Instance resource to known hosts.
code(r:AWS::InstanceRes)experimental Source: autoload/AWS.ngs:1038
EXPERIMENTAL! Do not use! Converts Instance resources to NGS code. Right now it works in the most primitive way.
code
This multimethod has additional 7 method(s) not listed above, defined in other namespace(s)
AWS::validate(rd:AWS::RecordSet) Source: autoload/AWS.ngs:1270
Declarative primitive for validating AWS Route53 RecordSet
AWS::pollute(do_warn:Any=true) Source: autoload/AWS.ngs:1556
Undocumented
AWS::q(id:Str, **kw:Hash)WIP Source: autoload/AWS.ngs:1586
Work in progress, do not use!

Example

AWS::q("vpc-11111111")  # references specific vpc
AWS::q(id:Str, **kw:Hash)WIP Source: autoload/AWS.ngs:1605
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) Source: autoload/AWS.ngs:1611
Undocumented