Intro to Infrastructure as Code

Learn the basics of infrastructure as code with Terraform, a scalable and efficient approach to provisioning and managing infrastructure, covering declarative and imperative methods, configuration files, and more.

Key takeaways
  • Terraform is infrastructure as code, provisioning and managing infrastructure in a repeatable process.
  • The primary advantage is it removes manual time-consuming efforts, increasing scalability.
  • Two main approaches: declarative and imperative, where one defines desired infrastructure, while the other defines a step-by-step plan.
  • Key to infrastructure as code is configuration files and providers like AWS or OpenTofu, and storing the state between local and remote systems.
  • Resources are managed with code, files, or network locations.
  • Ansible, on the other hand, handles configuration as a state that needs to be tracked and reverted.
  • For reapplying changes, apply is the tool, as well as providing a comparison plan before deploying.
  • OpenTofu provides a forked version, offering documentation and community involvement.
  • For securing sensitive information, a secure protocol is not suggested in storing credentials directly within code.
  • AWS has extensive resource list of modules that provide support, with community-created and contributed tools.
  • When you update variables, it shows up as resources in plan for updating in the process, whereas creating a resource for local setup is different, displaying resource not found errors, whereas redeploying over remote, is not tracked directly in AWS.
  • Other approaches exist with Pulumi (support for JavaScript, Python) but that has varying support on what languages that support that level.
  • Also, it could go through another tool where infrastructure has configuration and management options (i.e., Terraform on remote setup.