How would you manage externalized configuration and secure sensitive properties in a microservices architecture?

In a microservices architecture, externalized configuration means storing application settings outside the application code so they can be changed without rebuilding or redeploying services. Sensitive properties such as passwords, API keys, database credentials, and tokens should be secured using encryption, secret management tools, and controlled access mechanisms.

Key Points

Example

Consider an e-commerce platform with multiple microservices

Instead of storing database credentials separately in each service, all configurations are managed centrally and securely distributed to the services.

Architecture

Microservices

↓

Config Server

↓

Git Repository

↓

Encrypted Properties

Configuration Flow

1. Configurations are stored in a central repository.

2. Spring Cloud Config Server exposes configurations.

3. Microservices fetch configurations during startup.

4. Sensitive values are decrypted securely before use.

Sample Configuration

application-prod.yml

database

url: jdbc:mysql://prod-db

username: app_user

password: ENC(xyz123abc)

The encrypted password is decrypted at runtime.

Common Solutions

1. Spring Cloud Config

2. HashiCorp Vault

3. Kubernetes Secrets

4. Cloud Secret Managers

Examples

Best Practices for Securing Sensitive Properties

Using Environment Variables

spring.datasource.password=
${DB_PASSWORD}

The actual password is stored outside the application.

Benefits

Real-World Example

A payment microservice requires

Instead of storing them in application.properties

Production Architecture

Microservice

↓

Spring Cloud Config

↓

HashiCorp Vault

↓

Encrypted Secrets

This approach provides centralized management and enterprise-grade security.

Interview Tip

A concise interview answer is: In a microservices architecture, I would use Spring Cloud Config to externalize configuration and maintain centralized configuration management. For sensitive properties such as passwords, API keys, and tokens, I would use secure solutions like HashiCorp Vault, Kubernetes Secrets, or cloud secret managers. Additionally, I would encrypt sensitive values, use environment variables where appropriate, and avoid storing secrets directly in source code or configuration files.

Last updated: 11 November 2026

Previous question: In Spring Boot, how is session management configured and handled, especially in distributed systems?

Next question: Can we create a non-web application in Spring Boot?

More Spring Boot - Level II interview questions

All Spring Boot - Level II questions