vault module configures HashiCorp Vault with KV secrets storage, GitHub and AWS authentication backends, team-based access policies, and integrations for secret synchronization and Grafana.
Overview
This module provisions:- KV v2 secrets engine for storing application secrets
- GitHub authentication backend with team-based access
- AWS authentication backend for service accounts
- Vault policies for admin, secret-sync, and team-sync roles
- Grafana secrets configuration with OAuth integration
- IAM role bindings for Kubernetes service accounts
Input Variables
GitHub Client ID for the Penn Labs Grafana OAuth2 Application. Used to configure Grafana’s GitHub authentication.
GitHub Client Secret for the Penn Labs Grafana OAuth2 Application. Stored securely in Vault for Grafana to authenticate users.
Slack notification URL used for Grafana notifications. Enables Grafana to send alerts to Slack channels.
Role ARN for the secret-sync service account. This IAM role is used to authenticate the secret synchronization service with Vault via AWS auth.
Role ARN for the team-sync service account. This IAM role is used to authenticate the team synchronization service with Vault via AWS auth.
Outputs
The mount path of the KV secrets engine. Use this path to reference secrets stored in Vault (e.g.,
secrets/production/app-name).Resources Provisioned
Secrets Engine
secrets/. KV v2 provides versioning and metadata for all secrets.
Authentication Backends
AWS Authentication
GitHub Authentication
pennlabs organization and maps the sre team to admin policies.
Policies
Admin Policy
Secret Sync Policy
Team Sync Policy
Grafana Configuration
- Admin credentials
- GitHub OAuth client credentials
- Slack notification webhook URL
Usage Example
Module Structure
The module is organized into specialized files:main.tf: Core Vault resources (secrets engine, auth backends, policies)grafana.tf: Grafana-specific secret configurationsecret-sync.tf: Secret synchronization policy and AWS auth roleteam-sync.tf: Team synchronization policy and AWS auth rolevariables.tf: Input variable definitionsoutputs.tf: Output valuespolicies/: Directory containing HCL policy templates
Dependencies
This module requires:- HashiCorp Vault provider configured
- Vault server running and accessible
- IAM roles created for secret-sync and team-sync (typically from the
iammodule) - GitHub organization access for authentication
- AWS authentication configured in Vault
Notes
- The Grafana admin password is randomly generated with 64 alphanumeric characters
- All secrets are stored in KV v2, which provides automatic versioning
- The SRE team from the
pennlabsGitHub organization gets admin access - AWS auth roles use
bound_iam_principal_arnsto restrict access to specific IAM roles - Policy templates use the
PATHvariable to reference the secrets mount path dynamically