This repository was archived by the owner on Mar 24, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change 1
1
# dottfvars
2
+
3
+ Parses a ` .tfvars ` or ` .tfvars.json ` file and adds the key value pairs
4
+ to the node environment variables (` process.env ` ). This module is
5
+ intended to be used in conjunction with the
6
+ [ ` env-var ` module] ( https://www.npmjs.com/package/env-var ) .
7
+
8
+ ## Usage
9
+
10
+ Can parse ` .tfvars ` files
11
+
12
+ ``` ts
13
+ import {resolve } from ' path'
14
+
15
+ dottfvars .from (resolve (__dirname , ' iac/development.tfvars' ))
16
+ const imageId = env .from (process .env ).get (' image_id' ).asString ()
17
+ ```
18
+
19
+ Alternatively, you may define your tfvars as JSON and pass in a
20
+ ` .tfvars.json ` file path instead.
21
+
22
+ Related Packages:
23
+ - [ env-ssm] ( https://github.com/byu-oit/env-ssm#readme )
Original file line number Diff line number Diff line change @@ -3,15 +3,15 @@ import * as env from 'env-var'
3
3
import * as dottfvars from '../src/dottfvars'
4
4
5
5
test ( 'parses .tfvars file' , async ( ) => {
6
- await dottfvars . from ( resolve ( __dirname , 'examples/good.tfvars' ) )
6
+ dottfvars . from ( resolve ( __dirname , 'examples/good.tfvars' ) )
7
7
const imageId = env . from ( process . env ) . get ( 'image_id' ) . asString ( )
8
8
const availabilityZoneNames = env . from ( process . env ) . get ( 'availability_zone_names' ) . asJsonArray ( )
9
9
expect ( typeof imageId ) . toBe ( 'string' )
10
10
expect ( availabilityZoneNames ) . toHaveLength ( 2 )
11
11
} )
12
12
13
13
test ( 'parses tfvars.json file' , async ( ) => {
14
- await dottfvars . from ( resolve ( __dirname , 'examples/good.tfvars.json' ) )
14
+ dottfvars . from ( resolve ( __dirname , 'examples/good.tfvars.json' ) )
15
15
const imageId = env . from ( process . env ) . get ( 'image_id' ) . asString ( )
16
16
const availabilityZoneNames = env . from ( process . env ) . get ( 'availability_zone_names' ) . asJsonArray ( )
17
17
expect ( typeof imageId ) . toBe ( 'string' )
You can’t perform that action at this time.
0 commit comments