swap out references to terraform to opentofu
This commit is contained in:
parent
a3097779e2
commit
b3d1f13db9
|
@ -26,10 +26,8 @@ crash.*.log
|
|||
# Ignore local .tfvars
|
||||
*.tfvars
|
||||
|
||||
# generated terraform files
|
||||
# generated opentofu files
|
||||
*.json
|
||||
|
||||
# Ignore CLI configuration files
|
||||
*.tfrc
|
||||
.terraformrc
|
||||
terraform.rc
|
||||
|
|
|
@ -35,10 +35,8 @@ override.tf.json
|
|||
# Include override files you do wish to add to version control using negated pattern
|
||||
# !example_override.tf
|
||||
|
||||
# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
|
||||
# Include tfplan files to ignore the plan output of command: tofu plan -out=tfplan
|
||||
*tfplan*
|
||||
|
||||
# Ignore CLI configuration files
|
||||
*.tfrc
|
||||
.terraformrc
|
||||
terraform.rc
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# terraform
|
||||
# tofu
|
||||
|
||||
Contains [Terraform](https://terraform.io/) code used to manage our infrastructure, Nix'ified for [Terranix](https://terranix.org/).
|
||||
Contains [OpenTofu](https://opentofu.org/) code used to manage our infrastructure, Nix'ified for [Terranix](https://terranix.org/).
|
||||
|
||||
## Prerequisites
|
||||
|
||||
|
@ -97,7 +97,7 @@ Contains [Terraform](https://terraform.io/) code used to manage our infrastructu
|
|||
|
||||
### Configuring
|
||||
|
||||
Create a file `terraform.tfvars` containing override for any Terraform variables, e.g.:
|
||||
Create a file `.auto.tfvars` containing override for any OpenTofu variables, e.g.:
|
||||
|
||||
```tfvars
|
||||
hcloud_location = "nbg1"
|
||||
|
|
12
flake.nix
12
flake.nix
|
@ -19,7 +19,7 @@
|
|||
inputs.flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
terraformConfiguration = inputs.terranix.lib.terranixConfiguration {
|
||||
tfConfig = inputs.terranix.lib.terranixConfiguration {
|
||||
inherit system;
|
||||
modules = [
|
||||
inputs.terranix-hcloud.terranixModules.hcloud
|
||||
|
@ -29,7 +29,7 @@
|
|||
tf = "${pkgs.opentofu}/bin/tofu";
|
||||
in
|
||||
{
|
||||
defaultPackage = terraformConfiguration;
|
||||
defaultPackage = tfConfig;
|
||||
|
||||
# Auto formatters. This also adds a flake check to ensure that the
|
||||
# source tree was auto formatted.
|
||||
|
@ -59,14 +59,14 @@
|
|||
apps = let
|
||||
tfCommand = cmd: ''
|
||||
if [[ -e config.tf.json ]]; then rm -f config.tf.json; fi;
|
||||
export TERRAFORM_CLOUD_TOKEN=$(${pkgs.sops}/bin/sops -d --extract '["tf_cloud_token"]' secrets.enc.yaml)
|
||||
export TF_CLOUD_TOKEN=$(${pkgs.sops}/bin/sops -d --extract '["tf_cloud_token"]' secrets.enc.yaml)
|
||||
export TF_CLI_CONFIG_FILE="ci.tfrc"
|
||||
cat << EOF > "$TF_CLI_CONFIG_FILE"
|
||||
credentials "app.terraform.io" {
|
||||
token = "$TERRAFORM_CLOUD_TOKEN"
|
||||
token = "$TF_CLOUD_TOKEN"
|
||||
}
|
||||
EOF
|
||||
cp ${terraformConfiguration} config.tf.json \
|
||||
cp ${tfConfig} config.tf.json \
|
||||
&& ${tf} init \
|
||||
&& ${tf} ${cmd}
|
||||
'';
|
||||
|
@ -86,7 +86,7 @@
|
|||
destroy = ''
|
||||
${tfCommand "destroy"}
|
||||
rm ${toString ./.}/config.tf.json
|
||||
rm ${toString ./.}/terraform.tfstate*
|
||||
rm ${toString ./.}/*.tfstate*
|
||||
rm ${toString ./.}/secrets.yaml
|
||||
rm ${toString ./.}/ci.tfrc
|
||||
'';
|
||||
|
|
Loading…
Reference in New Issue