Skip to content

Commit 3cbe5ae

Browse files
authored
Migrate to OpenTofu (#28)
1 parent a34dda6 commit 3cbe5ae

File tree

24 files changed

+55
-212
lines changed

24 files changed

+55
-212
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Terraform Tests
1+
name: OpenTofu Tests
22

33
on:
44
workflow_dispatch:
@@ -10,14 +10,12 @@ on:
1010
- "**.md"
1111

1212
permissions:
13-
id-token: write
13+
contents: read
1414

1515
jobs:
1616
tests:
1717
name: Tests
18-
uses: osinfra-io/github-terraform-gcp-called-workflows/.github/workflows/test.yml@v0.2.6
18+
uses: osinfra-io/github-terraform-gcp-called-workflows/.github/workflows/test.yml@e067c396b92a716f0ea384764ef6b8e1714dfa54
1919
if: github.actor != 'dependabot[bot]'
2020
with:
21-
service_account: plt-lz-testing-github@plt-lz-terraform-tf00-sb.iam.gserviceaccount.com
22-
terraform_version: ${{ vars.TERRAFORM_VERSION }}
23-
workload_identity_provider: projects/746490462722/locations/global/workloadIdentityPools/github-actions/providers/github-actions-oidc
21+
opentofu_version: ${{ vars.OPENTOFU_VERSION }}

.gitignore

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,17 @@
11
# .gitignore
22
# https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files
33

4-
# Local .terraform directories
4+
# Local .tofu directories
5+
**/.tofu/*
56
**/.terraform/*
67

7-
# .tfstate files
8-
*.tfstate
9-
*.tfstate.*
10-
11-
# Crash log files
12-
crash.log
13-
148
# Ignore provider lock file
9+
.tofu.lock.hcl
1510
.terraform.lock.hcl
1611

17-
# Ignore any local.tfvars. Most .tfvars files are managed as part of configuration and so should
18-
# be included in version control.
19-
local.tfvars
20-
21-
# Ignore override files as they are usually used to override resources locally
22-
override.tf
23-
override.tf.json
24-
*_override.tf
25-
*_override.tf.json
26-
2712
# Ignore plan output files
2813
plan.out
2914

30-
# Ignore checkov directories and files
31-
.external_modules
32-
3315
# Ignore Infracost directories and files
3416
.infracost
3517

.pre-commit-config.yaml

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,16 @@ repos:
1010
- id: trailing-whitespace
1111
- id: check-symlinks
1212

13-
- repo: https://github.com/antonbabenko/pre-commit-terraform
14-
rev: v1.99.4
13+
- repo: https://github.com/osinfra-io/pre-commit-hooks
14+
rev: v0.1.1
1515
hooks:
16-
- id: terraform_fmt
17-
18-
# To speed up local validation add the following to your ~/.zshrc:
19-
# export TF_PLUGIN_CACHE_DIR=$HOME/.terraform.d/plugin-cache
20-
21-
- id: terraform_validate
22-
args:
23-
- --hook-config=--retry-once-with-cleanup=true
24-
- --tf-init-args=-upgrade
25-
exclude: tests/fixtures/shared
26-
27-
# Always run after terraform_validate
16+
- id: tofu-fmt
17+
verbose: true
2818

29-
- id: terraform_docs
19+
# To speed up local validation:
20+
# mkdir -p $HOME/.opentofu.d/plugin-cache
21+
# Add the following to your ~/.zshrc:
22+
# export TF_PLUGIN_CACHE_DIR=$HOME/.opentofu.d/plugin-cache
3023

31-
- repo: https://github.com/bridgecrewio/checkov.git
32-
rev: 3.2.443
33-
hooks:
34-
- id: checkov
24+
- id: tofu-validate
3525
verbose: true
36-
args:
37-
- --download-external-modules=true
38-
- --skip-check
39-
- "CKV_TF_1"
40-
- --quiet

.terraform-docs.yml

Lines changed: 0 additions & 5 deletions
This file was deleted.

README.md

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# <img align="left" width="45" height="45" src="https://github.com/user-attachments/assets/eb7f0847-4807-4a4a-a36a-86740477c660"> Kubernetes - Datadog Operator Terraform Module
1+
# <img align="left" width="45" height="45" src="https://github.com/user-attachments/assets/eb7f0847-4807-4a4a-a36a-86740477c660"> Kubernetes - Datadog Operator OpenTofu Module
22

3-
**[GitHub Actions](https://github.com/osinfra-io/terraform-kubernetes-datadog-operator/actions):**
3+
**[GitHub Actions](https://github.com/osinfra-io/opentofu-kubernetes-datadog-operator/actions):**
44

5-
[![Terraform Tests](https://github.com/osinfra-io/terraform-kubernetes-datadog-operator/actions/workflows/test.yml/badge.svg)](https://github.com/osinfra-io/terraform-kubernetes-datadog-operator/actions/workflows/test.yml) [![Dependabot](https://github.com/osinfra-io/terraform-kubernetes-datadog-operator/actions/workflows/dependabot.yml/badge.svg)](https://github.com/osinfra-io/terraform-kubernetes-datadog-operator/actions/workflows/dependabot.yml)
5+
[![OpenTofu Tests](https://github.com/osinfra-io/opentofu-kubernetes-datadog-operator/actions/workflows/test.yml/badge.svg)](https://github.com/osinfra-io/opentofu-kubernetes-datadog-operator/actions/workflows/test.yml) [![Dependabot](https://github.com/osinfra-io/opentofu-kubernetes-datadog-operator/actions/workflows/dependabot.yml/badge.svg)](https://github.com/osinfra-io/opentofu-kubernetes-datadog-operator/actions/workflows/dependabot.yml)
66

77
**[Infracost](https://www.infracost.io):**
88

@@ -12,10 +12,10 @@
1212

1313
## Repository Description
1414

15-
Terraform **example** module for the Datadog Kubernetes Operator on Google Kubernetes Engine (GKE).
15+
OpenTofu **example** module for the Datadog Kubernetes Operator on Google Kubernetes Engine (GKE).
1616

1717
> [!NOTE]
18-
> We do not recommend consuming this module like you might a [public module](https://registry.terraform.io/browse/modules). It is a baseline, something you can fork, potentially maintain, and modify to fit your organization's needs. Using public modules vs. writing your own has various [drivers and trade-offs](https://docs.osinfra.io/fundamentals/architecture-decision-records/adr-0003) that your organization should evaluate.
18+
> We do not recommend consuming this module like you might a [public module](https://search.opentofu.org). It is a baseline, something you can fork, potentially maintain, and modify to fit your organization's needs. Using public modules vs. writing your own has various [drivers and trade-offs](https://docs.osinfra.io/fundamentals/architecture-decision-records/adr-0003) that your organization should evaluate.
1919
2020
## 🔩 Usage
2121

@@ -28,18 +28,16 @@ Our focus is on the core fundamental practice of platform engineering, Infrastru
2828

2929
>Open Source Infrastructure (as Code) is a development model for infrastructure that focuses on open collaboration and applying relative lessons learned from software development practices that organizations can use internally at scale. - [Open Source Infrastructure (as Code)](https://www.osinfra.io)
3030
31-
To avoid slowing down stream-aligned teams, we want to open up the possibility for contributions. The Open Source Infrastructure (as Code) model allows team members external to the platform team to contribute with only a slight increase in cognitive load. This section is for developers who want to contribute to this repository, describing the tools used, the skills, and the knowledge required, along with Terraform documentation.
31+
To avoid slowing down stream-aligned teams, we want to open up the possibility for contributions. The Open Source Infrastructure (as Code) model allows team members external to the platform team to contribute with only a slight increase in cognitive load. This section is for developers who want to contribute to this repository, describing the tools used, the skills, and the knowledge required, along with OpenTofu documentation.
3232

3333
See the [documentation](https://docs.osinfra.io/fundamentals/development-setup) for setting up a local development environment.
3434

3535
### 🛠️ Tools
3636

37-
- [checkov](https://github.com/bridgecrewio/checkov)
3837
- [helm](https://github.com/helm/helm)
3938
- [infracost](https://github.com/infracost/infracost)
39+
- [osinfra-pre-commit-hooks](https://github.com/osinfra-io/pre-commit-hooks)
4040
- [pre-commit](https://github.com/pre-commit/pre-commit)
41-
- [pre-commit-terraform](https://github.com/antonbabenko/pre-commit-terraform)
42-
- [terraform-docs](https://github.com/terraform-docs/terraform-docs)
4341

4442
### 📋 Skills and Knowledge
4543

@@ -49,21 +47,16 @@ Links to documentation and other resources required to develop and iterate in th
4947

5048
### 🔍 Tests
5149

52-
All tests are [mocked](https://developer.hashicorp.com/terraform/language/tests/mocking) allowing us to test the module without creating infrastructure or requiring credentials. The trade-offs are acceptable in favor of speed and simplicity. In a Terraform test, a mocked provider or resource will generate fake data for all computed attributes that would normally be provided by the underlying provider APIs.
50+
All tests are [mocked](https://opentofu.org/docs/cli/commands/test/#the-mock_provider-blocks) allowing us to test the module without creating infrastructure or requiring credentials. The trade-offs are acceptable in favor of speed and simplicity. In an OpenTofu test, a mocked provider or resource will generate fake data for all computed attributes that would normally be provided by the underlying provider APIs.
5351

5452
```none
55-
terraform init
53+
tofu init
5654
```
5755

5856
```none
59-
terraform test
57+
tofu test
6058
```
6159

62-
## 📓 Terraform Documentation
60+
## 📓 OpenTofu Documentation
6361

6462
> A child module automatically inherits default (un-aliased) provider configurations from its parent. The provider versions below are informational only and do **not** need to align with the provider configurations from its parent.
65-
66-
## 📓 Terraform Regional Documentation
67-
68-
- [regional](regional/README.md)
69-
- [regional/manifests](regional/manifests/README.md)

SECURITY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ the community, but it does come with some risks.
77
## Reporting a Vulnerability
88

99
Privately discuss, fix, and publish information about security vulnerabilities in this repository by drafting a new
10-
[security advisory](https://github.com/osinfra-io/terraform-kubernetes-datadog-operator/security/advisories/new).
10+
[security advisory](https://github.com/osinfra-io/opentofu-kubernetes-datadog-operator/security/advisories/new).
1111

1212
<!-- This file is managed by the osinfra-io/github-organization-management repository and should not be edited directly. -->

empty.tofu

Whitespace-only changes.

regional/README.md

Lines changed: 2 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,3 @@
1-
# Terraform Documentation
1+
# OpenTofu Documentation
22

3-
A child module automatically inherits its parent's default (un-aliased) provider configurations. The provider versions below are informational only and do **not** need to align with the provider configurations from its parent.
4-
5-
<!-- BEGIN_TF_DOCS -->
6-
## Requirements
7-
8-
No requirements.
9-
10-
## Providers
11-
12-
| Name | Version |
13-
|------|---------|
14-
| <a name="provider_helm"></a> [helm](#provider\_helm) | 3.0.2 |
15-
| <a name="provider_kubernetes"></a> [kubernetes](#provider\_kubernetes) | 2.37.1 |
16-
17-
## Modules
18-
19-
| Name | Source | Version |
20-
|------|--------|---------|
21-
| <a name="module_helpers"></a> [helpers](#module\_helpers) | github.com/osinfra-io/terraform-core-helpers//child | v0.1.2 |
22-
23-
## Resources
24-
25-
| Name | Type |
26-
|------|------|
27-
| [helm_release.datadog_operator](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource |
28-
| [kubernetes_secret_v1.datadog_operator_secret](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/secret_v1) | resource |
29-
30-
## Inputs
31-
32-
| Name | Description | Type | Default | Required |
33-
|------|-------------|------|---------|:--------:|
34-
| <a name="input_agent_namespace"></a> [agent\_namespace](#input\_agent\_namespace) | Namespace for the Datadog Agent | `string` | `"datadog"` | no |
35-
| <a name="input_api_key"></a> [api\_key](#input\_api\_key) | Datadog API key | `string` | n/a | yes |
36-
| <a name="input_app_key"></a> [app\_key](#input\_app\_key) | Datadog APP key | `string` | n/a | yes |
37-
| <a name="input_cluster_prefix"></a> [cluster\_prefix](#input\_cluster\_prefix) | Prefix for your cluster name, region, and zone (if applicable) will be added to the end of the cluster name | `string` | n/a | yes |
38-
| <a name="input_limits_cpu"></a> [limits\_cpu](#input\_limits\_cpu) | CPU limits for the Datadog Operator | `string` | `"200m"` | no |
39-
| <a name="input_limits_memory"></a> [limits\_memory](#input\_limits\_memory) | Memory limits for the Datadog Operator | `string` | `"64Mi"` | no |
40-
| <a name="input_operator_version"></a> [operator\_version](#input\_operator\_version) | The version of the Datadog Operator to install | `string` | `"2.11.1"` | no |
41-
| <a name="input_requests_cpu"></a> [requests\_cpu](#input\_requests\_cpu) | CPU requests for the Datadog Operator | `string` | `"100m"` | no |
42-
| <a name="input_requests_memory"></a> [requests\_memory](#input\_requests\_memory) | Memory requests for the Datadog Operator | `string` | `"32Mi"` | no |
43-
| <a name="input_watch_namespaces"></a> [watch\_namespaces](#input\_watch\_namespaces) | Restricts the Operator to watch its managed resources on specific namespaces - set to [""] to watch all namespaces | `list(string)` | <pre>[<br/> "datadog"<br/>]</pre> | no |
44-
45-
## Outputs
46-
47-
No outputs.
48-
<!-- END_TF_DOCS -->
3+
> A child module automatically inherits default (un-aliased) provider configurations from its parent. The provider versions below are informational only and do **not** need to align with the provider configurations from its parent.

regional/helm/datadog-operator.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
remoteConfiguration:
44
enabled: true
55

6-
# Base64 High Entropy String
7-
# checkov:skip=CKV_SECRET_6: False positive
86
apiKeyExistingSecret: datadog-operator-secret
97
appKeyExistingSecret: datadog-operator-secret
108

regional/helpers.tf

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)