This Terraform provider enables you to manage files and directories on remote servers via SSH. It provides resources to create, read, update, and delete files and directories on remote systems using SSH authentication.
- Create, read, update, and delete files on remote servers
- Create and manage directories on remote servers
- Secure SSH authentication using various methods (password, private key)
- Support for file permissions and ownership
- Telemetry integration using OpenTelemetry
- Robust error handling and logging
- Comprehensive test coverage
- Go 1.22 or higher
- Terraform 1.0 or higher
- MacOS, Linux, BSD or other *nix platforms where the file system is capable of understanding file permissions (unlike Windows)
terraform {
required_providers {
ssh = {
source = "askrella/ssh"
version = "0.1.0"
}
}
}
- Clone the repository
git clone https://github.com/askrella/askrella-ssh-provider.git
- Enter the repository directory
cd askrella-ssh-provider
- Build the provider
go build -o terraform-provider-askrella-ssh
terraform {
required_providers {
ssh = {
source = "askrella/ssh"
version = "0.1.0"
}
}
}
provider "ssh" {}
locals {
ssh_config = {
host = "example.com"
port = 22
username = "user"
password = "your-password" # or use private_key
# private_key = file("~/.ssh/id_rsa")
}
}
# Create a directory on a remote server
resource "ssh_directory" "example_dir" {
ssh = local.ssh_config
path = "/path/to/directory"
permissions = "0755"
}
# Create a file in the directory
resource "ssh_file" "example_file" {
ssh = local.ssh_config
path = "${ssh_directory.example_dir.path}/example.txt"
content = "Hello, World!"
permissions = "0644"
depends_on = [ssh_directory.example_dir]
}
- Go 1.22 or higher
- Terraform 1.0 or higher
- golangci-lint for code linting
go build
The project uses Go's testing framework with Gomega matchers. Tests are designed to run in parallel and are isolated from each other.
# Run all tests
go test -v ./...
# Run tests with race detection
go test -race -v ./...
# Run tests with coverage
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out
This provider integrates with OpenTelemetry for distributed tracing and monitoring. Traces are automatically created for provider operations and can be exported to your preferred observability backend.
The project maintains high code quality standards through:
- Comprehensive test coverage
- Static code analysis using golangci-lint
- Mutation testing
- Continuous Integration via GitHub Actions
- Automated dependency updates via Dependabot
To use a locally built version of the provider:
- Build the provider as described above
- Configure your Terraform project to use the local provider:
terraform {
required_providers {
ssh = {
source = "askrella/ssh"
}
}
}
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch
- Commit your changes with descriptive commit messages
- Add tests for any new functionality
- Create a pull request
Please ensure your code:
- Passes all tests
- Includes appropriate documentation
- Follows the project's code style
- Includes relevant test cases
This project is licensed under the MIT License - see the LICENSE file for details.