Skip to content

Commit f42c074

Browse files
committed
First version (ported from internal infra)
0 parents  commit f42c074

File tree

15 files changed

+441
-0
lines changed

15 files changed

+441
-0
lines changed

.github/workflows/main.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: validate
2+
on: [push, pull_request]
3+
4+
jobs:
5+
pre-commit:
6+
runs-on: ubuntu-latest
7+
8+
steps:
9+
- uses: actions/checkout@v3
10+
11+
- name: pip cache
12+
uses: actions/cache@v3
13+
with:
14+
path: ~/.cache/pip
15+
key: ${{ runner.os }}-pip-${{ hashFiles('ci/requirements.txt') }}
16+
restore-keys: |
17+
${{ runner.os }}-pip-
18+
19+
- name: pre-commit cache
20+
uses: actions/cache@v3
21+
with:
22+
path: ~/.cache/pre-commit
23+
key: ${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
24+
restore-keys: |
25+
${{ runner.os }}-pre-commit-
26+
27+
- name: ~/bin cache
28+
uses: actions/cache@v3
29+
with:
30+
path: ~/bin
31+
key: ${{ runner.os }}-homebin-${{ hashFiles('ci/versions.sh') }}
32+
restore-keys: |
33+
${{ runner.os }}-homebin-
34+
35+
- name: Install pre-commit
36+
run: python3 -m pip install --disable-pip-version-check -r ci/requirements.txt
37+
38+
- name: Install terraform-docs
39+
run: ci/install-binary.sh terraform-docs
40+
41+
- name: Install tflint
42+
run: ci/install-binary.sh tflint
43+
44+
- name: Run pre-commit tests
45+
run: PATH="~/bin:$PATH" pre-commit run --all-files

.markdownlintrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"default": true,
3+
"line_length": false,
4+
"no-inline-html": false
5+
}

.pre-commit-config.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.6.0
4+
hooks:
5+
- id: check-json
6+
- id: check-merge-conflict
7+
- id: check-yaml
8+
- id: detect-private-key
9+
- id: end-of-file-fixer
10+
- id: pretty-format-json
11+
args:
12+
- --autofix
13+
- id: trailing-whitespace
14+
15+
- repo: https://github.com/igorshubovych/markdownlint-cli
16+
rev: v0.41.0
17+
hooks:
18+
- id: markdownlint
19+
20+
- repo: https://github.com/antonbabenko/pre-commit-terraform
21+
rev: v1.93.0
22+
hooks:
23+
- id: terraform_fmt
24+
- id: terraform_tflint
25+
26+
- repo: https://github.com/terraform-docs/terraform-docs
27+
rev: v0.18.0
28+
hooks:
29+
- id: terraform-docs-go
30+
args: ["--output-file", "README.md", "."]
31+
32+
- repo: https://github.com/detailyang/pre-commit-shell
33+
rev: 1.0.5
34+
hooks:
35+
- id: shell-lint

.shellcheckrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
external-sources=true

.terraform-docs.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
formatter: "markdown table"
2+
output:
3+
file: README.md
4+
mode: inject
5+
template: |-
6+
<!-- BEGIN_TF_DOCS -->
7+
{{ .Content }}
8+
<!-- END_TF_DOCS -->

CODE_OF_CONDUCT.md

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
2+
# Contributor Covenant Code of Conduct
3+
4+
## Our Pledge
5+
6+
We as members, contributors, and leaders pledge to make participation in our
7+
community a harassment-free experience for everyone, regardless of age, body
8+
size, visible or invisible disability, ethnicity, sex characteristics, gender
9+
identity and expression, level of experience, education, socio-economic status,
10+
nationality, personal appearance, race, caste, color, religion, or sexual
11+
identity and orientation.
12+
13+
We pledge to act and interact in ways that contribute to an open, welcoming,
14+
diverse, inclusive, and healthy community.
15+
16+
## Our Standards
17+
18+
Examples of behavior that contributes to a positive environment for our
19+
community include:
20+
21+
* Demonstrating empathy and kindness toward other people
22+
* Being respectful of differing opinions, viewpoints, and experiences
23+
* Giving and gracefully accepting constructive feedback
24+
* Accepting responsibility and apologizing to those affected by our mistakes,
25+
and learning from the experience
26+
* Focusing on what is best not just for us as individuals, but for the overall
27+
community
28+
29+
Examples of unacceptable behavior include:
30+
31+
* The use of sexualized language or imagery, and sexual attention or advances of
32+
any kind
33+
* Trolling, insulting or derogatory comments, and personal or political attacks
34+
* Public or private harassment
35+
* Publishing others' private information, such as a physical or email address,
36+
without their explicit permission
37+
* Other conduct which could reasonably be considered inappropriate in a
38+
professional setting
39+
40+
## Enforcement Responsibilities
41+
42+
Community leaders are responsible for clarifying and enforcing our standards of
43+
acceptable behavior and will take appropriate and fair corrective action in
44+
response to any behavior that they deem inappropriate, threatening, offensive,
45+
or harmful.
46+
47+
Community leaders have the right and responsibility to remove, edit, or reject
48+
comments, commits, code, wiki edits, issues, and other contributions that are
49+
not aligned to this Code of Conduct, and will communicate reasons for moderation
50+
decisions when appropriate.
51+
52+
## Scope
53+
54+
This Code of Conduct applies within all community spaces, and also applies when
55+
an individual is officially representing the community in public spaces.
56+
Examples of representing our community include using an official email address,
57+
posting via an official social media account, or acting as an appointed
58+
representative at an online or offline event.
59+
60+
## Enforcement
61+
62+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
63+
reported to the community leaders responsible for enforcement at
64+
`tf-modules@theory.org`. All complaints will be reviewed and investigated
65+
promptly and fairly.
66+
67+
All community leaders are obligated to respect the privacy and security of the
68+
reporter of any incident.
69+
70+
## Enforcement Guidelines
71+
72+
Community leaders will follow these Community Impact Guidelines in determining
73+
the consequences for any action they deem in violation of this Code of Conduct:
74+
75+
### 1. Correction
76+
77+
**Community Impact**: Use of inappropriate language or other behavior deemed
78+
unprofessional or unwelcome in the community.
79+
80+
**Consequence**: A private, written warning from community leaders, providing
81+
clarity around the nature of the violation and an explanation of why the
82+
behavior was inappropriate. A public apology may be requested.
83+
84+
### 2. Warning
85+
86+
**Community Impact**: A violation through a single incident or series of
87+
actions.
88+
89+
**Consequence**: A warning with consequences for continued behavior. No
90+
interaction with the people involved, including unsolicited interaction with
91+
those enforcing the Code of Conduct, for a specified period of time. This
92+
includes avoiding interactions in community spaces as well as external channels
93+
like social media. Violating these terms may lead to a temporary or permanent
94+
ban.
95+
96+
### 3. Temporary Ban
97+
98+
**Community Impact**: A serious violation of community standards, including
99+
sustained inappropriate behavior.
100+
101+
**Consequence**: A temporary ban from any sort of interaction or public
102+
communication with the community for a specified period of time. No public or
103+
private interaction with the people involved, including unsolicited interaction
104+
with those enforcing the Code of Conduct, is allowed during this period.
105+
Violating these terms may lead to a permanent ban.
106+
107+
### 4. Permanent Ban
108+
109+
**Community Impact**: Demonstrating a pattern of violation of community
110+
standards, including sustained inappropriate behavior, harassment of an
111+
individual, or aggression toward or disparagement of classes of individuals.
112+
113+
**Consequence**: A permanent ban from any sort of public interaction within the
114+
community.
115+
116+
## Attribution
117+
118+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
119+
version 2.1, available at
120+
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
121+
122+
Community Impact Guidelines were inspired by
123+
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
124+
125+
For answers to common questions about this code of conduct, see the FAQ at
126+
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
127+
[https://www.contributor-covenant.org/translations][translations].
128+
129+
[homepage]: https://www.contributor-covenant.org
130+
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
131+
[Mozilla CoC]: https://github.com/mozilla/diversity
132+
[FAQ]: https://www.contributor-covenant.org/faq
133+
[translations]: https://www.contributor-covenant.org/translations

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 jeremy avnet
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# terraform-cloudflare-dns-https
2+
3+
Create ServiceMode [DNS HTTPS records](https://kalfeher.com/https-records-simple/) in Cloudflare.
4+
5+
The Zone ID can be found on the Cloudflare overview page for the domain you
6+
want to add records to.
7+
8+
## Usage
9+
10+
To create an HTTPS record saying `example.com` is available via http/2 over TLS:
11+
12+
```hcl
13+
module "tea_sh_https" {
14+
source = "brainsik/dns-https/cloudflare"
15+
zone_id = "313372600deadcodebea5751993defc0"
16+
name = "example.com"
17+
18+
alpn = "h2"
19+
}
20+
```
21+
22+
To create an HTTPS record saying `example.com` is available via http/3 or http/2 over TLS with IPs to use for initially establishing a connection:
23+
24+
```hcl
25+
module "tea_sh_https" {
26+
source = "brainsik/dns-https/cloudflare"
27+
zone_id = "313372600deadcodebea5751993defc0"
28+
name = "example.com"
29+
30+
alpn = "h3,h2"
31+
ipv4hint = "192.0.2.1"
32+
ipv6hint = "2001:db8::1,2001:db8::2"
33+
}
34+
```
35+
36+
<!-- BEGIN_TF_DOCS -->
37+
## Requirements
38+
39+
| Name | Version |
40+
|------|---------|
41+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.6 |
42+
| <a name="requirement_cloudflare"></a> [cloudflare](#requirement\_cloudflare) | >= 4.0 |
43+
44+
## Providers
45+
46+
| Name | Version |
47+
|------|---------|
48+
| <a name="provider_cloudflare"></a> [cloudflare](#provider\_cloudflare) | >= 4.0 |
49+
50+
## Modules
51+
52+
No modules.
53+
54+
## Resources
55+
56+
| Name | Type |
57+
|------|------|
58+
| [cloudflare_record.https](https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs/resources/record) | resource |
59+
60+
## Inputs
61+
62+
| Name | Description | Type | Default | Required |
63+
|------|-------------|------|---------|:--------:|
64+
| <a name="input_alpn"></a> [alpn](#input\_alpn) | A comma separated list of short form ALPN identifiers (e.g., "h2" or "h3,h2") | `string` | n/a | yes |
65+
| <a name="input_ipv4hint"></a> [ipv4hint](#input\_ipv4hint) | A comma separated list of IPs | `string` | `""` | no |
66+
| <a name="input_ipv6hint"></a> [ipv6hint](#input\_ipv6hint) | A comma separated list of IPs | `string` | `""` | no |
67+
| <a name="input_name"></a> [name](#input\_name) | The name of the record | `string` | n/a | yes |
68+
| <a name="input_priority"></a> [priority](#input\_priority) | Resource record priority | `number` | `1` | no |
69+
| <a name="input_zone_id"></a> [zone\_id](#input\_zone\_id) | The Cloudflare DNS zone ID to add the record to | `string` | n/a | yes |
70+
71+
## Outputs
72+
73+
No outputs.
74+
<!-- END_TF_DOCS -->

ci/install-binary.sh

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/bin/bash
2+
set -eu -o pipefail
3+
4+
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
5+
# shellcheck source=ci/versions.sh
6+
source "$SCRIPT_DIR/versions.sh"
7+
8+
bin_name=$1
9+
case "$bin_name" in
10+
terraform-docs)
11+
bin_name_ver="$bin_name-$TERRAFORM_DOCS_VER"
12+
bin_dl_file="terraform-docs-$TERRAFORM_DOCS_VER-linux-amd64.tar.gz"
13+
bin_dl_url="https://github.com/terraform-docs/terraform-docs/releases/download/$TERRAFORM_DOCS_VER/$bin_dl_file"
14+
;;
15+
tflint)
16+
bin_name_ver="$bin_name-$TFLINT_VER"
17+
bin_dl_file="tflint_linux_amd64.zip"
18+
bin_dl_url="https://github.com/terraform-linters/tflint/releases/download/$TFLINT_VER/$bin_dl_file"
19+
;;
20+
esac
21+
bin_path="$HOME/bin/$bin_name_ver"
22+
23+
# Bail out if we already have this version installed
24+
if [[ -x "$bin_path" ]]; then
25+
echo "✨ Found $bin_path"
26+
exit 0
27+
fi
28+
29+
# Ensure ~/bin exists
30+
mkdir -p "$HOME/bin"
31+
32+
# Grab the archive from GitHub releases
33+
pushd "$(mktemp -d -t "$bin_name.XXXXXXXX")" >/dev/null
34+
curl --fail -# -L -o "$bin_dl_file" "$bin_dl_url"
35+
if echo "$bin_dl_file" | grep -q '\.tar\.gz$'; then
36+
tar -xzf "$bin_dl_file"
37+
elif echo "$bin_dl_file" | grep -q '\.zip$'; then
38+
unzip -u "$bin_dl_file"
39+
else
40+
echo "🚨 Unrecognized extension in $bin_dl_file"
41+
exit 1
42+
fi
43+
chmod +x "$bin_name"
44+
mv "$bin_name" "$bin_path"
45+
popd >/dev/null
46+
47+
# Move binary to ~/bin and symlink
48+
pushd "$HOME/bin" >/dev/null
49+
rm -f "$bin_name"
50+
ln -s "$bin_path" "$bin_name"
51+
popd >/dev/null

ci/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pre-commit==3.8.0

0 commit comments

Comments
 (0)