Author : MD TAREQ HASSAN | Updated : 2021/06/14
What is Infrastructure as code?
- Infrastructure as code (IaC) means to manage IT infrastructure using code
- Code can be domain specific language (DSL) or real programming language
- DSL i.e. HCL in Terraform
- C# (+ many more labguage) in Pulumi
- ARM Template (Azure)
- IaC allows you to automate the provisioning of your cloud resources using code
- Defining provisioning application infrastructures using code
- IaC helps IT operations teams manage and provision IT infrastructure automatically through code without relying on manual processes
- IaC is a concept and there are IaC tools( i.e. Terraform, Pulumi, Cloudformation etc.) that helps to automate different tasks (provisioning and managing infrastructure)
- Treating infrastructure the same way we treat code
IaC approaches
- Declarative (i.e. HCL in Terraform, JSON in ARM Template)
- Imperative (i.e. real programming language in Pulumi)
How does Azure Pulumi Work?
See: https://samcogan.com/wth-is-pulumi/
Projects and Program
- A Pulumi project is any folder which contains a
Pulumi.yaml
filePulumi.yaml
project file specifies metadata about your project- The project file must begin with a capitalized
P
(Pulumi/yaml
, notpulumi.yaml
)
- Project is a directory that contains source code for the program and metadata on how to run the program
- A project specifies which runtime to use and determines where to look for the program that should be executed during deployments
- Pulumi program
- Describes the target infrastructure written in specified programming language i.e. C#
- Resides in a project
- Contains all of the cloud resources you define in you Pulumi code
pulumi up
creates an instance of Pulumi Program which is known as “Stack”
- https://www.pulumi.com/docs/intro/concepts/project/
Stack
- A stack is an isolated, independently configurable instance of a Pulumi program
- Each stack has its own separate configuration and secrets, role-based access controls (RBAC) and policies, and concurrent deployments.
- See: details about Stack in Pulumi
Stack State
- Pulumi stores metadata about infrastructure so that it can manage the corresponding cloud resources and that metadata is called State (Stack State)
- For detaisl, see Pulumi Stack State
Stack State Backend
- Pulumi stores Stack State in a backend (A backend is an API and storage endpoint used by the CLI)
- For detaisl, see Pulumi Stack State Backend
Pulumi CLI
- A CLI (command line interface) tool to interact with Pulumi runtime
- Pulumi is controlled primarily using CLI
- Pulumi CLI is what converts code into running cloud infrastructure
- Pulumi CLI works in conjunction with stack state backend (i.e. Pulumi service) to deploy changes to the cloud infrastructure and apps
- It keeps a history of who updated what in your team and when
- Pulumi CLI has been designed for:
- continuous integration and delivery scenarios
- inner loop productivity
- Common CLI commands: https://www.pulumi.com/docs/reference/cli/#common-commands