Go to : https://developer.hashicorp.com/terraform/downloads
Follow instructions for Ubuntu/Debian except you need to hardcode the $(lsb_release -cs)
part as given for debian and other distributions.
The given commands work:
sudo apt install gpg
wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg
Check if it is correct :
gpg --no-default-keyring --keyring /usr/share/keyrings/hashicorp-archive-keyring.gpg --fingerprint
Then do :
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com bookworm main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
Notice the word bookworm
List of words for hardcoding can be found on : https://www.hashicorp.com/official-packaging-guide
The original solution was posted here : https://discuss.hashicorp.com/t/apt-install-terraform-fails-as-per-docs/29690/5
The instructions to install terraform mentioned above were taken from : https://stackoverflow.com/a/75254686