Skip to content
This repository was archived by the owner on Aug 19, 2021. It is now read-only.

Commit f27d407

Browse files
authored
Merge branch 'master' into master
2 parents 48a5011 + ff5e77c commit f27d407

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+2715
-296
lines changed

.isort.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[settings]
2-
known_third_party = boto3,click,jinja2,pytest,pytest_lazyfixture,setuptools,tenacity,tfworker,yaml
2+
known_third_party = boto3,click,jinja2,moto,pkg_resources,pytest,pytest_lazyfixture,tenacity,tfworker,yaml

README.md

Lines changed: 77 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ terraform:
1313

1414
# global level variables
1515
terraform_vars:
16-
region: //aws-region//
16+
region: {{ aws_region }}
1717
environment: dev
1818

1919
definitions:
@@ -28,7 +28,6 @@ terraform:
2828
```sh
2929
% worker --aws-profile default --backend s3 terraform --show-output example1
3030
```
31-
3231
**NOTE:** When adding a provider from a non-hashicorp source, use a `source` field, as follows
3332
(_the `source` field is only valid for terraform 13+ and is not emitted when using 12_):
3433

@@ -64,7 +63,7 @@ Build and publish the package to PYPI:
6463

6564
## Configuration
6665

67-
A project is configured through a worker config, a yaml file that specifies the definitions, inputs, outputs, providers and all other necessary configuration. The worker config is what specifies how state is shared among your definitions. The config support jinja templating that can be used to conditionally pass state or pass in env variables through the command line via the `--config-var` option.
66+
A project is configured through a worker config, a yaml, json, or hcl2 file that specifies the definitions, inputs, outputs, providers and all other necessary configuration. The worker config is what specifies how state is shared among your definitions. The config support jinja templating that can be used to conditionally pass state or pass in env variables through the command line via the `--config-var` option.
6867

6968
*./worker.yaml*
7069
```yaml
@@ -91,6 +90,68 @@ terraform:
9190
subnet: network.outputs.subnet_id
9291
```
9392
93+
```json
94+
{
95+
"terraform": {
96+
"providers": {
97+
"aws": {
98+
"vars": {
99+
"region": "{{ aws_region }}",
100+
"version": "~> 2.61"
101+
}
102+
}
103+
},
104+
"terraform_vars": {
105+
"region": "{{ aws_region }}",
106+
"environment": "dev"
107+
},
108+
"definitions": {
109+
"network": {
110+
"path": "/definitions/aws/network-existing"
111+
},
112+
"database": {
113+
"path": "/definitions/aws/rds",
114+
"remote_vars": {
115+
"subnet": "network.outputs.subnet_id"
116+
}
117+
}
118+
}
119+
}
120+
}
121+
```
122+
123+
```hcl
124+
terraform {
125+
providers {
126+
aws = {
127+
vars = {
128+
region = "{{ aws_region }}"
129+
version = "2.63.0"
130+
}
131+
}
132+
}
133+
134+
terraform_vars {
135+
environment = "dev"
136+
region = "{{ aws_region }}"
137+
}
138+
139+
definitions {
140+
network = {
141+
path = "/definitions/aws/network-existing"
142+
}
143+
144+
database = {
145+
path = "/definitions/aws/rds"
146+
147+
remote_vars = {
148+
subnet = "network.outputs.subnet_id"
149+
}
150+
}
151+
}
152+
}
153+
```
154+
94155
In this config, the worker manages two separate terraform modules, a `network` and a `database` definition, and shares an output from the network definition with the database definition. This is made available inside of the `database` definition through the `local.subnet` value.
95156

96157
`aws_region` is substituted at runtime for the value of `--aws-region` passed through the command line.
@@ -111,3 +172,16 @@ In order to troubleshoot this definition, you would cd /tmp/tmpew44uopp/definiti
111172
## Background
112173

113174
The terraform worker was a weekend project to run terraform against a series of definitions (modules). The idea was the configuration vars, provider configuration, remote state, and variables from remote state would all be dynamically generated. The purpose was for building kubernetes deployments, and allowing all of the configuration information to be stored as either yamnl files in github, or have the worker configuration generated by an API which stored all of the deployment configurations in a database.
175+
176+
## Documentation
177+
178+
Documentation uses the [Sphinx](https://www.sphinx-doc.org/en/master/index.html) documentation fromework.
179+
180+
To build HTML documentation:
181+
182+
```bash
183+
% cd docs
184+
% make clean && make html
185+
```
186+
187+
The documentation can be viewed locally by open `./docs/build/index.html` in a browser.

docs/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = source
9+
BUILDDIR = build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/make.bat

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@ECHO OFF
2+
3+
pushd %~dp0
4+
5+
REM Command file for Sphinx documentation
6+
7+
if "%SPHINXBUILD%" == "" (
8+
set SPHINXBUILD=sphinx-build
9+
)
10+
set SOURCEDIR=source
11+
set BUILDDIR=build
12+
13+
if "%1" == "" goto help
14+
15+
%SPHINXBUILD% >NUL 2>NUL
16+
if errorlevel 9009 (
17+
echo.
18+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
19+
echo.installed, then set the SPHINXBUILD environment variable to point
20+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
21+
echo.may add the Sphinx directory to PATH.
22+
echo.
23+
echo.If you don't have Sphinx installed, grab it from
24+
echo.http://sphinx-doc.org/
25+
exit /b 1
26+
)
27+
28+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29+
goto end
30+
31+
:help
32+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33+
34+
:end
35+
popd

docs/source/_static/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# This is a terraform configuration file.

0 commit comments

Comments
 (0)