ResDef type

Abstract resource definition

Direct parent types

Eachable1
Eachable which each() calls the callback with one argument
Direct subtypes: 16

Direct children types

AWS::ResDef
AWS Resource definition
Direct subtypes: 14
AWS2::ResDef
AWS Resource definition
Direct subtypes: 18

Methods

Bool(rd:ResDef) Source: autoload/Res.ngs:107
Check whether any resources were found.

Returns

Bool

Example

# Implicit Bool(): if expr -> if Bool(expr)
if AWS::Instance({"env": "dev", "role": "edge"}) {
  echo("There is at least one edge server in dev environment")
}
converge(rd:ResDef, **props:Hash) Source: autoload/Res.ngs:145
Ensure that resources matching resource definition have given properties. This operation will do necessary changes, including creating the resource(s) if they do not exist.

Returns

rd

Example

# Idempotent
PROXY_LAB_TAGS = { 'env': 'proxy-lab' }
PROXY_LAB_VPC_CIDR = '192.168.10.0/24'
vpc    = AWS::Vpc(VPN_POC_TAGS).converge(CidrBlock=VPN_POC_CIDR, Tags=VPN_POC_TAGS)
gw     = AWS::Igw(Attachments=[{'VpcId': vpc}]).converge(Tags=VPN_POC_TAGS)
rtb    = AWS::RouteTable(VpcId=vpc).converge(Routes=Present({"DestinationCidrBlock": "0.0.0.0/0", "GatewayId": gw}))
subnet = AWS::Subnet(VpcId=vpc, CidrBlock=VPN_POC_CIDR).converge()
create(rd:ResDef, n:Int, **props:Hash) Source: autoload/Res.ngs:174
Create n resources with given props. Typically called by converge().

Returns

rd
created(rd:ResDef, resources:Arr, props:Hash) Source: autoload/Res.ngs:201
Called by create() on new resources. Appends the new resources to the list and runs update(). Don't call directly.

Parameters

resourcesArr of Res
delete(rd:ResDef) Source: autoload/Res.ngs:184
Delete the resources matching resource definition.

Returns

rd
each(rd:ResDef, cb:Fun) Source: autoload/Res.ngs:80
Call cb with properties of each found resource

Returns

rd

Example

AWS::Instance().each(F(i) echo(i.InstanceId))
expect(rd:ResDef, e:Int) Source: autoload/Res.ngs:61
Throw an exception unless there is exactly e resources were found. Useful to express assumptions before operating.

Returns

rd

Example

slave_build_server = AWS::Instance(Tags={'env': 'aux', 'role': 'build-slave'}).expect(1)
subnets = AWS::Subnet(my_vpc_anchor).expect(2)
expect(rd:ResDef) Source: autoload/Res.ngs:71
Throw an exception unless the resources were found. Useful to express assumptions before operating.

Returns

rd

Example

instances = AWS::Instance({'env': env, 'role': role}).expect()
filter(rd:ResDef, predicate:Fun) Source: autoload/Res.ngs:93
Create new resource definition by filtering resources of rd.

Parameters

rdOriginal resource definition. Not modified.

Returns

ResDef

Example

# Get instances with last private IP octet less than 20:
AWS::Instance().filter({A.PrivateIpAddress.split(".")[-1].Int()<20})
find_if_needed(rd:ResDef) Source: autoload/Res.ngs:48
Populates .resources by running .find(), if it was not done yet.

Returns

rd
ids(rd:ResDef) Source: autoload/Res.ngs:193
Get IDs of the resources matching resource definition.

Returns

Arr
init(rd:ResDef, anchor:Any) Source: autoload/Res.ngs:8
Undocumented
init(rd:ResDef) Source: autoload/Res.ngs:25
Creates resource definition with empty Hash anchor.
init(r:Res, def:ResDef, props:Hash) Source: autoload/Res.ngs:124
Stores def and props in r
Iter(rd:ResDef) Source: autoload/Res.ngs:114
EXPERIMENTAL! Do not use!
len(rd:ResDef) Source: autoload/Res.ngs:20
Check how many resources are matching given resource definition. Throws InvalidArgument if resources were not looked up yet.
log(rd:ResDef, method:Str, s:Str) Source: autoload/Res.ngs:42
Formats and logs message s for resource definition rd.

Parameters

methodthe name of calling method which also goes to the formatted message.
opt_prop(rd:ResDef, name:Str, props:Hash) Source: autoload/Res.ngs:211
Get optional resource property, looking up in properties first and then in anchor.

Returns

Box
opt_prop(rd:ResDef, name:Str, props:Hash, cb:Fun) Source: autoload/Res.ngs:214
Run cb with optional resource property if it exists, uses opt_prop(ResDef, Str, Hash)
req_prop(rd:ResDef, name:Str, props:Hash) Source: autoload/Res.ngs:218
Get resource property, looking up in properties first and then in anchor
Str(rd:ResDef) Source: autoload/Res.ngs:29
Converts resource definition to a string, for displaying purposes.