ANS-C01 Question 329
Select 4You are tasked with creating an AWS CloudFormation template to provision a VPC with subnets, routing tables, and security groups. During a code review, you notice that several values such as IP addresses, subnet CIDRs, and resource names are hardcoded in the template. What problems could arise from using hardcoded values in the template?
- A
Limited reusability of the template across multiple environments.
- B
Increased risk of configuration drift between environments.
- C
Improved template readability and maintainability.
- D
Higher likelihood of errors during resource updates or modifications.
- E
Reduced ability to leverage parameterization and automation features.
Show answer and explanation
Correct answers: A, B, D, E
Explanation
Hardcoding values in Infrastructure as Code (IaC) templates like AWS CloudFormation introduces a range of problems, including limiting reusability, increasing the risk of configuration drift, and making updates error-prone. A better approach is to use parameters, mappings, or dynamic references to ensure flexibility and maintainability while leveraging automation features effectively.
- A. Correct.
Hardcoding values limits the flexibility and reusability of the template, as it cannot be easily adapted to different environments (e.g., dev, test, prod) without manual modifications.
- B. Correct.
Hardcoded values can lead to configuration drift, as different environments may require different configurations that cannot be dynamically adjusted without editing the template.
- C. Incorrect.
Hardcoding does not improve readability or maintainability; instead, it makes the template rigid and prone to errors when changes are required.
- D. Correct.
Hardcoding values increases the likelihood of errors during resource updates or modifications, as any changes require editing the template directly, which can introduce mistakes.
- E. Correct.
Hardcoding values prevents the use of parameters, mappings, or other mechanisms that enhance automation and make the template more dynamic and versatile.