This Terraform provider allows you to manage pastebin pastes as infrastructure resources.
- Create pastes with various options (expiration, formatting, compression, etc.)
- Read existing pastes using data sources
- Support for attachments and password-protected pastes
- Burn-after-reading functionality
- Discussion/comments support
Add the provider to your Terraform configuration:
terraform {
required_providers {
pastebin = {
source = "RO-29/pastebin"
version = "~> 1.0"
}
}
}-
Clone the repository:
git clone https://github.com/RO-29/terraform-provider-pastebin.git cd terraform-provider-pastebin -
Build the provider:
make build
-
Install locally for development:
make install-terraform-provider
The provider supports the following configuration options:
provider "pastebin" {
host = "https://pastebin.example.tech" # Required
username = var.pastebin_username # Optional: for authenticated instances
password = var.pastebin_password # Optional: for authenticated instances
skip_tls_verify = false # Optional: skip TLS verification
user_agent = "terraform-provider-pastebin" # Optional: custom user agent
# Extra HTTP headers
extra_headers = {
"X-Custom-Header" = "value"
}
# Default settings for resources
expire = "1week"
formatter = "plaintext"
gzip = true
open_discussion = false
burn_after_reading = false
}You can also configure the provider using environment variables:
PASTEBIN_HOST- Pastebin instance host URLPASTEBIN_USERNAME- Username for authenticationPASTEBIN_PASSWORD- Password for authentication
Creates and manages a pastebin paste.
resource "pastebin_paste" "example" {
content = "Hello, World!"
formatter = "plaintext"
expire = "1day"
password = "secret123"
open_discussion = true
burn_after_reading = false
gzip = true
}content(Required, String) - The content of the pasteattachment_name(Optional, String) - Name for the attachment (makes the paste an attachment)formatter(Optional, String) - Text formatter:plaintext,markdown,syntaxhighlightingexpire(Optional, String) - Expiration time:5min,10min,1hour,1day,1week,1month,1year,neverpassword(Optional, String, Sensitive) - Password to protect the pasteopen_discussion(Optional, Boolean) - Enable discussion/comments on the pasteburn_after_reading(Optional, Boolean) - Delete the paste after first readgzip(Optional, Boolean) - Enable gzip compression
id(String) - Paste identifierurl(String) - URL of the created pastedelete_token(String, Sensitive) - Delete token for the paste
Reads an existing pastebin paste.
data "pastebin_paste" "existing" {
url = "https://pastebin.example.tech/?abcd1234#EezApNVTTRUuEkt1jj7r9vSfewLBvUohDSXWuvPEs1bF"
password = "secret123" # Optional: if password protected
confirm_burn = true # Optional: confirm reading burn-after-reading pastes
}url(Required, String) - Full URL of the paste including master keypassword(Optional, String, Sensitive) - Password to decrypt the pasteconfirm_burn(Optional, Boolean) - Confirm reading a burn-after-reading paste (will delete it)
id(String) - Paste identifiercontent(String) - The content of the pasteattachment_name(String) - Name of the attachment (if paste is an attachment)attachment_data(String, Sensitive) - Base64 encoded attachment datamime_type(String) - MIME type of attachmentcomment_count(Number) - Number of comments on the paste
See the examples directory for complete usage examples.
resource "pastebin_paste" "example" {
content = "Hello, Terraform!"
expire = "1day"
}
output "paste_url" {
value = pastebin_paste.example.url
}resource "pastebin_paste" "code" {
content = file("${path.module}/script.py")
formatter = "syntaxhighlighting"
expire = "1month"
}resource "pastebin_paste" "secret" {
content = "Sensitive information"
password = var.paste_password
expire = "1hour"
burn_after_reading = true
}data "pastebin_paste" "existing" {
url = "https://pastebin.example.tech/?id#key"
}
output "content" {
value = data.pastebin_paste.existing.content
}# Store application configuration
resource "pastebin_paste" "app_config" {
content = jsonencode({
environment = var.environment
database_url = var.database_url
api_keys = {
stripe = var.stripe_api_key
}
})
password = var.config_password
expire = "1month"
burn_after_reading = false
formatter = "syntaxhighlighting"
}
# Retrieve and use the configuration
data "pastebin_paste" "current_config" {
url = pastebin_paste.app_config.url
password = var.config_password
}
locals {
config = jsondecode(data.pastebin_paste.current_config.content)
}# Upload build logs
resource "pastebin_paste" "build_log" {
content = file("${path.module}/build.log")
attachment_name = "build-${timestamp()}.log"
expire = "1week"
open_discussion = true
gzip = true
}
# Share compressed archives
resource "pastebin_paste" "release_archive" {
content = filebase64("${path.module}/dist/app-v${var.version}.tar.gz")
attachment_name = "app-v${var.version}.tar.gz"
expire = "1year"
}-
Clone the repository:
git clone https://github.com/RO-29/terraform-provider-pastebin.git cd terraform-provider-pastebin -
Build the provider:
make build
-
Install locally for testing:
make install-terraform-provider
-
Run tests:
make test # Unit tests make test-coverage # With coverage report make testacc # Acceptance tests (requires TF_ACC=1)
After making changes, test with a minimal Terraform configuration:
terraform {
required_providers {
pastebin = {
source = "RO-29/pastebin"
}
}
}
provider "pastebin" {
host = "https://pastebin.example.tech"
}
resource "pastebin_paste" "test" {
content = "Test paste from Terraform!"
expire = "1day"
}
output "paste_url" {
value = pastebin_paste.test.url
}-
Provider not found: Ensure you've specified the correct source in your
required_providersblock:terraform { required_providers { pastebin = { source = "RO-29/pastebin" version = "~> 1.0" } } }
-
Authentication errors: Verify your host URL and credentials:
- Check that
PASTEBIN_HOSTenvironment variable orhostprovider attribute is set correctly - For authenticated instances, ensure
PASTEBIN_USERNAMEandPASTEBIN_PASSWORDare set
- Check that
-
TLS certificate errors: For self-hosted pastebin instances with self-signed certificates:
provider "pastebin" { host = "https://pastebin.internal.company.com" skip_tls_verify = true # Use only for testing/development }
-
Build issues: If you encounter build problems:
- Ensure Go 1.23+ is installed
- Check that all dependencies are available:
go mod download - Clean build artifacts:
make clean && make build
- Check existing issues
- Review the pastebin-go-cli documentation for API-related questions
- Create a new issue with:
- Terraform version (
terraform version) - Provider version
- Minimal reproduction case
- Full error messages
- Terraform version (
This project is licensed under the same terms as the pastebin-go-cli library it depends on.