agentleFS
dungnotnulldungnotnull/hybrid-harness-chaos-process-prm/skills/s07-secrets-management/SKILL.md

harness-secrets-management

Skill19 starsChanged 6 months agoMITView on GitHub

Create, reference, rotate, and audit secrets in Harness pipelines and configurations. Use this skill whenever the user asks about secrets, credentials, API keys, passwords, certificates, Vault integration, AWS Secrets Manager, KMS, GCP Secret Manager, Azure Key Vault, encrypted variables, or how to avoid hardcoding sensitive values in pipelines. Also trigger when a pipeline is leaking credentials in logs, or when the user needs to rotate a secret safely across multiple pipelines.

  • Reads credentials

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    When Harness AI is unavailable: Use static pipeline templates from s09 Template Library and manual YAML construction following Harness …

    line 335

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Harness Secrets Management

Purpose

Establish a zero-hardcoded-secret policy across all Harness resources. Every credential, API key, password, and certificate must flow through a secrets manager — never embedded in YAML, logs, or environment variables.


Input Contract

InputSourceRequired
Service definitions requiring secretss05 (workflow_context.artifacts)Yes
Secrets backend choices02 taste or userYes
Delegate connectivity infos06 outputYes
List of required secrets (DB, API keys, certs)s01 PRD or userYes

Output Contract

OutputDestinationFormat
Secret Manager connector YAML.commandcode/artifacts/secrets-manager.yamlYAML
Secret reference definitions.commandcode/artifacts/secrets-references.yamlYAML
Pre-commit hook script.git/hooks/pre-commitBash
Secret rotation runbooks25 (postmortem context)Markdown
Secret usage maps22 (governance audit)YAML

Prerequisites

  • Harness Account / Project access with Secrets Manager permissions
  • Choice of secrets backend: Harness Built-in / HashiCorp Vault / AWS SM / GCP SM / Azure KV
  • Delegate deployed with access to the chosen secrets backend (network path confirmed)

Secrets Architecture

External Secrets Backend           Harness Secret Manager Connector
(Vault / AWS SM / GCP SM)  ◄──────────────────────────────────────
         │                                       │
         │  Secret Value (never leaves infra)    │
         ▼                                       ▼
   Harness Secret Reference               Pipeline YAML
   secrets.getValue("my_key")     ←   <+secrets.getValue("my_key")>
         │
         ▼
   Delegate fetches at runtime → injects into step environment
   (masked in logs as ***)

Golden Rule: Harness never stores the actual secret value (when using external SM). It stores only the reference path. The delegate fetches the value at runtime, directly from your backend.


Supported Secret Manager Backends

BackendConnector TypeAuth Methods
Harness Built-inNativeAccount-level encryption
HashiCorp VaultHashiCorpVaultToken, AppRole, K8s Auth, AWS IAM
AWS Secrets ManagerAwsSecretManagerIAM Role (delegate), Access Key
AWS KMSAwsKmsIAM Role (delegate), Access Key
GCP Secret ManagerGcpSecretManagerService Account, Workload Identity
Azure Key VaultAzureKeyVaultService Principal, Managed Identity
CyberArkCyberArkApplication + Safe

Step 1 — Configure Secret Manager Connector

HashiCorp Vault (AppRole)

connector:
  name: HashiCorp Vault Prod
  identifier: vault_prod
  orgIdentifier: <ORG_ID>
  projectIdentifier: <PROJECT_ID>
  type: VaultConnector
  spec:
    authTokenRef: vault_auth_token_secret    # Bootstrap token only
    basePath: secret/data/harness            # Vault path prefix
    vaultUrl: https://vault.internal.company.com
    renewalIntervalMinutes: 10
    secretEngineManuallyConfigured: true
    secretEngineName: secret
    secretEngineVersion: 2
    useVaultAgent: false
    useAwsIam: false
    useK8sAuth: false
    appRoleId: <APP_ROLE_ID>
    secretId: vault_approle_secret_id        # Reference to bootstrap secret
    delegateSelectors:
      - prod-cluster

HashiCorp Vault (Kubernetes Auth — preferred for K8s delegates)

connector:
  name: Vault K8s Auth
  identifier: vault_k8s_auth
  type: VaultConnector
  spec:
    vaultUrl: https://vault.internal.company.com
    basePath: secret/data/harness
    useK8sAuth: true
    k8sAuthEndpoint: kubernetes
    vaultK8sAuthRole: harness-delegate-role
    serviceAccountTokenPath: /var/run/secrets/kubernetes.io/serviceaccount/token
    secretEngineManuallyConfigured: true
    secretEngineName: secret
    secretEngineVersion: 2
    renewalIntervalMinutes: 10
    delegateSelectors:
      - prod-cluster

AWS Secrets Manager (IAM Role on Delegate)

connector:
  name: AWS Secrets Manager Prod
  identifier: aws_sm_prod
  type: AwsSecretManager
  spec:
    region: us-east-1
    credential:
      type: AssumeIAMRole   # No access keys needed; uses delegate's EC2/pod role
    delegateSelectors:
      - aws-prod-delegate
    default: false

Step 2 — Create Secrets

Text Secret (API Key, Password)

secret:
  type: SecretText
  name: Stripe API Key
  identifier: stripe_api_key
  orgIdentifier: <ORG_ID>
  projectIdentifier: <PROJECT_ID>
  spec:
    secretManagerIdentifier: vault_prod
    valueType: Reference           # For external SM: path to secret
    value: "payment/stripe/api_key"  # Vault path (relative to basePath)

File Secret (TLS Cert, SSH Key, kubeconfig)

secret:
  type: SecretFile
  name: TLS Certificate
  identifier: tls_cert_pem
  spec:
    secretManagerIdentifier: vault_prod
    # Upload file via Harness API or UI

SSH Credential (Git, bastion access)

secret:
  type: SSHKey
  name: GitHub Deploy Key
  identifier: github_deploy_key
  spec:
    auth:
      type: SSH
      spec:
        credentialType: KeyReference
        spec:
          userName: git
          key: github_ssh_private_key    # Reference to file secret
          encryptedPassphrase: ""

Step 3 — Reference Secrets in Pipelines

In Step Environment Variables

step:
  type: Run
  spec:
    envVariables:
      STRIPE_API_KEY: <+secrets.getValue("stripe_api_key")>
      DB_PASSWORD: <+secrets.getValue("database_password")>
      JWT_SECRET: <+secrets.getValue("jwt_signing_secret")>
    command: |
      # $STRIPE_API_KEY is available here, masked as *** in logs
      ./deploy.sh

In Connector References

connector:
  spec:
    auth:
      spec:
        passwordRef: database_password    # Harness secret identifier

In Kubernetes Secrets via Pipeline

step:
  name: Sync K8s Secret
  type: ShellScript
  spec:
    shell: Bash
    source:
      type: Inline
      spec:
        script: |
          kubectl create secret generic app-secrets \
            --from-literal=STRIPE_KEY="<+secrets.getValue("stripe_api_key")>" \
            --from-literal=DB_PASS="<+secrets.getValue("database_password")>" \
            -n <+infra.namespace> \
            --dry-run=client -o yaml | kubectl apply -f -

Step 4 — Secret Rotation Workflow

1. Create new secret version in backend (Vault / AWS SM)
2. Update Harness secret reference (if path changed)
3. Test in dev environment first:
   - Run pipeline with new secret
   - Verify application accepts new credential
4. Roll to staging → verify
5. Roll to production:
   - Deploy new secret
   - Verify connections healthy
   - Revoke old secret version
6. Update rotation date in audit log

Zero-Downtime Rotation for Live Services

# Use a "shadow" secret approach:
# 1. App reads BOTH old and new secrets (grace period)
# 2. Deploy app with dual-secret support
# 3. Confirm old secret no longer used
# 4. Remove old secret from application config
# 5. Remove old secret from backend

Audit and Compliance

Find All Secret Usage in Project (API)

curl -X GET \
  "https://app.harness.io/gateway/ng/api/v2/secrets?accountIdentifier=<ACCOUNT>&projectIdentifier=<PROJECT>&orgIdentifier=<ORG>&pageSize=100" \
  -H "x-api-key: <HARNESS_API_KEY>" \
  | jq '.data.content[] | {identifier, name, secretManagerIdentifier, updatedAt}'

Detect Hardcoded Secrets in Pipeline YAML (pre-commit hook)

#!/bin/bash
# .git/hooks/pre-commit
# Block commits that contain hardcoded secrets in Harness YAML files

files=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.yaml$|\.yml$')

for file in $files; do
  # Check for patterns that suggest hardcoded secrets
  if grep -qE '(password|token|secret|key|apiKey)\s*:\s*["\x27][A-Za-z0-9+/]{20,}' "$file"; then
    echo "ERROR: Potential hardcoded secret in $file"
    echo "Use: <+secrets.getValue(\"your_secret_id\")> instead"
    exit 1
  fi
done

Secret Scope Hierarchy

Account-level secrets    → Available across all orgs and projects
    └── Org-level secrets     → Available across all projects in org
            └── Project-level secrets  → Available only in this project

Rule of thumb:

  • Infrastructure credentials (cloud provider) → Account level
  • Shared integration secrets (Slack, Jira) → Org level
  • Application secrets (DB passwords, API keys) → Project level

AI Agent Integration

Autonomy Level

AspectLevelDescription
CurrentL1AI suggests secret reference patterns and vault integration
TargetL2AI generates secret configs and vault integration templates

Harness AI Agent

Agent: Harness AI DevOps Agent Capabilities:

  • Secret reference creation via conversational prompts
  • Vault/AWS SM/GCP SM integration templates
  • Secret rotation policy suggestions

Human Gates

  • Secret creation
  • Access grant approval
  • Vault policy changes

Fallback

When Harness AI is unavailable: Use static pipeline templates from s09 Template Library and manual YAML construction following Harness schema documentation.


Success Criteria

  • Zero hardcoded secrets in any pipeline YAML
  • All secrets referencing external SM (not Harness built-in) for production
  • Secret rotation runbook documented and tested
  • Pre-commit hook blocking hardcoded secrets in repository
  • Secret access audited — each secret has a designated owner
  • Delegate has network access to secrets backend (tested with nc or curl)
  • Logs confirmed: secret values appear as *** not plaintext

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.