Prepare and test your skills

Prepare and test your skills

Versioning and incremental updates are the practices that keep infrastructure as code (IaC) safe and predictable over time. Versioning means storing infrastructure provisioning and configuration logic in source control where every change can be tracked, reviewed, and audited. An incremental update means changing that stored configuration and redeploying resources from the new version instead of manually editing live resources. Together, they remove manual steps, reduce human error, and improve consistency and reproducibility across environments.
Versioning infrastructure configurations in source control means treating provisioning logic the same way as application code. The configuration files live in a code repository, so each change has a full history of who changed what and why. Because the configuration is in a repository, a continuous integration and continuous deployment (CI/CD) pipeline can automatically test and deploy every change before it reaches production. This automation increases consistency and speed while minimizing human error, which increases the resilience of apps and environments.
Applying incremental updates through immutable redeploys means never modifying a deployed resource in place. Immutable infrastructure is the rule that a virtual machine, Kubernetes cluster, or firewall rule is never tweaked after deployment; the update is made to the configuration in the source repository instead. The update follows a fixed order from source code to live environment:
This sequence makes deployments and rollbacks more predictable because every environment is re-created from the same versioned source. It also avoids configuration drift, where live resources slowly differ from their intended state, and snowflake servers that become unique and hard to reproduce.
Exam tip: For an immutable update, change the configuration in the source repository and redeploy the resource; do not edit the live virtual machine, cluster, or firewall rule directly.
Tools that support versioned deployments on Google Cloud automate the creation and management of resources from versioned configurations. All of these tools depend on the versioned repository as the source of truth, so data flows from the repository through testing and deployment to the live Google Cloud environment:
Execution of deployment workflows is the process of turning a Terraform configuration into live Google Cloud resources by generating an execution plan and applying it. In Google Cloud, Infrastructure Manager (opens in a new tab) is the managed service that performs this work by running Terraform commands for you. You supply a Terraform configuration from a Cloud Storage bucket or Git repository, and Infrastructure Manager provisions new resources or modifies existing ones through an automated job.
A deployment update in Infrastructure Manager is a new revision of an existing deployment that either corrects drift or implements intended change. Drift happens when live resources change outside of Terraform, such as when someone edits a resource in the console. Intended change happens when you want the infrastructure itself to be different, such as adding resources or editing settings.
| Goal | Configuration used for the update | Example |
|---|---|---|
| Return infrastructure to a chosen state | The original Terraform configuration is applied again | Reapply the deployed configuration after a manual console change |
| Implement changes to infrastructure | A new or edited Terraform configuration is applied | Add a new virtual machine or change a bucket setting |
Choose the first option when the configuration is still correct but the live environment has drifted. Choose the second option when the desired infrastructure has changed and the configuration must describe the new state.
Prerequisites for execution ensure that Infrastructure Manager has the identity, permissions, configuration, and capacity needed to apply changes safely. The update depends on both the calling identity and the service account that acts on Google Cloud resources. Missing permissions, quota, or continuity planning causes deployment errors or service interruption:
roles/config.admin to manage deployments.Exam tip: If the revision defines different resources than the original deployment, the service account needs permissions for resources defined in both configurations.
The Infrastructure Manager execution workflow applies configuration changes through an automated Cloud Build (opens in a new tab) job that moves from source code to live resources in a fixed order. Data flows from the Cloud Storage bucket or Git repository that holds the Terraform module to the Cloud Build job, and then from the Cloud Build job to the target Google Cloud resources. Logs flow from the Cloud Build job to a Cloud Storage (opens in a new tab) bucket created by Infrastructure Manager, and deployment metadata flows from the job to Cloud Storage for later queries:
A process flow showing Infrastructure Manager creating a Cloud Build job that downloads the Terraform module from Cloud Storage or Git, runs terraform init, validate, and apply, streams logs to Cloud Storage, retries on transient failure, and finally provisions the Google Cloud resources.
terraform init to prepare the working directory and providers.terraform validate to check that the configuration is syntactically correct.terraform apply to provision or modify resources, or terraform destroy when the deployment is being deleted.terraform init or terraform apply fails from causes such as intermittent network outages, Infrastructure Manager automatically retries those operations a limited number of times.Only after the apply step succeeds are the Google Cloud resources provisioned as described by the configuration. When the deployment is complete, you can query Infrastructure Manager for the status of the deployment, the list of resources deployed as part of the deployment, and details about individual resources in the deployment.
The runtime environment for Infrastructure Manager is an ephemeral Cloud Build environment that exists only for the duration of the Terraform run. Infrastructure Manager executes the Terraform commands inside this environment and then the environment is discarded, so no state or software persists between runs. You select which supported version of Terraform to use for each deployment, while the operating system and installed software inside the environment are managed by Google Cloud and can change at any time. Each execution also creates deployment metadata in Cloud Storage that tracks what was deployed. Do not include personal or sensitive information in Terraform configuration values, because configuration values are handled as part of this automated workflow and stored with deployment data.
State management and consistency in infrastructure as code means keeping deployed cloud resources matched to a versioned configuration so every environment is reproducible. Provisioning logic is stored as code, changes are tracked and tested, and automation applies the same configuration the same way each time. On Google Cloud, this approach improves consistency, reduces human error, and increases resilience.
Infrastructure as code (IaC) is a technique that treats infrastructure provisioning and configuration the same way as application code. Provisioning logic is stored in source control so it is discoverable and can be versioned and audited. Because the configuration lives in a code repository, continuous integration and continuous deployment (CI/CD) pipelines can automatically test and deploy any changes. Google Cloud resources managed this way live inside projects, which contain service resources such as Compute Engine virtual machines, Pub/Sub topics, Cloud Storage (opens in a new tab) buckets, and Cloud VPN endpoints. Automation ensures those resources are created from the same tested configuration rather than by separate manual steps, so development, testing, and production environments stay aligned over time.
Tools that automate provisioning on Google Cloud include Google Cloud native services and popular third-party IaC tools. These tools apply the versioned configuration to create and update infrastructure. Using automation for provisioning, testing, and deployment increases consistency and speed while minimizing human error:
Immutable infrastructure is a philosophy that builds on IaC and requires that resources are never modified after they are deployed. If a virtual machine, Kubernetes cluster, or firewall rule needs an update, the configuration is updated in the source repository. After the change is tested and validated, the resource is fully redeployed using the new configuration rather than tweaked in place. Creating immutable infrastructure leads to more predictable deployments and rollbacks. It also mitigates problems common in mutable infrastructures, like configuration drift and snowflake servers, where running resources slowly differ from each other and from the intended configuration.
Exam tip: Immutable infrastructure means never modify a deployed resource — update the configuration in source control and fully redeploy the resource.
Immutable infrastructure means a virtual machine, Kubernetes cluster, or firewall rule is never modified after deployment. To apply an update, change the resource configuration in the source repository, test and validate the change often with a continuous integration and continuous deployment (CI/CD) pipeline, and then fully redeploy the resource using the new validated configuration. This sequence makes deployments and rollbacks more predictable and avoids configuration drift and snowflake servers where running resources differ from the intended configuration.
Reapply the original Terraform configuration when the configuration is still correct but the live environment has drifted, for example after a manual console change. Apply a new or edited Terraform configuration when the desired infrastructure has changed, for example adding a new virtual machine or changing a bucket setting.
Infrastructure Manager runs the changes through an automated Cloud Build job that downloads the Terraform module from a Cloud Storage bucket or Git repository, runs terraform init to prepare the working directory and providers, runs terraform validate to check that the configuration is syntactically correct, and runs terraform apply to provision or modify resources. The job streams logs to a Cloud Storage bucket created by Infrastructure Manager and automatically retries terraform init or terraform apply a limited number of times when they fail from transient causes such as intermittent network outages.
A cloud engineer is updating an existing Google Cloud infrastructure deployment using Terraform. The configuration includes several Compute Engine virtual machines, firewall rules, and Cloud Storage buckets.
Before executing the updates in the environment, the engineer wants to preview the exact proposed changes, verify which resources will be created, modified, or destroyed, and ensure there are no unintended disruptions to live resources.
Which Terraform command should the engineer run to generate and review this execution plan without making actual changes?
terraform plan
terraform apply
terraform validate
terraform init
Last updated