Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: lock terraform version to 1.4.6 #233

Merged
merged 3 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion database-grants/terraform/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Prerequisites

- Terraform 1.4.6 , please stick to this version for now, tested 1.6.x, it brings issue with the Dititalocean storage as backend
- Ensure you have `tfenv` installed in your system. https://github.com/tfutils/tfenv

- The terraform configuration in this directory requires to have `terraform` binary version to be minimum 1.4.6 Ref: https://developer.hashicorp.com/terraform/tutorials/configuration-language/versions#review-example-configuration





# How to set up terraform
Expand All @@ -22,6 +27,21 @@ source setup_keys.sh

# How to run terraform

Use correct version:
```bash
tfenv use min-required
```
OR if you configure `.terraform-version`

```bash
echo "1.4.6" > .terraform-version
tfenv use # this will configure the correct version from .terraform-version file
```

```bash
terraform version # check if the version matches with the required_version in provider.tf
```

Init:

```bash
Expand Down
3 changes: 3 additions & 0 deletions database-grants/terraform/dev/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ variable "password" {
}

terraform {
# Ref: https://developer.hashicorp.com/terraform/tutorials/configuration-language/versions#review-example-configuration
required_version = "~> 1.4.6"

required_providers {
postgresql = {
source = "cyrilgdn/postgresql"
Expand Down
5 changes: 4 additions & 1 deletion database-grants/terraform/dev/setup_keys.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
# Retrieve keys from your netrc, specified as
# machine sfo2.digitaloceanspaces.com login KEY password SECRET
# Source this file before running terraform commands
netrc_string=$(grep digitalocean.dev.treetracker.org ~/.netrc)

grep_string=$(cat backend.tf | grep endpoint | awk -F'=' '{print $2}' | awk -F'/' '{print $NF}' | sed 's/"//g')

netrc_string=$(grep ${grep_string} ~/.netrc)
sanketnadkarni marked this conversation as resolved.
Show resolved Hide resolved
export AWS_ACCESS_KEY_ID=$(echo $netrc_string | awk '{print $4}')
export AWS_SECRET_ACCESS_KEY=$(echo $netrc_string | awk '{print $6}')
2 changes: 1 addition & 1 deletion database-grants/terraform/prod/backend.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ terraform {
skip_credentials_validation = true
# skip_get_ec2_platforms = true
skip_requesting_account_id = true
skip_metadata_api_check = true
skip_metadata_api_check = true
}
}
Loading