Skip to content

Commit 6c8108a

Browse files
authored
feat: add initial terraform (#1)
1 parent 8f57b5d commit 6c8108a

18 files changed

+883
-0
lines changed

.circleci/config.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
version: 2.1
2+
3+
executors:
4+
terraform:
5+
docker:
6+
- image: cimg/deploy:2023.05
7+
node:
8+
docker:
9+
- image: cimg/node:current
10+
11+
python:
12+
docker:
13+
- image: cimg/python:3.11.3
14+
15+
tf_docs:
16+
docker:
17+
- image: quay.io/terraform-docs/terraform-docs:0.17.0
18+
19+
20+
jobs:
21+
terraform_check:
22+
executor: terraform
23+
steps:
24+
- checkout
25+
- run:
26+
step_name: Run Terraform Validate
27+
command: |
28+
terraform init -backend=false
29+
terraform validate
30+
31+
terraform_docs:
32+
executor: tf_docs
33+
steps:
34+
- checkout
35+
- run:
36+
step_name: Verify Terraform Documentation Generation
37+
command: |
38+
cp README.md /tmp
39+
terraform-docs markdown .
40+
diff /tmp/README.md README.md
41+
42+
43+
msg_check:
44+
executor: python
45+
steps:
46+
- checkout
47+
- run:
48+
command: |
49+
if [ -z "${CIRCLE_PR_NUMBER}" ]; then
50+
MSG="`git log -n 1 --pretty=%s`"
51+
else
52+
MSG="`curl -s https://api.github.com/repos/${CIRCLE_PR_REPONAME}/pulls/${CIRCLE_PR_NUMBER}|jq .title`"
53+
MSG="${${MSG%%\"}##\"}"
54+
if [ -z "$MSG" ]; then
55+
MSG="`git log -n 1 --pretty=%s`"
56+
fi
57+
fi
58+
59+
hooks/commit-msg.py "$MSG"
60+
61+
version_bump:
62+
executor: node
63+
steps:
64+
- checkout
65+
- run:
66+
step_name: Semantic Release
67+
command: |
68+
eval $(ssh-agent -s)
69+
echo $DEPLOY_KEY | base64 -d > /tmp/deploy_key
70+
chmod 600 /tmp/deploy_key
71+
ssh-add /tmp/deploy_key </dev/null
72+
npx semantic-release
73+
74+
75+
workflows:
76+
pr_test:
77+
when:
78+
and:
79+
- not:
80+
matches:
81+
pattern: "^main$"
82+
value: << pipeline.git.branch >>
83+
jobs:
84+
- terraform_check
85+
- msg_check
86+
- terraform_docs
87+
release:
88+
when:
89+
and:
90+
- equal: [ main, << pipeline.git.branch >> ]
91+
jobs:
92+
- version_bump

.github/CONTRIBUTING.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Welcome to Fullstory's Terraform contributing guide
2+
3+
Thanks for your time in contributing to this project! Please read all the information below to properly
4+
contribute with our workflow.
5+
6+
## Issues
7+
8+
- Make sure you test against the latest tagged version with the expected terraform version
9+
- Re-run the `init-repo.sh` to ensure your local is the expected setup
10+
- Provide a reprducible (or show) case. If you cannot accurately show the issue, it'll be difficult to fix
11+
12+
## Setting up your workspace for dev
13+
14+
- Run the `init-repo.sh` to ensure your dev workspace is correct with all tooling
15+
16+
## Generating the README
17+
18+
You can generate the README with HCL examples using `terraform-docs`. You can install `terraform-docs` by following [this guide](https://terraform-docs.io/user-guide/installation/).
19+
20+
```
21+
terraform-docs markdown .
22+
```
23+
24+
## Commit Messages
25+
26+
This repo follows the [conventional commit](https://www.conventionalcommits.org/en/v1.0.0/#summary) message style. This is strictly enforced by git hooks (which should have been activated by the `init-repo.sh`) and by CI. A small example is below:
27+
28+
```
29+
feat: allow customization of cloudfront headers that are forwarded to origin
30+
```
31+
32+
## Opening a PR
33+
34+
Thanks for contributing! When you're ready to open a PR, you will need to fork this repo, push changes to your fork, and then open a PR here. Note: See [Working with forks](https://help.github.com/articles/working-with-forks/) for a better way to use git push.

.github/pull_request_template.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
## Description
2+
3+
<!--- Describe your changes in detail -->
4+
<!--- Are these changes a new behavior? What was the old vs new -->
5+
6+
## Issue or Ticket
7+
8+
<!--- There should be an issue (github issue) or Jira ticket for this work -->
9+
10+
<!--- Please link to the issue here: -->
11+
12+
<!-- Comment this out if you'd like to include more information for an easier review
13+
## Additional Info
14+
-->
15+
16+
## Checklist before submitting PR for review
17+
18+
- [ ] This change requires a doc update, and I've included it
19+
- [ ] My code follows the style guidelines of this project
20+
- [ ] I have ensured my code is commented and any new terraform variables have proper descriptions

.gitignore

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Local .terraform directories
2+
**/.terraform/*
3+
4+
# .tfstate files
5+
*.tfstate
6+
*.tfstate.*
7+
8+
# Crash log files
9+
crash.log
10+
11+
# Ignore any .tfvars files that are generated automatically for each Terraform run. Most
12+
# .tfvars files are managed as part of configuration and so should be included in
13+
# version control.
14+
#
15+
# example.tfvars
16+
17+
# Ignore override files as they are usually used to override resources locally and so
18+
# are not checked in
19+
override.tf
20+
override.tf.json
21+
*_override.tf
22+
*_override.tf.json
23+
24+
# Include override files you do wish to add to version control using negated pattern
25+
#
26+
# !example_override.tf
27+
28+
# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
29+
# example: *tfplan*
30+
31+
# VSCode
32+
.vscode

.releaserc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
branches: ["main"]
2+
tagFormat: ${version}
3+
plugins:
4+
[
5+
"@semantic-release/commit-analyzer",
6+
"@semantic-release/release-notes-generator",
7+
"@semantic-release/github"
8+
]

.terraform-docs.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
formatter: "markdown"
2+
output:
3+
file: README.md
4+
mode: inject
5+
template: |-
6+
<!-- BEGIN_TF_DOCS -->
7+
{{ .Content }}
8+
<!-- END_TF_DOCS -->
9+
content: |-
10+
{{ .Requirements }}
11+
12+
{{ .Inputs }}
13+
14+
{{ .Outputs }}
15+
16+
## Usage
17+
18+
```hcl
19+
{{ include "examples/basic/main.tf" }}
20+
```
21+
22+
### Creating a READER role
23+
This module **does not** create a READER role. You can use the following example to create a READER role that will allow a user to use and read all objects _and_ all future objects in the database.
24+
```hcl
25+
{{ include "examples/reader_role/main.tf" }}
26+
```

0 commit comments

Comments
 (0)