2.4 Given a scenario, use code to deploy and configure cloud resources.
Defining infrastructure and configuration as code makes environments repeatable, reviewable and auditable, which is also a security win.
As-code approaches
- Infrastructure as code (IaC)
- Declaring cloud resources in files (Terraform, CloudFormation, Bicep) that tools apply automatically.
- Configuration as code (CaC)
- Declaring OS and application configuration in code (Ansible, Chef, Puppet).
Scripting logic
- Variables
- Named values reused across code, such as region or instance size. Never hard-code secrets in them.
- Conditionals
- If/else logic, e.g. create a bigger instance only in production.
- Operators
- Comparison, arithmetic and logical operators used in expressions.
- Data types
- Strings, numbers, booleans, lists and maps.
- Functions
- Reusable blocks of logic, built-in or user-defined.
Practices
- Repeatability
- The same code produces the same environment every time.
- Drift detection
- Finding differences between declared code and what is actually deployed, often caused by manual changes.
- Versioning
- Keeping IaC in version control to review, audit and roll back changes.
- Testing
- Validating code (linting, policy-as-code checks, plan reviews) before applying.
- Documentation
- Describing modules, inputs and outputs so others can use them safely.
Formats
- JavaScript Object Notation (JSON)
- Structured key-value format; strict syntax, common in APIs and templates.
- Yet Another Markup Language (YAML)
- Indentation-based, human-friendly format used by Kubernetes, Ansible and CI pipelines. Indentation errors change meaning.
Check your understanding
Loading quiz…
Original CoreQ Academy material, mapped to objective 2.4 of the publicly available CompTIA Cloud+ CV0-004 exam objectives (Exam objectives V4, document version 5.0). Not affiliated with or endorsed by CompTIA. Contains no exam questions.