Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/Excoriate/daggerverse/terragrunt

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/Excoriate/daggerverse/terragrunt

  • v0.21.0
  • Source
  • Go
  • Socket score

Version published
Created
Source

Terragrunt Module for Dagger

A powerful Dagger module for managing Terragrunt, Terraform, and OpenTofu operations in a containerized environment.

Features 🎨

FeatureDescription
🛠️ Flexible Base ImageBuilt using APKO for a secure and optimized container environment.
🔧 Multi-Tool SupportPrimarily focused on Terragrunt, but also supports Terraform and OpenTofu.
⚙️ Customizable ConfigurationsExtensive options for Terragrunt and Terraform settings.
💾 Caching MechanismsImplements caching for Terragrunt and Terraform for improved performance.
☁️ AWS CLI IntegrationOption to include AWS CLI in the container.
🔐 Permissions ManagementFine-grained control over directory permissions.
🌐 Environment Variable HandlingEasy setting and management of environment variables.
🔒 Secret ManagementSecure handling of sensitive information like Terraform tokens.
🚀 Execution FlexibilityRun Terragrunt, Terraform, or shell commands within the container.

Terragrunt Batteries Included 🔋

FeatureDescription
🛠️ Terragrunt, Terraform, and OpenTofu binariesPre-installed binaries for Terragrunt, Terraform, and OpenTofu.
📄 Terragrunt ConfigurationBest practice configuration files for Terragrunt.
⚙️ Terragrunt OptionsConfigurable options for Terragrunt (see terragrunt_opts.go).
🔧 Directory PermissionsManage directory permissions (see terragrunt_cfg.go).
💾 Caching ConfigurationSetup caching for Terragrunt and Terraform (see terragrunt_cfg.go).
🌐 Environment VariablesHandle environment variables for Terragrunt (see terragrunt_opts.go).
🔐 Secret ManagementSecure handling of sensitive information like Terraform tokens.

Configuration 🛠️

Base Container Options

  • ctr: Specify a custom base container.
  • imageURL: Specify a custom base image URL.
  • tgVersion: Set the version of Terragrunt (default: 0.68.1).
  • tfVersion: Set the version of Terraform (default: 1.9.5).
  • openTofuVersion: Set the version of OpenTofu (default: 1.8.2).
  • enableAWSCLI: Enable or disable the installation of the AWS CLI (default: false).
  • awscliVersion: Set the version of the AWS CLI to install (default: 2.15.1).
  • extraPackages: A list of extra packages to install with APKO, from the Alpine packages repository (default: []).

IaC Tool Versions

  • Terragrunt, Terraform, and OpenTofu versions can be specified or will use defaults.

Permissions and Caching

  • Configure directory permissions and set up caching for Terragrunt and Terraform.

Environment and Secrets

  • Set environment variables and manage secrets securely.

Usage Examples 🚀

Basic Terragrunt Execution

	testEnvVars := []string{
		"AWS_ACCESS_KEY_ID=test",
		"AWS_SECRET_ACCESS_KEY=test",
		"AWS_SESSION_TOKEN=test",
	}

	// Initialize the Terragrunt module
	tgModule := dag.
		Terragrunt(dagger.TerragruntOpts{
			EnvVarsFromHost: testEnvVars,
		}).
		WithTerragruntPermissionsOnDirsDefault().
		WithTerragruntLogOptions(
			dagger.TerragruntWithTerragruntLogOptionsOpts{
				TgLogLevel:        "debug",
				TgForwardTfStdout: true,
			},
		)

	// Execute the init command, but don't run it in a container
	tgCtrConfigured := tgModule.
		Exec("init", dagger.TerragruntExecOpts{
			Source: m.getTestDir("").
				Directory("terragrunt"),
		})

	// Evaluate the terragrunt init command.
	tgInitCmdOut, tgInitCmdErr := tgCtrConfigured.
		Stdout(ctx)

Running Terragrunt with Custom Options

	tgModule := dag.
		Terragrunt(dagger.TerragruntOpts{
			EnvVarsFromHost: testEnvVars,
			TfVersion:       "1.7.0",
		}).
		WithTerragruntPermissionsOnDirsDefault().
		WithTerragruntLogOptions(dagger.TerragruntWithTerragruntLogOptionsOpts{
			TgLogDisableFormatting: true,
			TgLogShowAbsPaths:      true,
			TgLogLevel:             "debug",
		}).
		WithTerraformLogOptions(dagger.TerragruntWithTerraformLogOptionsOpts{
			TfLog:     "debug",
			TfLogPath: "/mnt/tflogs", // it's a directory that the terragrunt user owns.
		}).
		// Extra options added for more realism.
		WithTerragruntOptions(dagger.TerragruntWithTerragruntOptionsOpts{
			IgnoreDependencyErrors:     true,
			IgnoreExternalDependencies: true,
			DisableBucketUpdate:        true,
		})

	// Execute the plan command and get the container back.
	tgCtr := tgModule.Exec("plan", dagger.TerragruntExecOpts{
		Source: m.
			getTestDir("").
			Directory("terragrunt"),
		Secrets: []*dagger.Secret{
			dbPasswordSecret,
			apiKeySecret,
			sshKeySecret,
		},
		// Args to output the plan to a file.
		Args: []string{
			"-out=plan.tfplan",
			"-refresh=true",
		},
	})


Testing 🧪

The module includes comprehensive tests covering various aspects of functionality. You can run these tests using:

just test terragrunt

Developer Experience 🛠️

To contribute or modify the module:

  1. Use Just for task automation.
  2. Utilize Nix for managing the development environment.

Common commands:

just run-hooks           # Initialize pre-commit hooks
just lintall terragrunt  # Run linter
just test terragrunt    # Run tests
just ci terragrunt # Run entire CI tasks locally

APKO Base Image

This module uses APKO to build its base image, ensuring:

  • Enhanced security through minimal attack surface
  • Optimized container size and performance
  • Reproducible and declarative image builds

For more information on APKO, refer to the Chainguard APKO documentation.


For detailed API documentation and more examples, please refer to the source code and test files in the tests/ directory.

FAQs

Package last updated on 21 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc