Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cloudmonkey

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cloudmonkey - npm Package Compare versions

Comparing version 1.0.0-alpha.2 to 1.0.0-alpha.3

2

package.json
{
"name": "cloudmonkey",
"version": "1.0.0-alpha.2",
"version": "1.0.0-alpha.3",
"description": "Small infrastructure testing framework -- EXPERIMENTAL",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -74,3 +74,3 @@ # CloudMonkey

```bash
CloudMonkey 1.0.0-alpha.0
CloudMonkey 1.0.0

@@ -80,2 +80,3 @@ service "ec2"

filter by "id", "vpc"
travel to "subnet", "securityGroup"
* resource type "internetGateway"

@@ -91,2 +92,3 @@ filter by "id", "vpc"

filter by "id", "vpc"
travel to "instance"
```

@@ -96,10 +98,10 @@

The selection syntax provides a means to select resources. For example:
The selection interface provides a means to select resources in your infrastructure. For example:
```javascript
const monkey = new CloudMonkey();
...
monkey.register(new EC2({ region: 'eu-central-1' }));
const igw = await monkey.select.one.ec2.internetGateway({ vpc: 'vpc-12345678' });
```
The general format is this:
The select interface of `CloudMonkey` has the following format:
```

@@ -109,7 +111,13 @@ select.<quantifier>.<service>.<resourceType>(<filter>)

Quantifier is `one`, `some` or `all`. `one` returns one single object while `all` and `some` always return an array. `one` will throw an error if there is none or multiple objects available. `<service>` must be one of the services registered. `<resourceType>` must be one of the resource types provided by the service (plural, i.e., adding an `s` for nicer reading, is working as well).
`<qualifier>` is `one`, `some` or `all`.
`one` returns one single object while `all` and `some` return an array.
`one` will throw an error if there is none or if there are more than one objects available.
`<service>` must be one of the services registered.
`<resourceType>` must be one of the resource types provided by the service
(plural, i.e., adding an `s` for nicer reading, is supported).
Both cases, an array representing multiple resources or a single object, can be used for further assertions. Use mocha or jasmine or chai or any assertion library.
The returned data (whether it is an array or a single object) provides the meta data of the selected infrastructure element(s).
This can be used to further assertions, e.g., using mocha or jasmine or chai or any other assertion library of your choice.
Both cases are decorated. You can use `dump()` and travel to related resources within the same service.
In addition, it is decorated with `dump()` to simply print out the meta data.

@@ -123,5 +131,9 @@ ```javascript

And it also provides the `travel` interface for traveling to related resources within the same service.
### Travel to other resources
The travel syntax allows to travel from resources (of one resource type) to related resources (of another resource type within the same service). It can be combined with filters. Use `help()` (see above) to learn which travel and filter options are available for a particular resource type.
The travel interface allows to travel from resources (of one resource type) to related resources (of another resource type within the same service).
It also accepts filters, just like the select interface.
Use `help()` (see above) to learn which travel and filter options are available for a particular resource type.

@@ -133,7 +145,8 @@ ```javascript

sn.dump();
// do some assertions here
```
The general format is this:
The travel interface has the following format:
```
travel.to.<quantifier>.<resourceType>(<filter>)
```

@@ -22,2 +22,15 @@ const assert = require('assert');

identity: item => item.InstanceId,
travel: {
subnet: async (instances) => {
const snIds = instances.map(instance => instance.SubnetId);
const sns = await this.loadResources('subnet');
return sns.filter(sn => snIds.includes(sn.SubnetId));
},
securityGroup: async (instances) => {
const sgIds = instances.reduce((acc, instance) =>
[...acc, ...instance.SecurityGroups.map(sg => sg.GroupId)], []);
const sgs = await this.loadResources('securityGroup');
return sgs.filter(sg => sgIds.includes(sg.GroupId));
},
},
});

@@ -76,2 +89,9 @@ this.register({

identity: item => item.SubnetId,
travel: {
instance: async (sns) => {
const snIds = sns.map(sn => sn.SubnetId);
const instances = await this.loadResources('instance');
return instances.filter(instance => snIds.includes(instance.SubnetId));
}
},
});

@@ -78,0 +98,0 @@ }

@@ -10,6 +10,11 @@ const { CloudMonkey, EC2, S3 } = require('./CloudMonkey');

try {
const igw = await monkey.select.one.ec2.internetGateway({ vpc: 'vpc-5a207e32' });
const rt = await igw.travel.to.all.routeTables();
const sn = await rt.travel.to.all.subnets();
const instances = await monkey.select.all.ec2.instances({ vpc: 'vpc-5a207e32' });
// const igw = await monkey.select.one.ec2.internetGateway({ vpc: 'vpc-5a207e32' });
// const rt = await igw.travel.to.all.routeTables();
// const rt = await monkey.select.all.ec2.routeTables();
// const sn = await rt.travel.to.all.subnets();
// const ins = await sn.travel.to.all.instances();
// const sn = await monkey.select.all.ec2.subnet();
// instances[0].dump();
const sn = await instances[0].travel.to.one.securityGroup();
sn.dump();

@@ -16,0 +21,0 @@ } catch (err) {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc