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

terraform-generator

Package Overview
Dependencies
Maintainers
1
Versions
106
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

terraform-generator - npm Package Compare versions

Comparing version 0.6.0 to 0.6.1

11

dist/arguments/Argument.d.ts

@@ -7,6 +7,6 @@ export default class Argument {

*
* @param argument argument as string
* @param arg argument as string
* @param asIs argument will be printed as is, without extra symbol, quotes and whatnot, regardless of Terraform version, default = false.
*/
constructor(argument: string | Argument, asIs?: boolean);
constructor(arg: string | Argument, asIs?: boolean);
/**

@@ -17,1 +17,8 @@ * To Terraform representation.

}
/**
* Convenient function to construct new argument.
*
* @param arg argument as string
* @param asIs argument will be printed as is, without extra symbol, quotes and whatnot, regardless of Terraform version, default = false.
*/
export declare const arg: (arg: string | Argument, asIs?: boolean) => Argument;

15

dist/arguments/Argument.js

@@ -7,10 +7,10 @@ "use strict";

*
* @param argument argument as string
* @param arg argument as string
* @param asIs argument will be printed as is, without extra symbol, quotes and whatnot, regardless of Terraform version, default = false.
*/
constructor(argument, asIs = false) {
if (!argument || (typeof argument === 'string' && !argument.trim())) {
constructor(arg, asIs = false) {
if (!arg || (typeof arg === 'string' && !arg.trim())) {
throw new Error('Argument cannot be empty.');
}
this.argument = typeof argument === 'string' ? argument.trim() : argument;
this.argument = typeof arg === 'string' ? arg.trim() : arg;
this.asIs = asIs;

@@ -33,1 +33,8 @@ }

exports.default = Argument;
/**
* Convenient function to construct new argument.
*
* @param arg argument as string
* @param asIs argument will be printed as is, without extra symbol, quotes and whatnot, regardless of Terraform version, default = false.
*/
exports.arg = (arg, asIs = false) => new Argument(arg, asIs);

@@ -12,1 +12,8 @@ import { Argument, Block } from '..';

}
/**
* Convenient function to construct new block's attribute.
*
* @param block block
* @param name attribute name
*/
export declare const attr: (block: Block, name: string) => Attribute;

@@ -25,1 +25,8 @@ "use strict";

exports.default = Attribute;
/**
* Convenient function to construct new block's attribute.
*
* @param block block
* @param name attribute name
*/
exports.attr = (block, name) => new Attribute(block, name);

@@ -6,7 +6,14 @@ import { Argument } from '..';

*
* @param fnName function name
* @param name function name
* @param args function arguments
*/
constructor(fnName: string, ...args: any[]);
constructor(name: string, ...args: any[]);
private static constructArgument;
}
/**
* Convenient function to construct new function.
*
* @param name function name
* @param args function arguments
*/
export declare const fn: (name: string, ...args: any[]) => Function;

@@ -12,7 +12,7 @@ "use strict";

*
* @param fnName function name
* @param name function name
* @param args function arguments
*/
constructor(fnName, ...args) {
super(Function.constructArgument(fnName, ...args));
constructor(name, ...args) {
super(Function.constructArgument(name, ...args));
}

@@ -38,1 +38,8 @@ static constructArgument(fn, ...args) {

exports.default = Function;
/**
* Convenient function to construct new function.
*
* @param name function name
* @param args function arguments
*/
exports.fn = (name, ...args) => new Function(name, ...args);

@@ -10,1 +10,7 @@ import { Argument } from '..';

}
/**
* Convenient function to construct new heredoc.
*
* @param str string
*/
export declare const heredoc: (str: string) => Heredoc;

@@ -15,1 +15,7 @@ "use strict";

exports.default = Heredoc;
/**
* Convenient function to construct new heredoc.
*
* @param str string
*/
exports.heredoc = (str) => new Heredoc(str);

@@ -0,0 +0,0 @@ import { Block, Argument, Attribute } from '..';

@@ -0,0 +0,0 @@ "use strict";

@@ -55,2 +55,3 @@ import { TerraformVersion, Attribute, Argument } from '..';

* Get block's attribute.
* Same as attr().
*

@@ -60,3 +61,10 @@ * @param name attribute name

abstract getAttribute(name: string): Attribute;
/**
* Get block's attribute.
* Same as getAttribute().
*
* @param name attribute name
*/
attr(name: string): Attribute;
private validateIdentifier;
}

@@ -83,2 +83,11 @@ "use strict";

}
/**
* Get block's attribute.
* Same as getAttribute().
*
* @param name attribute name
*/
attr(name) {
return this.getAttribute(name);
}
validateIdentifier(identifier) {

@@ -85,0 +94,0 @@ if (!identifier.match(/^[a-zA-Z_\-]{1}[0-9a-zA-Z_\-]*$/)) {

@@ -0,0 +0,0 @@ import { Block, Argument, Attribute } from '..';

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { Block, Argument, Attribute } from '..';

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { Block, Argument, Attribute } from '..';

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { Block, Argument, Attribute } from '..';

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { Block, Argument, Attribute } from '..';

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { Block, Argument, Attribute } from '..';

@@ -0,0 +0,0 @@ "use strict";

@@ -12,7 +12,7 @@ import { default as TerraformGenerator } from './TerraformGenerator';

export { default as Backend } from './blocks/Backend';
export { default as Argument } from './arguments/Argument';
export { default as Attribute } from './arguments/Attribute';
export { default as Heredoc } from './arguments/Heredoc';
export { default as Function } from './arguments/Function';
export { default as Map } from './types/Map';
export { default as Argument, arg } from './arguments/Argument';
export { default as Attribute, attr } from './arguments/Attribute';
export { default as Heredoc, heredoc } from './arguments/Heredoc';
export { default as Function, fn } from './arguments/Function';
export { default as Map, map } from './types/Map';
export { default as Utils } from './utils/Utils';

@@ -26,11 +26,16 @@ "use strict";

exports.Argument = Argument_1.default;
exports.arg = Argument_1.arg;
var Attribute_1 = require("./arguments/Attribute");
exports.Attribute = Attribute_1.default;
exports.attr = Attribute_1.attr;
var Heredoc_1 = require("./arguments/Heredoc");
exports.Heredoc = Heredoc_1.default;
exports.heredoc = Heredoc_1.heredoc;
var Function_1 = require("./arguments/Function");
exports.Function = Function_1.default;
exports.fn = Function_1.fn;
var Map_1 = require("./types/Map");
exports.Map = Map_1.default;
exports.map = Map_1.map;
var Utils_1 = require("./utils/Utils");
exports.Utils = Utils_1.default;

@@ -38,3 +38,3 @@ import { Block, Resource, DataSource, Module, Output, Provider, Variable, Backend } from '.';

*/
addProvider(type: string, args: object): Provider;
addProvider(type: string, args?: object): Provider;
/**

@@ -48,3 +48,3 @@ * Add resource into Terraform.

*/
addResource(type: string, name: string, args: object): Resource;
addResource(type: string, name: string, args?: object): Resource;
/**

@@ -58,3 +58,3 @@ * Add data source into Terraform.

*/
addDataSource(type: string, name: string, args: object): DataSource;
addDataSource(type: string, name: string, args?: object): DataSource;
/**

@@ -67,3 +67,3 @@ * Add module into Terraform.

*/
addModule(name: string, args: object): Module;
addModule(name: string, args?: object): Module;
/**

@@ -76,3 +76,3 @@ * Add output into Terraform.

*/
addOutput(name: string, args: object): Output;
addOutput(name: string, args?: object): Output;
/**

@@ -85,3 +85,3 @@ * Add provider into Terraform.

*/
addVariable(name: string, args: object): Variable;
addVariable(name: string, args?: object): Variable;
/**

@@ -94,3 +94,3 @@ * Add backend into Terraform.

*/
addBackend(type: string, args: object): Backend;
addBackend(type: string, args?: object): Backend;
}

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { TerraformVersion } from '.';

@@ -0,0 +0,0 @@ "use strict";

@@ -6,5 +6,11 @@ export default class Map {

*
* @param args values
* @param args map values
*/
constructor(args: object);
}
/**
* Convenient function to construct new map.
*
* @param args map values
*/
export declare const map: (args: object) => Map;

@@ -7,3 +7,3 @@ "use strict";

*
* @param args values
* @param args map values
*/

@@ -15,1 +15,7 @@ constructor(args) {

exports.default = Map;
/**
* Convenient function to construct new map.
*
* @param args map values
*/
exports.map = (args) => new Map(args);

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ "use strict";

{
"name": "terraform-generator",
"version": "0.6.0",
"version": "0.6.1",
"author": "Ah Zhe",

@@ -5,0 +5,0 @@ "description": "Generate Terraform plan using Node.js.",

@@ -44,3 +44,3 @@ # **terraform-generator**

```javascript
import TerraformGenerator, { Resource, Map, Argument, Utils } from 'terraform-generator';
import TerraformGenerator, { Resource, map, arg, Utils } from 'terraform-generator';
```

@@ -92,3 +92,3 @@

],
map: new Map({
map: map({
arg1: 'str',

@@ -99,10 +99,10 @@ arg2: 123,

block: block,
blockAttribute: block.getAttribute('attrName'),
heredoc: new Heredoc(`line1
blockAttribute: block.attr('attrName'),
heredoc: heredoc(`line1
line2
line3`),
function1: new Function('max', 5, 12, 19),
function2: new Function('sort', 'a', block.getAttribute('attrName'), 'c'),
custom1: new Argument('max(5, 12, 9)'),
custom2: new Argument('as is', true) // it will be printed as is, without extra symbol, quotes and whatnot, regardless of Terraform version
function1: fn('max', 5, 12, 19),
function2: fn('sort', 'a', block.attr('attrName'), 'c'),
custom1: arg('max(5, 12, 9)'),
custom2: arg('as is', true) // it will be printed as is, without extra symbol, quotes and whatnot, regardless of Terraform version
}

@@ -113,6 +113,6 @@ ```

```javascript
block.getAttribute('id') // block id, string
block.getAttribute('subnets') // subnet objects, object list
block.getAttribute('subnets.*.id') // subnet ids, string list
block.getAttribute('subnets.*.id[0]') // first subnet id, string
block.attr('id') // block id, string
block.attr('subnets') // subnet objects, object list
block.attr('subnets.*.id') // subnet ids, string list
block.attr('subnets.*.id[0]') // first subnet id, string
```

@@ -135,4 +135,3 @@

```javascript
import TerraformGenerator, { Map, Utils } from 'terraform-generator';
import fs from 'fs';
import TerraformGenerator, { Map, map, Utils } from 'terraform-generator';
import path from 'path';

@@ -213,3 +212,3 @@

const subnet = tfg.addResource('aws_subnet', `subnet_${name}`, {
vpc_id: vpc.getAttribute('id'),
vpc_id: vpc.attr('id'),
cidr_block: cidr,

@@ -225,6 +224,6 @@ availability_zone: getAvailabilityZone(i),

tfg.addOutput('subnets', {
value: new Map({
webSubnets: subnets.web.map(subnet => subnet.getAttribute('id')),
appSubnets: subnets.app.map(subnet => subnet.getAttribute('id')),
dbSubnets: subnets.db.map(subnet => subnet.getAttribute('id'))
value: map({
webSubnets: subnets.web.map(subnet => subnet.attr('id')),
appSubnets: subnets.app.map(subnet => subnet.attr('id')),
dbSubnets: subnets.db.map(subnet => subnet.attr('id'))
})

@@ -231,0 +230,0 @@ });

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