Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions src/terraform/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Installs the Terraform CLI and optionally TFLint and Terragrunt. Auto-detects la
| installSentinel | Install sentinel, a language and framework for policy built to be embedded in existing software to enable fine-grained, logic-based policy decisions | boolean | false |
| installTFsec | Install tfsec, a tool to spot potential misconfigurations for your terraform code | boolean | false |
| installTerraformDocs | Install terraform-docs, a utility to generate documentation from Terraform modules | boolean | false |
| terraformDocsVersion | terraform-docs version to install (only used when installTerraformDocs is true) (https://github.com/terraform-docs/terraform-docs/releases) | string | latest |
| httpProxy | Connect to a keyserver using a proxy by configuring this option | string | - |
| customDownloadServer | Custom server URL for downloading Terraform and Sentinel packages, including protocol (e.g., https://releases.hashicorp.com). If not provided, the default HashiCorp download server (https://releases.hashicorp.com) will be used. | string | - |

Expand Down
12 changes: 11 additions & 1 deletion src/terraform/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "terraform",
"version": "1.4.5",
"version": "1.5.0",
"name": "Terraform, tflint, and TFGrunt",
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/terraform",
"description": "Installs the Terraform CLI and optionally TFLint and Terragrunt. Auto-detects latest version and installs needed dependencies.",
Expand Down Expand Up @@ -50,6 +50,16 @@
"default": false,
"description": "Install terraform-docs, a utility to generate documentation from Terraform modules"
},
"terraformDocsVersion": {
"type": "string",
"proposals": [
"latest",
"0.20.0",
"0.19.0"
],
"default": "latest",
"description": "terraform-docs version to install (only used when installTerraformDocs is true) (https://github.com/terraform-docs/terraform-docs/releases)"
},
"httpProxy": {
"type": "string",
"default": "",
Expand Down
2 changes: 1 addition & 1 deletion src/terraform/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ TERRAGRUNT_VERSION="${TERRAGRUNT:-"latest"}"
INSTALL_SENTINEL=${INSTALLSENTINEL:-false}
INSTALL_TFSEC=${INSTALLTFSEC:-false}
INSTALL_TERRAFORM_DOCS=${INSTALLTERRAFORMDOCS:-false}
TERRAFORM_DOCS_VERSION="${TERRAFORMDOCSVERSION:-"latest"}"
CUSTOM_DOWNLOAD_SERVER="${CUSTOMDOWNLOADSERVER:-""}"
# This is because ubuntu noble, ubuntu resolute and debian trixie don't support the old format of GPG keys and validation
NEW_GPG_CODENAMES="trixie noble resolute"
Expand Down Expand Up @@ -641,7 +642,6 @@ install_terraform_docs() {
}

if [ "${INSTALL_TERRAFORM_DOCS}" = "true" ]; then
TERRAFORM_DOCS_VERSION="latest"
terraform_docs_url='https://github.com/terraform-docs/terraform-docs'
find_version_from_git_tags TERRAFORM_DOCS_VERSION $terraform_docs_url
tfdocs_filename="terraform-docs-v${TERRAFORM_DOCS_VERSION}-linux-${architecture}.tar.gz"
Expand Down
18 changes: 18 additions & 0 deletions test/terraform/install_terraform_docs_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

set -e

# Import test library for `check` command
source dev-container-features-test-lib

# Check to make sure the user is vscode
check "user is vscode" whoami | grep vscode

# Terraform Docs specific tests
check "terraform-docs" terraform-docs --version

# Verify the pinned version was installed
check "terraform-docs version is pinned to 0.20.0" bash -c "terraform-docs --version | grep 'v0.20.0'"

# Report result
reportResults
9 changes: 9 additions & 0 deletions test/terraform/scenarios.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@
}
}
},
"install_terraform_docs_version": {
"image": "mcr.microsoft.com/devcontainers/base:jammy",
"features": {
"terraform": {
"installTerraformDocs": true,
"terraformDocsVersion": "0.20.0"
}
}
},
"terraform_docs_fallback_test": {
"image": "mcr.microsoft.com/devcontainers/base:jammy",
"features": {
Expand Down
Loading