Environment-Specific Values, or ESVs, are variables used in PingOne to store configuration settings that can vary across different environments such as development, testing, and production. Properly managing ESVs is crucial for maintaining security, ensuring consistency, and simplifying deployment processes.
What are Environment-Specific Values in PingOne?
ESVs allow you to define values that can change based on the environment your application is running in. This means you can have different configurations for development, staging, and production without changing your codebase. For example, you might have different database connection strings or API keys for each environment.
Why use Environment-Specific Values?
Using ESVs helps in several ways:
- Security: Sensitive information like API keys and passwords can be stored securely and accessed only where necessary.
- Flexibility: Easily switch configurations between environments without modifying code.
- Maintainability: Centralize configuration management, reducing the risk of misconfigurations.
How do you create ESVs in PingOne?
Creating ESVs in PingOne involves defining the variables and their values through the PingOne admin console or API.
Through the Admin Console
- Log in to the PingOne admin console.
- Navigate to Environment-Specific Values under the Configuration section.
- Click on Add Environment-Specific Value.
- Enter the name, description, and initial value.
- Set the scope (e.g., organization, environment).
- Save the ESV.
Through the API
You can also create ESVs programmatically using the PingOne API. Here’s an example using curl:
curl -X POST \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "DATABASE_URL",
"value": "https://dev-db.example.com",
"scope": "ENVIRONMENT",
"environmentId": "YOUR_ENVIRONMENT_ID"
}' \
"https://api.pingone.com/v1/environments/YOUR_ENVIRONMENT_ID/environmentSpecificValues"
How do you reference ESVs in your configuration?
Referencing ESVs allows you to use their values in your application configuration files or scripts.
In Configuration Files
PingOne supports referencing ESVs in JSON configuration files. Use the ${ESV_NAME} syntax to include the value of an ESV.
Example:
{
"database": {
"url": "${DATABASE_URL}",
"username": "${DB_USERNAME}"
}
}
In Scripts
You can also retrieve ESV values programmatically using the PingOne API. Here’s an example in Python:
import requests
def get_esv_value(esv_name, environment_id, access_token):
url = f"https://api.ping1.com/v1/environments/{environment_id}/environmentSpecificValues/{esv_name}"
headers = {
"Authorization": f"Bearer {access_token}",
"Content-Type": "application/json"
}
response = requests.get(url, headers=headers)
if response.status_code == 200:
return response.json().get('value')
else:
raise Exception(f"Failed to get ESV: {response.text}")
# Usage
database_url = get_esv_value("DATABASE_URL", "YOUR_ENVIRONMENT_ID", "YOUR_ACCESS_TOKEN")
print(f"Database URL: {database_url}")
🎯 Key Takeaways
- Create ESVs through the admin console or API.
- Reference ESVs in configuration files using `${ESV_NAME}`.
- Retrieve ESV values programmatically using the API.
What are the security considerations for ESVs?
Security is paramount when managing ESVs. Here are some key considerations:
- Encryption: Ensure that ESVs are encrypted both in transit and at rest.
- Access Control: Restrict access to ESVs to authorized personnel only.
- Audit Logging: Enable audit logging to track changes and access to ESVs.
- Avoid Exposure: Never expose ESVs in logs, version control systems, or public repositories.
Example of Secure ESV Management
Here’s an example of securely managing ESVs using the PingOne API:
# Create an ESV securely
curl -X POST \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "API_KEY",
"value": "YOUR_SECURE_API_KEY",
"scope": "ENVIRONMENT",
"environmentId": "YOUR_ENVIRONMENT_ID"
}' \
"https://api.pingone.com/v1/environments/YOUR_ENVIRONMENT_ID/environmentSpecificValues"
# Retrieve an ESV securely
curl -X GET \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
"https://api.pingone.com/v1/environments/YOUR_ENVIRONMENT_ID/environmentSpecificValues/API_KEY"
How do you update ESVs?
Updating ESVs is straightforward through the admin console or API.
Through the Admin Console
- Log in to the PingOne admin console.
- Navigate to Environment-Specific Values.
- Find the ESV you want to update.
- Click on Edit and update the value.
- Save the changes.
Through the API
To update an ESV using the API, send a PATCH request:
curl -X PATCH \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"value": "NEW_DATABASE_URL"
}' \
"https://api.pingone.com/v1/environments/YOUR_ENVIRONMENT_ID/environmentSpecificValues/DATABASE_URL"
🎯 Key Takeaways
- Update ESVs through the admin console or API.
- Always test changes in non-production environments before applying them to production.
- Monitor the impact of updates to ensure application stability.
How do you delete ESVs?
Deleting ESVs is necessary when they are no longer needed or have been replaced.
Through the Admin Console
- Log in to the PingOne admin console.
- Navigate to Environment-Specific Values.
- Find the ESV you want to delete.
- Click on Delete and confirm the action.
Through the API
To delete an ESV using the API, send a DELETE request:
curl -X DELETE \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
"https://api.pingone.com/v1/environments/YOUR_ENVIRONMENT_ID/environmentSpecificValues/DATABASE_URL"
How do you handle ESV conflicts?
ESV conflicts can occur when multiple values are defined for the same name in different scopes. To handle conflicts:
- Check Scopes: Ensure that ESVs with the same name are defined in different scopes (e.g., organization vs. environment).
- Override Values: Define a more specific ESV in a narrower scope to override a broader one.
- Review Configurations: Regularly review configurations to identify and resolve conflicts.
Example of resolving a conflict:
# Define a global ESV
curl -X POST \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "API_KEY",
"value": "GLOBAL_API_KEY",
"scope": "ORGANIZATION"
}' \
"https://api.pingone.com/v1/organizations/YOUR_ORGANIZATION_ID/environmentSpecificValues"
# Override the global ESV in a specific environment
curl -X POST \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "API_KEY",
"value": "ENVIRONMENT_API_KEY",
"scope": "ENVIRONMENT",
"environmentId": "YOUR_ENVIRONMENT_ID"
}' \
"https://api.pingone.com/v1/environments/YOUR_ENVIRONMENT_ID/environmentSpecificValues"
🎯 Key Takeaways
- Check scopes to avoid conflicts.
- Define more specific ESVs to override broader ones.
- Regularly review configurations to resolve conflicts.
How do you monitor ESV usage?
Monitoring ESV usage helps you understand how and where they are being used, which is crucial for maintaining security and performance.
Enable Audit Logging
Enable audit logging to track access and changes to ESVs:
- Log in to the PingOne admin console.
- Navigate to Settings > Audit Logging.
- Enable logging for Environment-Specific Values.
Review Logs
Regularly review audit logs to identify any suspicious activity or unauthorized access:
# Example log entry
{
"timestamp": "2025-01-23T10:00:00Z",
"event": "ESV_ACCESS",
"user": "[email protected]",
"esvName": "API_KEY",
"environmentId": "YOUR_ENVIRONMENT_ID"
}
Use Monitoring Tools
Integrate monitoring tools to alert you of unusual ESV usage patterns:
- Set up alerts for frequent access to sensitive ESVs.
- Monitor for changes in ESV values.
How do you backup ESVs?
Backing up ESVs ensures you can recover them in case of accidental deletion or corruption.
Manual Backup
Manually export ESVs using the admin console or API:
# Export all ESVs in an environment
curl -X GET \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
"https://api.pingone.com/v1/environments/YOUR_ENVIRONMENT_ID/environmentSpecificValues"
Automated Backup
Automate backups using scripts or CI/CD pipelines:
#!/bin/bash
# Backup ESVs
curl -X GET \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
"https://api.pingone.com/v1/environments/YOUR_ENVIRONMENT_ID/environmentSpecificValues" > esvs_backup.json
# Store the backup file securely
aws s3 cp esvs_backup.json s3://your-backup-bucket/esvs_backup_$(date +%Y%m%d%H%M%S).json
🎯 Key Takeaways
- Manually export ESVs using the admin console or API.
- Automate backups using scripts or CI/CD pipelines.
- Store backups securely to prevent unauthorized access.
How do you migrate ESVs between environments?
Migrating ESVs between environments is necessary during deployments or migrations.
Using the Admin Console
- Export ESVs from the source environment.
- Manually recreate them in the target environment.
Using the API
Automate migration using the API:
# Export ESVs from the source environment
source_env_esvs=$(curl -X GET \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
"https://api.pingone.com/v1/environments/SOURCE_ENVIRONMENT_ID/environmentSpecificValues")
# Import ESVs into the target environment
echo "$source_env_esvs" | jq -c '.[]' | while read -r esv; do
curl -X POST \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d "$esv" \
"https://api.pingone.com/v1/environments/TARGET_ENVIRONMENT_ID/environmentSpecificValues"
done
How do you document ESVs?
Documentation is essential for understanding and maintaining ESVs.
Create Documentation
Document the purpose, usage, and scope of each ESV:
# Environment-Specific Values Documentation
## DATABASE_URL
- **Purpose**: Stores the database connection URL.
- **Usage**: Referenced in the `database` configuration section.
- **Scope**: Environment-specific.
## API_KEY
- **Purpose**: Stores the API key for external services.
- **Usage**: Referenced in API requests.
- **Scope**: Organization-wide.
Maintain Documentation
Regularly update documentation to reflect changes in ESVs:
- Update descriptions when ESV values or usage changes.
- Remove outdated entries.
🎯 Key Takeaways
- Create comprehensive documentation for each ESV.
- Maintain documentation to reflect changes.
- Share documentation with team members for clarity.
How do you troubleshoot ESV issues?
Troubleshooting ESV issues is crucial for maintaining application functionality.
Common Issues
- Incorrect References: Ensure ESVs are referenced correctly in configuration files.
- Access Denied: Verify that the accessing user has the necessary permissions.
- Value Not Found: Check that the ESV exists in the correct scope and environment.
Debugging Steps
- Check References: Verify the syntax and scope of ESV references.
- Verify Permissions: Ensure the user has the required access rights.
- Inspect Logs: Review audit logs for any errors or warnings related to ESVs.
Example of troubleshooting incorrect references:
# Incorrect reference
{
"database": {
"url": "${DB_URL}" # Incorrect name
}
}
# Correct reference
{
"database": {
"url": "${DATABASE_URL}" # Correct name
}
}
Final Thoughts
Managing Environment-Specific Values in PingOne is essential for maintaining security, flexibility, and maintainability. By following best practices, you can ensure that your configurations are secure, consistent, and easy to manage across different environments.
Start by creating and documenting ESVs, then monitor and back them up regularly. Implement access controls and audit logging to protect sensitive information. Troubleshoot issues promptly to maintain application functionality.
That’s it. Simple, secure, works. Get this right and you’ll sleep better knowing your configurations are under control.

