Terraform Archive Provider - Create ZIP and TAR Files
Use the Terraform archive provider to create ZIP files for Lambda functions, Cloud Functions, and deployments. archive_file data source with source_dir and...
Terraform
Use the Terraform random provider to generate unique names, passwords, IDs, and UUIDs. Prevent naming conflicts and create secure credentials in your...
resource "random_id" "suffix" {
byte_length = 4
}
resource "aws_s3_bucket" "data" {
bucket = "myapp-data-${random_id.suffix.hex}" # e.g., myapp-data-a1b2c3d4
}resource "random_id" "db" {
byte_length = 4
}
# random_id.db.hex → "a1b2c3d4"
# random_id.db.b64_std → "obLDfA=="
# random_id.db.dec → "2712847316"resource "random_string" "suffix" {
length = 8
special = false
upper = false
}
# random_string.suffix.result → "k7m2x9np"resource "random_password" "db" {
length = 32
special = true
override_special = "!#$%^&*()-_=+[]{}|:,.<>?"
}
resource "aws_db_instance" "main" {
password = random_password.db.result # Marked sensitive automatically
}
# Store in Parameter Store or Secrets Manager
resource "aws_ssm_parameter" "db_password" {
name = "/${var.project}/db-password"
type = "SecureString"
value = random_password.db.result
}resource "random_integer" "az" {
min = 0
max = 2
}
# Use for random AZ selectionresource "random_uuid" "correlation" {}
# random_uuid.correlation.result → "550e8400-e29b-41d4-a716-446655440000"resource "random_pet" "server" {
length = 2
separator = "-"
}
# random_pet.server.id → "fluffy-cat"resource "random_shuffle" "azs" {
input = ["us-east-1a", "us-east-1b", "us-east-1c"]
result_count = 2
}
# random_shuffle.azs.result → ["us-east-1c", "us-east-1a"]resource "random_password" "db" {
length = 32
special = true
keepers = {
rotation_date = "2025-01-01" # Change this to rotate password
}
}
resource "random_id" "bucket" {
byte_length = 4
keepers = {
environment = var.environment # New ID per environment
}
}# Globally unique S3 bucket name
resource "random_id" "bucket" {
byte_length = 4
}
resource "aws_s3_bucket" "data" {
bucket = "${var.project}-${var.env}-${random_id.bucket.hex}"
}
# Azure Storage Account (lowercase alphanum only, 3-24 chars)
resource "random_string" "storage" {
length = 8
special = false
upper = false
}
resource "azurerm_storage_account" "main" {
name = "${var.project}${random_string.storage.result}"
}
# Unique resource group suffix
resource "random_pet" "env" {
length = 2
}keepers to control when values regeneraterandom_password is automatically marked sensitiveUse random_id for unique suffixes on globally-named resources (S3, Storage Accounts), random_password for secure credentials, and keepers to control rotation. Random values persist in state — they only change when you modify keepers or taint the resource.
Use the Terraform archive provider to create ZIP files for Lambda functions, Cloud Functions, and deployments. archive_file data source with source_dir and...
Automate Terraform with Azure DevOps Pipelines. YAML pipelines, service connections, environment approvals, and Azure backend state configuration.
Automate Terraform with GitHub Actions. Plan on PR, apply on merge, OIDC authentication, environment protection, and drift detection workflows.
Automate Terraform with GitLab CI/CD. Plan on merge requests, apply on main, remote state with HTTP backend, and environment-specific pipelines.