200-901 Infrastructure and Automation Practice Question
A network automation engineer needs to ensure that a Python script can securely store and retrieve API credentials for Cisco DNA Center without hardcoding them in the script. Which method is the most appropriate?
⚠ Common exam trap
The trap here is assuming that storing credentials in a file within the repository is acceptable as long as it is not the main script, but version control exposure remains a critical risk.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Use environment variables to hold the credentials and access them via os.environ in the script.
Using environment variables keeps credentials out of source code and allows them to be managed securely by the deployment environment. This is a widely accepted practice for handling secrets in automation scripts. It avoids the risks of hardcoding or storing secrets in version control, and it supports different credentials per environment.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Embed the credentials directly in the Python script as constants.
Why it's wrong here
Hardcoding credentials in the script is a security risk because they become part of the source code and may be exposed in version control, logs, or error messages. It also makes rotation difficult. This method is strongly discouraged in favor of external secret management.
- ✓
Use environment variables to hold the credentials and access them via os.environ in the script.
Why this is correct
Environment variables are a common and secure way to inject secrets into applications at runtime. They are not stored in the codebase and can be managed by the operating system or container orchestration. This approach keeps credentials out of source control and allows different environments to use different values.
- ✗
Store the credentials in a YAML file that is committed to the same Git repository as the script.
Why it's wrong here
Committing credentials to a Git repository, even in a YAML file, exposes them to anyone with repository access. Git history retains the secrets even if later removed. This is not a secure practice; secrets should be stored outside the codebase and managed separately.
- ✗
Store the credentials in a plain text file on the local filesystem and read them at runtime.
Why it's wrong here
Storing credentials in plain text is insecure because anyone with file access can read them. It also violates security best practices and compliance requirements. While it avoids hardcoding, it does not provide adequate protection for sensitive data like API keys or passwords.
Go deeper
Related to this question
About these practice questions
One of 975 original 200-901 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
JA
Written and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official Cisco exam blueprint
This 200-901 practice question is part of Courseiva's free Cisco certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 200-901 exam.