terraform-generator
Advanced tools
Comparing version 3.4.0 to 3.5.0
@@ -61,3 +61,7 @@ import { TerraformVersion, Attribute, Argument } from '..'; | ||
abstract attr(name: string): Attribute; | ||
/** | ||
* Block's id attribute. | ||
*/ | ||
get id(): Attribute; | ||
private validateIdentifier; | ||
} |
@@ -84,2 +84,8 @@ "use strict"; | ||
} | ||
/** | ||
* Block's id attribute. | ||
*/ | ||
get id() { | ||
return this.attr('id'); | ||
} | ||
validateIdentifier(identifier) { | ||
@@ -86,0 +92,0 @@ if (!identifier.match(/^[a-zA-Z_\-]{1}[0-9a-zA-Z_\-]*$/)) { |
@@ -12,4 +12,5 @@ import { Block, Argument, Attribute } from '..'; | ||
constructor(name: string, args?: Record<string, any>); | ||
private static customArgumentToString; | ||
asArgument(): Argument; | ||
attr(name: string): Attribute; | ||
} |
@@ -17,12 +17,13 @@ "use strict"; | ||
constructor(name, args) { | ||
super('variable', [name], args, (version, key, value) => { | ||
if (version === '0.12' && key === 'type' && typeof value === 'string') { | ||
return `${key} = ${value}\n`; | ||
} | ||
else { | ||
return TerraformGeneratorUtils_1.default.argumentToString(version, key, value); | ||
} | ||
}); | ||
super('variable', [name], args, Variable.customArgumentToString); | ||
this.name = name; | ||
} | ||
static customArgumentToString(version, key, value) { | ||
if (version === '0.12' && key === 'type' && typeof value === 'string') { | ||
return `${key} = ${value}\n`; | ||
} | ||
else { | ||
return TerraformGeneratorUtils_1.default.argumentToString(version, key, value); | ||
} | ||
} | ||
asArgument() { | ||
@@ -29,0 +30,0 @@ return new __1.Argument(`var.${this.name}`); |
{ | ||
"name": "terraform-generator", | ||
"version": "3.4.0", | ||
"version": "3.5.0", | ||
"author": "Chang Zhe Jiet", | ||
@@ -5,0 +5,0 @@ "description": "Generate Terraform configurations with Node.js.", |
@@ -113,3 +113,4 @@ # **terraform-generator** | ||
```javascript | ||
block.attr('id') // block id, string | ||
block.id // block id, string | ||
block.id // convenience function for attr('id') | ||
block.attr('subnets') // subnet objects, object list | ||
@@ -226,3 +227,3 @@ block.attr('subnets.*.id') // subnet ids, string list | ||
const subnet = tfg.resource('aws_subnet', `subnet_${name}`, { | ||
vpc_id: vpc.attr('id'), | ||
vpc_id: vpc.id, | ||
cidr_block: cidr, | ||
@@ -239,5 +240,5 @@ availability_zone: getAvailabilityZone(i), | ||
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')) | ||
webSubnets: subnets.web.map(subnet => subnet.id), | ||
appSubnets: subnets.app.map(subnet => subnet.id), | ||
dbSubnets: subnets.db.map(subnet => subnet.id) | ||
}) | ||
@@ -244,0 +245,0 @@ }); |
49949
1276
247