diff --git a/.eslintrc.json b/.eslintrc.json index 504a252..1669083 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -55,7 +55,8 @@ "selector": "variableLike", "format": [ "strictCamelCase", - "UPPER_CASE" + "UPPER_CASE", + "snake_case" ], "leadingUnderscore": "allow" }, @@ -63,7 +64,8 @@ "selector": "memberLike", "format": [ "strictCamelCase", - "UPPER_CASE" + "UPPER_CASE", + "snake_case" ] }, { diff --git a/src/TerraformGenerator.ts b/src/TerraformGenerator.ts index e81b35a..e49bff6 100644 --- a/src/TerraformGenerator.ts +++ b/src/TerraformGenerator.ts @@ -2,8 +2,8 @@ import child_process from 'child_process'; import fs from 'fs'; import path from 'path'; import shell from 'shelljs'; -import { Block, Comment, Resource, Data, Module, Output, Provider, Variable, Backend, Provisioner, ResourceToDataOptions, Locals, Import } from './blocks'; -import { Util } from './Util'; +import { Block, Comment, Resource, Data, Module, Output, Provider, Variable, Backend, Provisioner, ResourceToDataOptions, Locals, Import, ImportArgs, VariableArgs, ModuleArgs, OutputArgs } from './blocks'; +import { BlockArgs, Util } from './utils'; /** * @category TerraformGenerator @@ -42,9 +42,9 @@ export interface WriteOptions { */ export class TerraformGenerator { - readonly #arguments?: Record; + readonly #arguments?: BlockArgs; readonly #blocks: Block[] = []; - #variables: Record = {}; + #variables: BlockArgs = {}; /** * Construct Terraform generator. @@ -53,7 +53,7 @@ export class TerraformGenerator { * * @param args arguments */ - constructor(args?: Record) { + constructor(args?: BlockArgs) { this.#arguments = args; } @@ -170,7 +170,7 @@ export class TerraformGenerator { * @param type type * @param args arguments */ - provider(type: string, args?: Record): Provider { + provider(type: string, args: BlockArgs): Provider { const block = new Provider(type, args); this.addBlocks(block); return block; @@ -186,7 +186,7 @@ export class TerraformGenerator { * @param args arguments * @param provisioners provisioners */ - resource(type: string, name: string, args?: Record, provisioners?: Provisioner[]): Resource { + resource(type: string, name: string, args: BlockArgs, provisioners?: Provisioner[]): Resource { const block = new Resource(type, name, args, provisioners); this.addBlocks(block); return block; @@ -201,8 +201,7 @@ export class TerraformGenerator { * use array for name mapping, position 0 = original resource's argument name, position 1 = mapped data source's argument name * @param args extra arguments */ - dataFromResource(resource: Resource, options: ResourceToDataOptions | undefined, argNames: (string | [string, string])[], - args?: Record): Data { + dataFromResource(resource: Resource, options: ResourceToDataOptions | undefined, argNames: (string | [string, string])[], args?: BlockArgs): Data { const block = resource.toData(options, argNames, args); this.addBlocks(block); return block; @@ -217,7 +216,7 @@ export class TerraformGenerator { * @param name name * @param args arguments */ - data(type: string, name: string, args?: Record): Data { + data(type: string, name: string, args: BlockArgs): Data { const block = new Data(type, name, args); this.addBlocks(block); return block; @@ -231,7 +230,7 @@ export class TerraformGenerator { * @param name name * @param args arguments */ - module(name: string, args?: Record): Module { + module(name: string, args: ModuleArgs): Module { const block = new Module(name, args); this.addBlocks(block); return block; @@ -245,7 +244,7 @@ export class TerraformGenerator { * @param name name * @param args arguments */ - output(name: string, args?: Record): Output { + output(name: string, args: OutputArgs): Output { const block = new Output(name, args); this.addBlocks(block); return block; @@ -258,7 +257,7 @@ export class TerraformGenerator { * * @param args arguments */ - locals(args?: Record): Locals { + locals(args: BlockArgs): Locals { const block = new Locals(args); this.addBlocks(block); return block; @@ -273,7 +272,7 @@ export class TerraformGenerator { * @param args arguments * @param value variable value */ - variable(name: string, args?: Record, value?: any): Variable { + variable(name: string, args: VariableArgs, value?: any): Variable { const block = new Variable(name, args); this.addBlocks(block); if (value != null) { @@ -283,42 +282,28 @@ export class TerraformGenerator { } /** - * Add backend into Terraform. + * Add import into Terraform. * - * Refer to Terraform documentation on what can be put as type & arguments. + * Refer to Terraform documentation on what can be put as arguments. * - * @param type type * @param args arguments */ - backend(type: string, args?: Record): Backend { - const block = new Backend(type, args); + import(args: ImportArgs): Import { + const block = new Import(args); this.addBlocks(block); return block; } /** - * Add provisioner into Terraform. + * Add backend into Terraform. * * Refer to Terraform documentation on what can be put as type & arguments. * * @param type type * @param args arguments */ - provisioner(type: string, args?: Record): Provisioner { - const block = new Provisioner(type, args); - this.addBlocks(block); - return block; - } - - /** - * Add import into Terraform. - * - * Refer to Terraform documentation on what can be put as arguments. - * - * @param args arguments - */ - import(args?: Record): Import { - const block = new Import(args); + backend(type: string, args: BlockArgs): Backend { + const block = new Backend(type, args); this.addBlocks(block); return block; } @@ -328,7 +313,7 @@ export class TerraformGenerator { * * @param variables variables */ - addVars(variables: Record): this { + addVars(variables: BlockArgs): this { this.#variables = { ...this.#variables, ...variables @@ -352,7 +337,7 @@ export class TerraformGenerator { /** * Get arguments. */ - getArguments(): Record | undefined { + getArguments(): BlockArgs | undefined { return this.#arguments; } @@ -366,7 +351,7 @@ export class TerraformGenerator { /** * Get variables. */ - getVars(): Record { + getVars(): BlockArgs { return this.#variables; } diff --git a/src/arguments/Argument.ts b/src/arguments/Argument.ts index 9f913f3..6239c57 100644 --- a/src/arguments/Argument.ts +++ b/src/arguments/Argument.ts @@ -1,18 +1,18 @@ -import { Util } from '../Util'; +import { Util } from '../utils'; /** * @category Argument */ -export class Argument { +export class Argument> { - readonly argument: string | Argument; + readonly argument: T; /** * Construct argument. * * @param arg argument as string or copy from another argument object */ - constructor(arg: string | Argument) { + constructor(arg: T) { if (!arg || (typeof arg === 'string' && !arg.trim())) { throw new Error('Argument cannot be empty.'); } @@ -80,4 +80,4 @@ export class Argument { * * @category Argument */ -export const arg = (arg: string | Argument): Argument => new Argument(arg); +export const arg = >(arg: T): Argument => new Argument(arg); diff --git a/src/arguments/Function.ts b/src/arguments/Function.ts index e8e9eda..528c691 100644 --- a/src/arguments/Function.ts +++ b/src/arguments/Function.ts @@ -1,4 +1,4 @@ -import { Util } from '../Util'; +import { Util } from '../utils'; import { Argument } from '.'; /** diff --git a/src/blocks/Backend.ts b/src/blocks/Backend.ts index 745d68a..22392b8 100644 --- a/src/blocks/Backend.ts +++ b/src/blocks/Backend.ts @@ -1,4 +1,5 @@ import { Argument, Attribute } from '../arguments'; +import { BlockArgs } from '../utils'; import { Block } from '.'; /** @@ -16,7 +17,7 @@ export class Backend extends Block { * @param type type * @param args arguments */ - constructor(type: string, args?: Record) { + constructor(type: string, args: BlockArgs) { super('backend', [type], args, undefined, true); this.type = type; diff --git a/src/blocks/Block.ts b/src/blocks/Block.ts index f6c0616..c92cdd9 100644 --- a/src/blocks/Block.ts +++ b/src/blocks/Block.ts @@ -1,14 +1,14 @@ import { Argument, Attribute } from '../arguments'; -import { Util } from '../Util'; +import { BlockArgs, Util } from '../utils'; /** * @category Block */ -export abstract class Block { +export abstract class Block { readonly blockType: string; readonly blockNames: string[]; - readonly #arguments: Record; + #arguments: Args; #innerBlocks: Block[]; readonly #insideTerraformBlock: boolean; @@ -19,7 +19,7 @@ export abstract class Block { * @param names names * @param args arguments */ - constructor(type: string, names: string[], args?: Record, innerBlocks?: Block[], insideTerraformBlock = false) { + constructor(type: string, names: string[], args: Args, innerBlocks?: Block[], insideTerraformBlock = false) { this.#validateIdentifier(type); names.forEach(name => { this.#validateIdentifier(name); @@ -27,7 +27,7 @@ export abstract class Block { this.blockType = type; this.blockNames = names; - this.#arguments = args ? args : {}; + this.#arguments = args; this.#innerBlocks = innerBlocks ? innerBlocks : []; this.#insideTerraformBlock = insideTerraformBlock; } @@ -42,7 +42,7 @@ export abstract class Block { /** * Get arguments. */ - getArguments(): Record { + getArguments(): Args { return this.#arguments; } @@ -51,7 +51,7 @@ export abstract class Block { * * @param key key */ - getArgument(key: string): any { + getArgument(key: K): Args[K] { return this.#arguments[key]; } @@ -61,7 +61,7 @@ export abstract class Block { * @param key key * @param value value */ - setArgument(key: string, value: any): this { + setArgument(key: K, value: Args[K]): this { this.#arguments[key] = value; return this; } @@ -71,10 +71,11 @@ export abstract class Block { * * @param args arguments */ - setArguments(args: Record): this { - for (const key in args) { - this.#arguments[key] = args[key]; - } + setArguments(args: Partial): this { + this.#arguments = { + ...this.#arguments, + ...args + }; return this; } diff --git a/src/blocks/Comment.ts b/src/blocks/Comment.ts index 2c4fc79..5174d30 100644 --- a/src/blocks/Comment.ts +++ b/src/blocks/Comment.ts @@ -4,7 +4,7 @@ import { Block } from '.'; /** * @category Block */ -export class Comment extends Block { +export class Comment extends Block> { readonly comment: string; @@ -14,7 +14,7 @@ export class Comment extends Block { * @param comment comment */ constructor(comment: string) { - super('comment', []); + super('comment', [], {}); this.comment = comment; } diff --git a/src/blocks/Data.ts b/src/blocks/Data.ts index b21b85e..7e4d041 100644 --- a/src/blocks/Data.ts +++ b/src/blocks/Data.ts @@ -1,4 +1,5 @@ import { Argument, Attribute } from '../arguments'; +import { BlockArgs } from '../utils'; import { Block } from '.'; /** @@ -18,7 +19,7 @@ export class Data extends Block { * @param name name * @param args arguments */ - constructor(type: string, name: string, args?: Record) { + constructor(type: string, name: string, args: BlockArgs) { super('data', [type, name], args); this.type = type; diff --git a/src/blocks/Import.ts b/src/blocks/Import.ts index d1d518e..06ddfa8 100644 --- a/src/blocks/Import.ts +++ b/src/blocks/Import.ts @@ -1,10 +1,19 @@ import { Argument, Attribute } from '../arguments'; -import { Block } from '.'; +import { Block, Resource } from '.'; /** * @category Block */ -export class Import extends Block { +export interface ImportArgs { + to: Resource; + id: string; + provider?: Argument; +} + +/** + * @category Block + */ +export class Import extends Block { /** * Construct import. @@ -13,7 +22,7 @@ export class Import extends Block { * * @param args arguments */ - constructor(args?: Record) { + constructor(args: ImportArgs) { super('import', [], args); } diff --git a/src/blocks/Locals.ts b/src/blocks/Locals.ts index 61c6f4a..94750ef 100644 --- a/src/blocks/Locals.ts +++ b/src/blocks/Locals.ts @@ -1,4 +1,5 @@ import { Argument, Attribute } from '../arguments'; +import { BlockArgs } from '../utils'; import { Block } from '.'; /** @@ -13,7 +14,7 @@ export class Locals extends Block { * * @param args arguments */ - constructor(args?: Record) { + constructor(args: BlockArgs) { super('locals', [], args); } diff --git a/src/blocks/Module.ts b/src/blocks/Module.ts index d9273f7..a0fde91 100644 --- a/src/blocks/Module.ts +++ b/src/blocks/Module.ts @@ -1,10 +1,19 @@ import { Argument, Attribute } from '../arguments'; +import { BlockArgs } from '../utils'; import { Block } from '.'; /** * @category Block */ -export class Module extends Block { +export interface ModuleArgs extends BlockArgs { + source: string; + version?: string; +} + +/** + * @category Block + */ +export class Module extends Block { readonly name: string; @@ -16,7 +25,7 @@ export class Module extends Block { * @param name name * @param args arguments */ - constructor(name: string, args?: Record) { + constructor(name: string, args: ModuleArgs) { super('module', [name], args); this.name = name; diff --git a/src/blocks/Output.ts b/src/blocks/Output.ts index 9a139be..a0f9a61 100644 --- a/src/blocks/Output.ts +++ b/src/blocks/Output.ts @@ -1,10 +1,22 @@ import { Argument, Attribute } from '../arguments'; -import { Block } from '.'; +import { BlockArgs } from '../utils'; +import { Block, Resource } from '.'; /** * @category Block */ -export class Output extends Block { +export interface OutputArgs { + value: any; + description?: string; + sensitive?: boolean; + precondition?: BlockArgs; + depends_on?: Resource[]; +} + +/** + * @category Block + */ +export class Output extends Block { readonly name: string; @@ -16,7 +28,7 @@ export class Output extends Block { * @param name name * @param args arguments */ - constructor(name: string, args?: Record) { + constructor(name: string, args: OutputArgs) { super('output', [name], args); this.name = name; diff --git a/src/blocks/Provider.ts b/src/blocks/Provider.ts index 9a2fa8a..7869469 100644 --- a/src/blocks/Provider.ts +++ b/src/blocks/Provider.ts @@ -1,4 +1,5 @@ import { Argument, Attribute } from '../arguments'; +import { BlockArgs } from '../utils'; import { Block } from '.'; /** @@ -16,7 +17,7 @@ export class Provider extends Block { * @param type type * @param args arguments */ - constructor(type: string, args?: Record) { + constructor(type: string, args: BlockArgs) { super('provider', [type], args); this.type = type; diff --git a/src/blocks/Provisioner.ts b/src/blocks/Provisioner.ts index 119e7f0..c6ac669 100644 --- a/src/blocks/Provisioner.ts +++ b/src/blocks/Provisioner.ts @@ -4,9 +4,23 @@ import { Block } from '.'; /** * @category Block */ -export class Provisioner extends Block { +export type ProvisionerType = 'local-exec' | 'remote-exec'; - readonly type: string; +/** + * @category Block + */ +export interface ProvisionerArgs { + command: string; + when?: Argument<'destroy'>; + on_failure?: Argument<'continue' | 'fail'>; +} + +/** + * @category Block + */ +export class Provisioner extends Block { + + readonly type: ProvisionerType; /** * Construct provisioner. @@ -16,7 +30,7 @@ export class Provisioner extends Block { * @param type type * @param args arguments */ - constructor(type: string, args?: Record) { + constructor(type: ProvisionerType, args: ProvisionerArgs) { super('provisioner', [type], args); this.type = type; diff --git a/src/blocks/Resource.ts b/src/blocks/Resource.ts index 0cba799..daf81dd 100644 --- a/src/blocks/Resource.ts +++ b/src/blocks/Resource.ts @@ -1,5 +1,6 @@ import { Argument, Attribute } from '../arguments'; import { Map } from '../types'; +import { BlockArgs } from '../utils'; import { Block, Data, Provisioner } from '.'; /** @@ -34,8 +35,8 @@ export class Resource extends Block { * @param args arguments * @param provisioners provisioners */ - constructor(type: string, name: string, args?: Record, provisioners?: Provisioner[]) { - super('resource', [type, name], args, provisioners); + constructor(type: string, name: string, args?: BlockArgs, provisioners?: Provisioner[]) { + super('resource', [type, name], args || {}, provisioners); this.type = type; this.name = name; @@ -74,7 +75,7 @@ export class Resource extends Block { * use array for name mapping, position 0 = original resource's argument name, position 1 = mapped data source's argument name * @param args extra arguments */ - toData(options: ResourceToDataOptions | undefined, argNames: (string | [string, string])[], args?: Record): Data { + toData(options: ResourceToDataOptions | undefined, argNames: (string | [string, string])[], args?: BlockArgs): Data { const type = options?.type ?? this.type; const name = options?.name ?? this.name; diff --git a/src/blocks/Variable.ts b/src/blocks/Variable.ts index 0c463b7..ea9f391 100644 --- a/src/blocks/Variable.ts +++ b/src/blocks/Variable.ts @@ -1,10 +1,23 @@ import { Argument, Attribute } from '../arguments'; +import { BlockArgs } from '../utils'; import { Block } from '.'; /** * @category Block */ -export class Variable extends Block { +export interface VariableArgs { + type: Argument; + default?: any; + description?: string; + sensitive?: boolean; + nullable?: boolean; + validation?: BlockArgs; +} + +/** + * @category Block + */ +export class Variable extends Block { readonly name: string; @@ -16,7 +29,7 @@ export class Variable extends Block { * @param name name * @param args arguments */ - constructor(name: string, args?: Record) { + constructor(name: string, args: VariableArgs) { super('variable', [name], args); this.name = name; diff --git a/src/index.ts b/src/index.ts index 3877cc5..8ce696c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,7 +1,30 @@ +export { BlockArgs } from './utils'; + export { TerraformGenerator, WriteOptions } from './TerraformGenerator'; -export { Block, Backend, Comment, Data, Import, Locals, Module, Output, Provider, Provisioner, Resource, ResourceToDataOptions, Variable } from './blocks'; +export { + Block, + Backend, + Comment, + Data, + Import, ImportArgs, + Locals, + Module, ModuleArgs, + Output, OutputArgs, + Provider, + Provisioner, ProvisionerArgs, ProvisionerType, + Resource, ResourceToDataOptions, + Variable, VariableArgs +} from './blocks'; -export { Argument, arg, Attribute, attr, Function, fn, Heredoc, heredoc } from './arguments'; +export { + Argument, arg, + Attribute, attr, + Function, fn, + Heredoc, heredoc +} from './arguments'; -export { List, list, Map, map } from './types'; +export { + List, list, + Map, map +} from './types'; diff --git a/src/types/Map.ts b/src/types/Map.ts index 737de32..7103d7b 100644 --- a/src/types/Map.ts +++ b/src/types/Map.ts @@ -1,16 +1,18 @@ +import { BlockArgs } from '../utils'; + /** * @category Type */ export class Map { - readonly arguments: Record; + readonly arguments: BlockArgs; /** * Construct map. * * @param args map values */ - constructor(args: Record) { + constructor(args: BlockArgs) { this.arguments = args; } @@ -23,4 +25,4 @@ export class Map { * * @category Type */ -export const map = (args: Record): Map => new Map(args); +export const map = (args: BlockArgs): Map => new Map(args); diff --git a/src/Util.ts b/src/utils/Util.ts similarity index 94% rename from src/Util.ts rename to src/utils/Util.ts index f5128bd..be25161 100644 --- a/src/Util.ts +++ b/src/utils/Util.ts @@ -1,6 +1,7 @@ -import { Argument } from './arguments'; -import { Block } from './blocks'; -import { Map, List } from './types'; +import { Argument } from '../arguments'; +import { Block } from '../blocks'; +import { Map, List } from '../types'; +import { BlockArgs } from '.'; export class Util { @@ -22,7 +23,7 @@ export class Util { return str; } - static argumentsToString(args?: Record): string { + static argumentsToString(args?: BlockArgs): string { let str = ''; for (const key in args) { str += this.argumentToString(key, args[key]); diff --git a/src/utils/index.ts b/src/utils/index.ts new file mode 100644 index 0000000..e9770d8 --- /dev/null +++ b/src/utils/index.ts @@ -0,0 +1,2 @@ +export * from './types'; +export * from './Util'; diff --git a/src/utils/types.ts b/src/utils/types.ts new file mode 100644 index 0000000..669fcce --- /dev/null +++ b/src/utils/types.ts @@ -0,0 +1 @@ +export type BlockArgs = Record; diff --git a/test/arguments/Argument.test.ts b/test/arguments/Argument.test.ts index 3825d28..5465964 100644 --- a/test/arguments/Argument.test.ts +++ b/test/arguments/Argument.test.ts @@ -1,6 +1,6 @@ import { attr } from '..'; import { Argument, arg } from '../../src/arguments'; -import { Util } from '../../src/Util'; +import { Util } from '../../src/utils'; test('Argument invalid args', () => { expect(() => new Argument(null as unknown as string)).toThrow(); diff --git a/test/arguments/Attribute.test.ts b/test/arguments/Attribute.test.ts index 1022b5f..0931f14 100644 --- a/test/arguments/Attribute.test.ts +++ b/test/arguments/Attribute.test.ts @@ -1,7 +1,7 @@ import { resource } from '..'; import { Attribute, attr } from '../../src/arguments'; import { Block } from '../../src/blocks'; -import { Util } from '../../src/Util'; +import { Util } from '../../src/utils'; test('Attribute invalid args', () => { expect(() => new Attribute(null as unknown as Block, null as unknown as string)).toThrow(); diff --git a/test/arguments/Function.test.ts b/test/arguments/Function.test.ts index 239de44..3b2e968 100644 --- a/test/arguments/Function.test.ts +++ b/test/arguments/Function.test.ts @@ -1,6 +1,6 @@ import { attr } from '..'; import { Function, fn } from '../../src/arguments'; -import { Util } from '../../src/Util'; +import { Util } from '../../src/utils'; test('Function invalid args', () => { expect(() => new Function(null as unknown as string)).toThrow(); diff --git a/test/arguments/Heredoc.test.ts b/test/arguments/Heredoc.test.ts index e824143..fb80492 100644 --- a/test/arguments/Heredoc.test.ts +++ b/test/arguments/Heredoc.test.ts @@ -1,5 +1,5 @@ import { Heredoc, heredoc } from '../../src/arguments'; -import { Util } from '../../src/Util'; +import { Util } from '../../src/utils'; test('Heredoc', () => { expect(new Heredoc('x').toTerraform()).toBe(Util.escape(`< { const backend = new Backend('name', arg4); diff --git a/test/blocks/Block.test.ts b/test/blocks/Block.test.ts index 4b009dc..2b1ae23 100644 --- a/test/blocks/Block.test.ts +++ b/test/blocks/Block.test.ts @@ -1,9 +1,10 @@ +import { Argument } from '../../src/arguments'; import { Resource, Provisioner, Output } from '../../src/blocks'; test('Block identifier', () => { expect(() => new Resource('!@#', '$%^')).toThrow(); expect(() => new Resource('', ' ')).toThrow(); - expect(() => new Output(null as unknown as string)).toThrow(); + expect(() => new Output(null as unknown as string, { value: 'value' })).toThrow(); }); test('Block arguments', () => { @@ -17,8 +18,14 @@ test('Block arguments', () => { }).getArguments()).toMatchSnapshot(); expect(resource.deleteArgument('b').getArguments()).toMatchSnapshot(); expect(resource.setProvisioners([ - new Provisioner('p1', { a: 0 }), - new Provisioner('p2', { b: 1 }) + new Provisioner('local-exec', { + command: 'cmd1' + }), + new Provisioner('remote-exec', { + command: 'cmd2', + when: new Argument('destroy'), + on_failure: new Argument('fail') + }) ]).getProvisioners()).toMatchSnapshot(); expect(resource.setProvisioners(undefined).getProvisioners()).toMatchSnapshot(); }); diff --git a/test/blocks/Data.test.ts b/test/blocks/Data.test.ts index f0f567b..4fc9f32 100644 --- a/test/blocks/Data.test.ts +++ b/test/blocks/Data.test.ts @@ -1,6 +1,6 @@ import { arg4 } from '..'; import { Data } from '../../src/blocks'; -import { Util } from '../../src/Util'; +import { Util } from '../../src/utils'; test('Data', () => { const data = new Data('type', 'name', arg4); diff --git a/test/blocks/Import.test.ts b/test/blocks/Import.test.ts index e06857c..187fbf8 100644 --- a/test/blocks/Import.test.ts +++ b/test/blocks/Import.test.ts @@ -1,8 +1,15 @@ import { arg4 } from '..'; -import { Import } from '../../src/blocks'; +import { Argument } from '../../src/arguments'; +import { Import, Resource } from '../../src/blocks'; + +const resource = new Resource('type', 'name', arg4); test('Import', () => { - const imp = new Import(arg4); + const imp = new Import({ + to: resource, + id: 'id', + provider: new Argument('arg') + }); expect(imp.toTerraform()).toMatchSnapshot(); expect(() => imp.asArgument()).toThrow(); expect(() => imp.attr('attr')).toThrow(); diff --git a/test/blocks/Locals.test.ts b/test/blocks/Locals.test.ts index a81346f..7850b95 100644 --- a/test/blocks/Locals.test.ts +++ b/test/blocks/Locals.test.ts @@ -1,6 +1,6 @@ import { arg4 } from '..'; import { Locals } from '../../src/blocks'; -import { Util } from '../../src/Util'; +import { Util } from '../../src/utils'; test('Locals', () => { const locals = new Locals(arg4); diff --git a/test/blocks/Module.test.ts b/test/blocks/Module.test.ts index cd244b1..70f9054 100644 --- a/test/blocks/Module.test.ts +++ b/test/blocks/Module.test.ts @@ -1,9 +1,13 @@ import { arg4 } from '..'; import { Module } from '../../src/blocks'; -import { Util } from '../../src/Util'; +import { Util } from '../../src/utils'; test('Module', () => { - const module = new Module('name', arg4); + const module = new Module('name', { + source: 'source', + version: '1', + ...arg4 + }); expect(module.toTerraform()).toMatchSnapshot(); expect(module.asArgument().toTerraform()).toBe(Util.escape('module.name')); expect(module.attr('attr').toTerraform()).toBe(Util.escape('module.name.attr')); diff --git a/test/blocks/Output.test.ts b/test/blocks/Output.test.ts index b791c27..10022dc 100644 --- a/test/blocks/Output.test.ts +++ b/test/blocks/Output.test.ts @@ -1,8 +1,7 @@ -import { arg4 } from '..'; import { Output } from '../../src/blocks'; test('Output', () => { - const output = new Output('name', arg4); + const output = new Output('name', { value: 'value' }); expect(output.toTerraform()).toMatchSnapshot(); expect(() => output.asArgument()).toThrow(); expect(() => output.attr('attr')).toThrow(); diff --git a/test/blocks/Provider.test.ts b/test/blocks/Provider.test.ts index 41a8e44..7c5f8c2 100644 --- a/test/blocks/Provider.test.ts +++ b/test/blocks/Provider.test.ts @@ -1,6 +1,6 @@ import { arg4 } from '..'; import { Provider } from '../../src/blocks'; -import { Util } from '../../src/Util'; +import { Util } from '../../src/utils'; test('Provider', () => { const provider = new Provider('name', arg4); diff --git a/test/blocks/Provisioner.test.ts b/test/blocks/Provisioner.test.ts index 96bf24d..907db55 100644 --- a/test/blocks/Provisioner.test.ts +++ b/test/blocks/Provisioner.test.ts @@ -1,8 +1,12 @@ -import { arg4 } from '..'; +import { Argument } from '../../src/arguments'; import { Provisioner } from '../../src/blocks'; test('Provisioner', () => { - const provisioner = new Provisioner('name', arg4); + const provisioner = new Provisioner('local-exec', { + command: 'cmd', + when: new Argument('destroy'), + on_failure: new Argument('fail') + }); expect(provisioner.toTerraform()).toMatchSnapshot(); expect(() => provisioner.asArgument()).toThrow(); expect(() => provisioner.attr('attr')).toThrow(); diff --git a/test/blocks/Resource.test.ts b/test/blocks/Resource.test.ts index 1aebeb5..2217f7f 100644 --- a/test/blocks/Resource.test.ts +++ b/test/blocks/Resource.test.ts @@ -1,7 +1,7 @@ import { arg4 } from '..'; import { Resource } from '../../src/blocks'; import { map } from '../../src/types'; -import { Util } from '../../src/Util'; +import { Util } from '../../src/utils'; test('Resource', () => { const resource = new Resource('type', 'name', arg4); diff --git a/test/blocks/Variable.test.ts b/test/blocks/Variable.test.ts index 60df311..7bd7dfc 100644 --- a/test/blocks/Variable.test.ts +++ b/test/blocks/Variable.test.ts @@ -1,9 +1,12 @@ -import { arg4 } from '..'; +import { Argument } from '../../src/arguments'; import { Variable } from '../../src/blocks'; -import { Util } from '../../src/Util'; +import { Util } from '../../src/utils'; test('Variable', () => { - const variable = new Variable('name', arg4); + const variable = new Variable('name', { + type: new Argument('string'), + default: 'value' + }); expect(variable.toTerraform()).toMatchSnapshot(); expect(variable.asArgument().toTerraform()).toBe(Util.escape('var.name')); expect(variable.attr('attr').toTerraform()).toBe(Util.escape('var.name.attr')); diff --git a/test/blocks/__snapshots__/Block.test.ts.snap b/test/blocks/__snapshots__/Block.test.ts.snap index dc4d602..065d74a 100644 --- a/test/blocks/__snapshots__/Block.test.ts.snap +++ b/test/blocks/__snapshots__/Block.test.ts.snap @@ -27,17 +27,17 @@ exports[`Block arguments 5`] = ` [ Provisioner { "blockNames": [ - "p1", + "local-exec", ], "blockType": "provisioner", - "type": "p1", + "type": "local-exec", }, Provisioner { "blockNames": [ - "p2", + "remote-exec", ], "blockType": "provisioner", - "type": "p2", + "type": "remote-exec", }, ] `; diff --git a/test/blocks/__snapshots__/Import.test.ts.snap b/test/blocks/__snapshots__/Import.test.ts.snap index 8a491d1..83dd6b7 100644 --- a/test/blocks/__snapshots__/Import.test.ts.snap +++ b/test/blocks/__snapshots__/Import.test.ts.snap @@ -2,1886 +2,9 @@ exports[`Import 1`] = ` "import{ -arg0 = &tfgquot;a&tfgquot; -arg1 = [ -&tfgquot;b&tfgquot;, -&tfgquot;c&tfgquot;, -&tfgquot;d&tfgquot; -] -arg2 = 0 -arg3 = [ -1, -2, -3 -] -arg4 = true -arg5 = [ -false, -true, -false -] -arg6 = type.name.attr -arg7 = [ -type.name.attr, -type.name.attr, -type.name.attr -] -arg8 = type.name -arg9 = [ -type.name, -type.name, -type.name -] -arg10 = [ -&tfgquot;e&tfgquot;, -4, -true, -type.name.attr, -type.name -] -arg11 = arg -arg12 = type.name.attr -arg13 = < `${type}-${project}-${configs.env}${tier ? `-${tier}` : ''}${name ? `-${name}` : ''}`; const getTags = (type: string, name?: string, tier?: string): Map => new Map({ - Name: getTagName(type, name, tier), - Project: project, - Env: configs.env + name: getTagName(type, name, tier), + project, + env: configs.env }); const createTerraformGenerator = (): TerraformGenerator => { @@ -165,7 +164,7 @@ const createTerraformGenerator = (): TerraformGenerator => { }); // NetworkACL - const defaultNACLRules = [ + const defaultNaclRules = [ { protocol: 'all', rule_no: 100, @@ -176,7 +175,7 @@ const createTerraformGenerator = (): TerraformGenerator => { } ]; - const dbNACLRules = [ + const dbNaclRules = [ { protocol: 'all', rule_no: 100, @@ -198,16 +197,16 @@ const createTerraformGenerator = (): TerraformGenerator => { tfg.resource('aws_network_acl', 'default', { vpc_id: vpc.id, subnet_ids: publicSubnets.concat(webSubnets, appSubnets, gutSubnets, itSubnets, mgtSubnets).map(subnet => subnet.id), - ingress: defaultNACLRules, - egress: defaultNACLRules, + ingress: defaultNaclRules, + egress: defaultNaclRules, tags: getTags('nacl', 'default') }); tfg.resource('aws_network_acl', 'db', { vpc_id: vpc.id, subnet_ids: dbSubnets.map(subnet => subnet.id), - ingress: dbNACLRules, - egress: dbNACLRules, + ingress: dbNaclRules, + egress: dbNaclRules, tags: getTags('nacl', 'db') }); diff --git a/test/tfg/Others.test.ts b/test/tfg/Others.test.ts index fb38c40..8d9ea45 100644 --- a/test/tfg/Others.test.ts +++ b/test/tfg/Others.test.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/naming-convention */ import fs from 'fs'; import path from 'path'; import { arg } from '../../src/arguments'; @@ -35,7 +34,7 @@ const createTerraformGenerator = (): TerraformGenerator => { tfg.dataFromResource(r, undefined, ['cidr_block', ['tags', 'tag']]); tfg.dataFromResource(r, { name: 'test2' }, ['cidr_block', ['tags', 'tag']]); - tfg.resource('innerBlock', 'innerBlock', { + const resource = tfg.resource('innerBlock', 'innerBlock', { a: 'a' }, [ new Provisioner('local-exec', { @@ -55,22 +54,16 @@ const createTerraformGenerator = (): TerraformGenerator => { a: locals.arg('a') }); - tfg.provisioner('provisioner', { - a: 'a', - b: 123, - c: r.attr('x') - }); - tfg.import({ - a: 'a', - b: 123, - c: r.attr('x') + to: resource, + id: 'id', + provider: arg('arg') }); tfg.resource('tags', 'tags', { tags: map({ 'a': 'a', - 'b c d': 'b c d' + 'b': 'b c d' }) }); diff --git a/test/tfg/__snapshots__/Base.test.ts.snap b/test/tfg/__snapshots__/Base.test.ts.snap index 1686fb8..d1293e1 100644 --- a/test/tfg/__snapshots__/Base.test.ts.snap +++ b/test/tfg/__snapshots__/Base.test.ts.snap @@ -484,9 +484,9 @@ profile = "test" resource "aws_vpc" "vpc"{ cidr_block = "172.88.0.0/16" tags = { -Name = "vpc-test-dev" -Project = "test" -Env = "dev" +name = "vpc-test-dev" +project = "test" +env = "dev" } } @@ -495,9 +495,9 @@ vpc_id = aws_vpc.vpc.id cidr_block = "172.88.100.0/24" availability_zone = "ap-southeast-1a" tags = { -Name = "subnet-test-dev-public0" -Project = "test" -Env = "dev" +name = "subnet-test-dev-public0" +project = "test" +env = "dev" } } @@ -506,9 +506,9 @@ vpc_id = aws_vpc.vpc.id cidr_block = "172.88.101.0/24" availability_zone = "ap-southeast-1b" tags = { -Name = "subnet-test-dev-public1" -Project = "test" -Env = "dev" +name = "subnet-test-dev-public1" +project = "test" +env = "dev" } } @@ -517,9 +517,9 @@ vpc_id = aws_vpc.vpc.id cidr_block = "172.88.102.0/24" availability_zone = "ap-southeast-1c" tags = { -Name = "subnet-test-dev-public2" -Project = "test" -Env = "dev" +name = "subnet-test-dev-public2" +project = "test" +env = "dev" } } @@ -528,9 +528,9 @@ vpc_id = aws_vpc.vpc.id cidr_block = "172.88.104.0/24" availability_zone = "ap-southeast-1a" tags = { -Name = "subnet-test-dev-web0" -Project = "test" -Env = "dev" +name = "subnet-test-dev-web0" +project = "test" +env = "dev" } } @@ -539,9 +539,9 @@ vpc_id = aws_vpc.vpc.id cidr_block = "172.88.105.0/24" availability_zone = "ap-southeast-1b" tags = { -Name = "subnet-test-dev-web1" -Project = "test" -Env = "dev" +name = "subnet-test-dev-web1" +project = "test" +env = "dev" } } @@ -550,9 +550,9 @@ vpc_id = aws_vpc.vpc.id cidr_block = "172.88.106.0/24" availability_zone = "ap-southeast-1c" tags = { -Name = "subnet-test-dev-web2" -Project = "test" -Env = "dev" +name = "subnet-test-dev-web2" +project = "test" +env = "dev" } } @@ -561,9 +561,9 @@ vpc_id = aws_vpc.vpc.id cidr_block = "172.88.108.0/24" availability_zone = "ap-southeast-1a" tags = { -Name = "subnet-test-dev-app0" -Project = "test" -Env = "dev" +name = "subnet-test-dev-app0" +project = "test" +env = "dev" } } @@ -572,9 +572,9 @@ vpc_id = aws_vpc.vpc.id cidr_block = "172.88.109.0/24" availability_zone = "ap-southeast-1b" tags = { -Name = "subnet-test-dev-app1" -Project = "test" -Env = "dev" +name = "subnet-test-dev-app1" +project = "test" +env = "dev" } } @@ -583,9 +583,9 @@ vpc_id = aws_vpc.vpc.id cidr_block = "172.88.110.0/24" availability_zone = "ap-southeast-1c" tags = { -Name = "subnet-test-dev-app2" -Project = "test" -Env = "dev" +name = "subnet-test-dev-app2" +project = "test" +env = "dev" } } @@ -594,9 +594,9 @@ vpc_id = aws_vpc.vpc.id cidr_block = "172.88.112.0/24" availability_zone = "ap-southeast-1a" tags = { -Name = "subnet-test-dev-gut0" -Project = "test" -Env = "dev" +name = "subnet-test-dev-gut0" +project = "test" +env = "dev" } } @@ -605,9 +605,9 @@ vpc_id = aws_vpc.vpc.id cidr_block = "172.88.113.0/24" availability_zone = "ap-southeast-1b" tags = { -Name = "subnet-test-dev-gut1" -Project = "test" -Env = "dev" +name = "subnet-test-dev-gut1" +project = "test" +env = "dev" } } @@ -616,9 +616,9 @@ vpc_id = aws_vpc.vpc.id cidr_block = "172.88.114.0/24" availability_zone = "ap-southeast-1c" tags = { -Name = "subnet-test-dev-gut2" -Project = "test" -Env = "dev" +name = "subnet-test-dev-gut2" +project = "test" +env = "dev" } } @@ -627,9 +627,9 @@ vpc_id = aws_vpc.vpc.id cidr_block = "172.88.116.0/24" availability_zone = "ap-southeast-1a" tags = { -Name = "subnet-test-dev-db0" -Project = "test" -Env = "dev" +name = "subnet-test-dev-db0" +project = "test" +env = "dev" } } @@ -638,9 +638,9 @@ vpc_id = aws_vpc.vpc.id cidr_block = "172.88.117.0/24" availability_zone = "ap-southeast-1b" tags = { -Name = "subnet-test-dev-db1" -Project = "test" -Env = "dev" +name = "subnet-test-dev-db1" +project = "test" +env = "dev" } } @@ -649,27 +649,27 @@ vpc_id = aws_vpc.vpc.id cidr_block = "172.88.118.0/24" availability_zone = "ap-southeast-1c" tags = { -Name = "subnet-test-dev-db2" -Project = "test" -Env = "dev" +name = "subnet-test-dev-db2" +project = "test" +env = "dev" } } resource "aws_internet_gateway" "igw"{ vpc_id = aws_vpc.vpc.id tags = { -Name = "igw-test-dev" -Project = "test" -Env = "dev" +name = "igw-test-dev" +project = "test" +env = "dev" } } resource "aws_route_table" "default"{ vpc_id = aws_vpc.vpc.id tags = { -Name = "rt-test-dev-default" -Project = "test" -Env = "dev" +name = "rt-test-dev-default" +project = "test" +env = "dev" } } @@ -680,9 +680,9 @@ cidr_block = "0.0.0.0/0" gateway_id = aws_internet_gateway.igw.id } tags = { -Name = "rt-test-dev-igw" -Project = "test" -Env = "dev" +name = "rt-test-dev-igw" +project = "test" +env = "dev" } } @@ -794,9 +794,9 @@ from_port = 0 to_port = 0 } tags = { -Name = "nacl-test-dev-default" -Project = "test" -Env = "dev" +name = "nacl-test-dev-default" +project = "test" +env = "dev" } } @@ -840,9 +840,9 @@ from_port = 0 to_port = 0 } tags = { -Name = "nacl-test-dev-db" -Project = "test" -Env = "dev" +name = "nacl-test-dev-db" +project = "test" +env = "dev" } } @@ -868,9 +868,9 @@ cidr_blocks = [ ] } tags = { -Name = "sg-test-dev-public-default" -Project = "test" -Env = "dev" +name = "sg-test-dev-public-default" +project = "test" +env = "dev" } } @@ -896,9 +896,9 @@ cidr_blocks = [ ] } tags = { -Name = "sg-test-dev-web-default" -Project = "test" -Env = "dev" +name = "sg-test-dev-web-default" +project = "test" +env = "dev" } } @@ -924,9 +924,9 @@ cidr_blocks = [ ] } tags = { -Name = "sg-test-dev-app-default" -Project = "test" -Env = "dev" +name = "sg-test-dev-app-default" +project = "test" +env = "dev" } } @@ -952,9 +952,9 @@ cidr_blocks = [ ] } tags = { -Name = "sg-test-dev-gut-default" -Project = "test" -Env = "dev" +name = "sg-test-dev-gut-default" +project = "test" +env = "dev" } } @@ -980,18 +980,18 @@ cidr_blocks = [ ] } tags = { -Name = "sg-test-dev-db-default" -Project = "test" -Env = "dev" +name = "sg-test-dev-db-default" +project = "test" +env = "dev" } } resource "aws_eip" "nat"{ vpc = true tags = { -Name = "eip-test-dev-nat" -Project = "test" -Env = "dev" +name = "eip-test-dev-nat" +project = "test" +env = "dev" } } @@ -999,9 +999,9 @@ resource "aws_nat_gateway" "nat"{ allocation_id = aws_eip.nat.id subnet_id = aws_subnet.public0.id tags = { -Name = "nat-test-dev" -Project = "test" -Env = "dev" +name = "nat-test-dev" +project = "test" +env = "dev" } } @@ -1012,9 +1012,9 @@ cidr_block = "0.0.0.0/0" gateway_id = aws_nat_gateway.nat.id } tags = { -Name = "rt-test-dev-nat" -Project = "test" -Env = "dev" +name = "rt-test-dev-nat" +project = "test" +env = "dev" } } @@ -1093,9 +1093,9 @@ profile = "test" resource "aws_vpc" "vpc"{ cidr_block = "172.88.0.0/16" tags = { -Name = "vpc-test-dev" -Project = "test" -Env = "dev" +name = "vpc-test-dev" +project = "test" +env = "dev" } } @@ -1104,9 +1104,9 @@ vpc_id = aws_vpc.vpc.id cidr_block = "172.88.100.0/24" availability_zone = "ap-southeast-1a" tags = { -Name = "subnet-test-dev-public0" -Project = "test" -Env = "dev" +name = "subnet-test-dev-public0" +project = "test" +env = "dev" } } @@ -1115,9 +1115,9 @@ vpc_id = aws_vpc.vpc.id cidr_block = "172.88.101.0/24" availability_zone = "ap-southeast-1b" tags = { -Name = "subnet-test-dev-public1" -Project = "test" -Env = "dev" +name = "subnet-test-dev-public1" +project = "test" +env = "dev" } } @@ -1126,9 +1126,9 @@ vpc_id = aws_vpc.vpc.id cidr_block = "172.88.102.0/24" availability_zone = "ap-southeast-1c" tags = { -Name = "subnet-test-dev-public2" -Project = "test" -Env = "dev" +name = "subnet-test-dev-public2" +project = "test" +env = "dev" } } @@ -1137,9 +1137,9 @@ vpc_id = aws_vpc.vpc.id cidr_block = "172.88.104.0/24" availability_zone = "ap-southeast-1a" tags = { -Name = "subnet-test-dev-web0" -Project = "test" -Env = "dev" +name = "subnet-test-dev-web0" +project = "test" +env = "dev" } } @@ -1148,9 +1148,9 @@ vpc_id = aws_vpc.vpc.id cidr_block = "172.88.105.0/24" availability_zone = "ap-southeast-1b" tags = { -Name = "subnet-test-dev-web1" -Project = "test" -Env = "dev" +name = "subnet-test-dev-web1" +project = "test" +env = "dev" } } @@ -1159,9 +1159,9 @@ vpc_id = aws_vpc.vpc.id cidr_block = "172.88.106.0/24" availability_zone = "ap-southeast-1c" tags = { -Name = "subnet-test-dev-web2" -Project = "test" -Env = "dev" +name = "subnet-test-dev-web2" +project = "test" +env = "dev" } } @@ -1170,9 +1170,9 @@ vpc_id = aws_vpc.vpc.id cidr_block = "172.88.108.0/24" availability_zone = "ap-southeast-1a" tags = { -Name = "subnet-test-dev-app0" -Project = "test" -Env = "dev" +name = "subnet-test-dev-app0" +project = "test" +env = "dev" } } @@ -1181,9 +1181,9 @@ vpc_id = aws_vpc.vpc.id cidr_block = "172.88.109.0/24" availability_zone = "ap-southeast-1b" tags = { -Name = "subnet-test-dev-app1" -Project = "test" -Env = "dev" +name = "subnet-test-dev-app1" +project = "test" +env = "dev" } } @@ -1192,9 +1192,9 @@ vpc_id = aws_vpc.vpc.id cidr_block = "172.88.110.0/24" availability_zone = "ap-southeast-1c" tags = { -Name = "subnet-test-dev-app2" -Project = "test" -Env = "dev" +name = "subnet-test-dev-app2" +project = "test" +env = "dev" } } @@ -1203,9 +1203,9 @@ vpc_id = aws_vpc.vpc.id cidr_block = "172.88.112.0/24" availability_zone = "ap-southeast-1a" tags = { -Name = "subnet-test-dev-gut0" -Project = "test" -Env = "dev" +name = "subnet-test-dev-gut0" +project = "test" +env = "dev" } } @@ -1214,9 +1214,9 @@ vpc_id = aws_vpc.vpc.id cidr_block = "172.88.113.0/24" availability_zone = "ap-southeast-1b" tags = { -Name = "subnet-test-dev-gut1" -Project = "test" -Env = "dev" +name = "subnet-test-dev-gut1" +project = "test" +env = "dev" } } @@ -1225,9 +1225,9 @@ vpc_id = aws_vpc.vpc.id cidr_block = "172.88.114.0/24" availability_zone = "ap-southeast-1c" tags = { -Name = "subnet-test-dev-gut2" -Project = "test" -Env = "dev" +name = "subnet-test-dev-gut2" +project = "test" +env = "dev" } } @@ -1236,9 +1236,9 @@ vpc_id = aws_vpc.vpc.id cidr_block = "172.88.116.0/24" availability_zone = "ap-southeast-1a" tags = { -Name = "subnet-test-dev-db0" -Project = "test" -Env = "dev" +name = "subnet-test-dev-db0" +project = "test" +env = "dev" } } @@ -1247,9 +1247,9 @@ vpc_id = aws_vpc.vpc.id cidr_block = "172.88.117.0/24" availability_zone = "ap-southeast-1b" tags = { -Name = "subnet-test-dev-db1" -Project = "test" -Env = "dev" +name = "subnet-test-dev-db1" +project = "test" +env = "dev" } } @@ -1258,27 +1258,27 @@ vpc_id = aws_vpc.vpc.id cidr_block = "172.88.118.0/24" availability_zone = "ap-southeast-1c" tags = { -Name = "subnet-test-dev-db2" -Project = "test" -Env = "dev" +name = "subnet-test-dev-db2" +project = "test" +env = "dev" } } resource "aws_internet_gateway" "igw"{ vpc_id = aws_vpc.vpc.id tags = { -Name = "igw-test-dev" -Project = "test" -Env = "dev" +name = "igw-test-dev" +project = "test" +env = "dev" } } resource "aws_route_table" "default"{ vpc_id = aws_vpc.vpc.id tags = { -Name = "rt-test-dev-default" -Project = "test" -Env = "dev" +name = "rt-test-dev-default" +project = "test" +env = "dev" } } @@ -1289,9 +1289,9 @@ cidr_block = "0.0.0.0/0" gateway_id = aws_internet_gateway.igw.id } tags = { -Name = "rt-test-dev-igw" -Project = "test" -Env = "dev" +name = "rt-test-dev-igw" +project = "test" +env = "dev" } } @@ -1403,9 +1403,9 @@ from_port = 0 to_port = 0 } tags = { -Name = "nacl-test-dev-default" -Project = "test" -Env = "dev" +name = "nacl-test-dev-default" +project = "test" +env = "dev" } } @@ -1449,9 +1449,9 @@ from_port = 0 to_port = 0 } tags = { -Name = "nacl-test-dev-db" -Project = "test" -Env = "dev" +name = "nacl-test-dev-db" +project = "test" +env = "dev" } } @@ -1477,9 +1477,9 @@ cidr_blocks = [ ] } tags = { -Name = "sg-test-dev-public-default" -Project = "test" -Env = "dev" +name = "sg-test-dev-public-default" +project = "test" +env = "dev" } } @@ -1505,9 +1505,9 @@ cidr_blocks = [ ] } tags = { -Name = "sg-test-dev-web-default" -Project = "test" -Env = "dev" +name = "sg-test-dev-web-default" +project = "test" +env = "dev" } } @@ -1533,9 +1533,9 @@ cidr_blocks = [ ] } tags = { -Name = "sg-test-dev-app-default" -Project = "test" -Env = "dev" +name = "sg-test-dev-app-default" +project = "test" +env = "dev" } } @@ -1561,9 +1561,9 @@ cidr_blocks = [ ] } tags = { -Name = "sg-test-dev-gut-default" -Project = "test" -Env = "dev" +name = "sg-test-dev-gut-default" +project = "test" +env = "dev" } } @@ -1589,18 +1589,18 @@ cidr_blocks = [ ] } tags = { -Name = "sg-test-dev-db-default" -Project = "test" -Env = "dev" +name = "sg-test-dev-db-default" +project = "test" +env = "dev" } } resource "aws_eip" "nat"{ vpc = true tags = { -Name = "eip-test-dev-nat" -Project = "test" -Env = "dev" +name = "eip-test-dev-nat" +project = "test" +env = "dev" } } @@ -1608,9 +1608,9 @@ resource "aws_nat_gateway" "nat"{ allocation_id = aws_eip.nat.id subnet_id = aws_subnet.public0.id tags = { -Name = "nat-test-dev" -Project = "test" -Env = "dev" +name = "nat-test-dev" +project = "test" +env = "dev" } } @@ -1621,9 +1621,9 @@ cidr_block = "0.0.0.0/0" gateway_id = aws_nat_gateway.nat.id } tags = { -Name = "rt-test-dev-nat" -Project = "test" -Env = "dev" +name = "rt-test-dev-nat" +project = "test" +env = "dev" } } diff --git a/test/tfg/__snapshots__/Others.test.ts.snap b/test/tfg/__snapshots__/Others.test.ts.snap index 9f15156..0f9dcca 100644 --- a/test/tfg/__snapshots__/Others.test.ts.snap +++ b/test/tfg/__snapshots__/Others.test.ts.snap @@ -83,13 +83,6 @@ exports[`Others 2`] = ` "name": "locals", "type": "locals", }, - Provisioner { - "blockNames": [ - "provisioner", - ], - "blockType": "provisioner", - "type": "provisioner", - }, Import { "blockNames": [], "blockType": "import", @@ -186,22 +179,16 @@ resource "locals" "locals"{ a = local.a } -provisioner "provisioner"{ -a = "a" -b = 123 -c = aws_vpc.test.x -} - import{ -a = "a" -b = 123 -c = aws_vpc.test.x +to = innerBlock.innerBlock +id = "id" +provider = arg } resource "tags" "tags"{ tags = { a = "a" -"b c d" = "b c d" +b = "b c d" } } @@ -280,22 +267,16 @@ resource "locals" "locals"{ a = local.a } -provisioner "provisioner"{ -a = "a" -b = 123 -c = aws_vpc.test.x -} - import{ -a = "a" -b = 123 -c = aws_vpc.test.x +to = innerBlock.innerBlock +id = "id" +provider = arg } resource "tags" "tags"{ tags = { a = "a" -"b c d" = "b c d" +b = "b c d" } }