Installing the Terraform Scaffolder Plugin#
This guide will help you install and set up the Terraform Scaffolder plugin in your Backstage instance.
Prerequisites#
- Backstage application
- Node.js and npm/yarn
- Access to Terraform modules (e.g., GitHub repositories, Terraform Registry)
- GitHub token (if using private repositories)
Installation Steps#
- Install the plugin package:
- Register the plugin in your Backstage app:
// packages/app/src/apis.ts
import { terraformScaffolderPlugin } from '@backstage/plugin-terraform-scaffolder';
export const apis = [
// ... other APIs
terraformScaffolderPlugin,
];
- Configure the plugin in your
app-config.yaml
:
terraformScaffolder:
# Enable proxy support for private GitHub repositories
useProxyForGitHub: true
# Registry module configuration (optional)
registryReferences:
returnAllVersions: true
namespaces:
- terraform-aws-modules
- vmware
# Direct module references
moduleReferences:
- name: 'AWS ECR Module'
url: 'https://github.com/terraform-aws-modules/terraform-aws-ecr'
refs:
- 'v3.1.0'
description: 'AWS ECR Module'
- If using private GitHub repositories, configure the proxy:
proxy:
endpoints:
'/github-raw':
target: 'https://raw.githubusercontent.com'
changeOrigin: true
headers:
Authorization: 'Token ${GITHUB_TOKEN}'
- Add the field extension to your template:
apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
name: terraform-infrastructure
title: Create Infrastructure
spec:
parameters:
- title: Infrastructure
properties:
infrastructure:
title: Terraform Module
type: string
ui:field: TerraformModule
Verification#
To verify the installation:
- Navigate to your software templates
- Create a new component using a template with the TerraformModule field
- Verify that you can:
- Select from available modules
- Choose module versions
- Configure module variables
- See validation messages
- Submit the form successfully
- Access private repositories (if configured)
Troubleshooting#
Common issues and solutions:
- Module Not Found
- Check module URL in app-config.yaml
- Verify GitHub access permissions
- Check module ref/branch exists
-
Verify registry namespace configuration
-
Private Repository Access
- Check GitHub token permissions
- Verify proxy configuration
- Ensure useProxyForGitHub is enabled
-
Check proxy endpoint headers
-
Type Errors
- Ensure all required API dependencies are installed
- Check for version mismatches
-
Verify type definitions in variables.tf
-
Form Validation Errors
- Verify variables.tf exists in module
- Check variable type definitions
- Ensure version references are correct
Next Steps#
After installation:
- Configure your module sources:
- Add configuration-based modules
- Set up catalog-based modules
-
Configure registry integration
-
Set up security:
- Configure private repository access
- Set up proxy settings
-
Manage GitHub tokens
-
Create and test templates:
- Create templates using the TerraformModule field
- Test with different module versions
-
Verify variable handling
-
Plan for production:
- Set up CI/CD for your Terraform deployments
- Document module usage
- Plan version management strategy
For detailed configuration options, see the Configuration guide.