This content originally appeared on DEV Community and was authored by Marcin Wyszynski
The introduction of Infrastructure as Code or IaC has transformed the way you can provision and deploy high-performance cloud-based IT infrastructures.
IaC tools, such as Terraform, have been integrated into DevOps toolchains, saving DevOps IaC teams from the excessive manual effort.
While these tools undoubtedly help accelerate building IT infrastructures, their limitations can impact DevOps’ ability to optimize and improve control of their IaC processes supporting future business needs.
In this article, you’ll learn about IT infrastructure limitations that IaC DevOps teams deal with on a daily basis and how Spacelift is able to get past them.
1) Workflow
One of the most frequent challenges while using more generic IaC tools is the non-intuitive workflow driven by its reliance on pull requests. Some solutions offer multiple workspaces, but the result can be fragile and nondeterministic.
Since there’s no concept of mapping projects to branches or tags, anyone commenting on an approved pull request can deploy arbitrary code to production, even if the approval was meant for a short-lived experimental environment.
Spacelift does not depend on pull requests. It is mostly driven by push and tag events, so building a sophisticated Git flow is much easier. Spacelift reports the outcome of its jobs as commit status checks, allowing you to block merging the code on a failing Spacelift check.
Triggering a run can be customized using Git push policies. Thanks to that, Spacelift can provide the same level of comfort and security to teams using one project per repository and those using mono repo with hundreds of interdependent projects. You can read more about our approach to VCS integration here.
2) Access Control
The majority of generic tools don’t offer access control models but rely on comments on pull requests to drive infrastructure deployments. While it is usually fine when a single repository drives a single Terraform project, it becomes a huge liability for more complex scenarios.
Spacelift ships with a sophisticated mechanism allowing administrators to declare who can log in (and under what circumstances) and what their level of access to each of the managed projects should be. Even our Slack integration can be subject to policy controls, allowing an admin to grant access to a project based on Slack-specific data (think team, channel, user, etc.).
3) Policy Framework
One thing that’s not in scope for most IaC solutions is the way to ensure that your infrastructure is compliant with industry best practices and your company policies.
Spacelift puts policy-as-code in the center of its value proposition and builds a consistent, robust policy framework on top of Open Policy Agent. Apart from providing a comprehensive automated change review and ensuring compliance of your Terraform changes, Spacelift uses the same approach to allow you to declare rules around the account and project access, handling push notifications, starting runs and triggering tasks, and creating relationships between projects.
4) Complex Workflows
Handling interdependencies between projects has always been Terraform’s Achilles’ heel. The usual approach to this problem is adding another layer of abstraction in the form of a Terraform wrapper like Terragrunt. But it’s only a partial solution as it breaks the problem into smaller chunks.
Spacelift’s trigger policies on the other hand provide a smart, declarative automation layer on top of vanilla Terraform. They allow you to plug into state changes of individual projects and declare dependencies that should be resolved, following the changes that have just been applied. Read more here to discover other exciting possibilities.
5) Private Module Registry
Another problem to solve externally when using some of the generic tools is authoring and maintaining reusable Terraform modules for your organization. Terraform is flexible in allowing modules to come from various sources, but ensuring confidential access, as well as testing and versioning, are left to you, the user.
Until now, the golden standard in that regard has been the private module registry from HashiCorp. But Spacelift offers much more. Far from being just a glorified package manager, Spacelift adds a full CI solution for Terraform modules, out of the box and free of charge. You can thus ensure that your private modules are healthy before you distribute them to the rest of your organization.
6) Effortless Setup and Customization
If you manage a single or a handful of rarely changing projects, it’s likely that you just set your IaC up once and forget about it. But in a more dynamic environment, where microservices come and go, new environments proliferate and new product teams require their own Terraform workspaces. The need to configure it each and every time become a major nuisance, putting a lot of pressure on your DevOps team.
Enter Spacelift. In Spacelift, much of the configuration can be handled by the project owners themselves—you can add Terraform and/or environment variables and mount files (even inject Terraform code!) programmatically or through the GUI without the need for administrative privileges or changing the central server configuration. For administrators, adding new projects requires minimal hassle since there’s no need to set up webhooks or change any YAML. And it can all be done programmatically using Terraform.
7) Programmatic Configuration
What comes as a pleasant surprise to users of generic CI tools, Spacelift entities such as stacks, contexts, modules or policies can be managed in a declarative way using your favorite infra-as-code tool (this rule applies also to their configuration). Yes, that’s right—Spacelift offers a Terraform provider that allows you to programmatically manage the lifecycle of its own resources.
Administrative stacks get credential-less access to the subset of our GraphQL API that does not involve managing the actual infrastructure. For more sophisticated use cases, Spacelift allows you to generate API keys that are subject to the same access controls as normal users are, allowing you to create single-purpose tokens for restricted use by your internal scripts.
8) Drift Detection
Generic IaC platforms do not provide any mechanisms to detect if your infrastructure is undergoing drift. Drift is a condition that represents the difference between the desired and the actual state of the infrastructure managed by your tool of choice – Terraform, Pulumi, CloudFormation or another. Drift can be caused by either or a combination of changes directly introduced by external actors – either humans or machines (scripts) or via the dependency of your resources on external data sources. In any case, drift is not good.
Spacelift has got you covered here. You can configure periodic drift detection to notify you whenever drift happens, and take immediate action. You can even go a step further with optional automatic reconciliation, ensuring your infrastructure always resembles your Terraform configuration.
9) Resource Visualization
General-purpose CI/CD platforms provide little to no insight into resource utilization from either a real-time or historical perspective. Which resources are over-or underutilized?
Developers need to be able to intimately understand the material they’re working with. With regards to infra-as-code, the most important part of this story is understanding the managed resources in-depth. Both from the current perspective and through being able to put each resource in its historical context.
The resources view in Spacelift gives you greater visibility into each and every resource. With this deep insight into resources, DevOps are able to gain an understanding of the lifecycle of each resource managed by Spacelift and document it, regardless of the technology used — Terraform, Terragrunt, Pulumi, or CloudFormation.
Creature Comforts
Last but not least, Spacelift puts an emphasis on great user experience, offering a myriad of creature comforts. Contexts for example allow you to attach entire collections of configuration to individual stacks and modules. Tasks provide a powerful audited way of running one-off administrative commands on an initialized Terraform environment – subject to their own policy constraints. Stack locking allows a single individual to take exclusive control over a stack to ensure that nobody is able to modify its state while crucial changes are being made.
Why Spacelift
Spacelift is an innovative and sophisticated SaaS product for Infrastructure as Code which helps IaC DevOps develop and deploy new infrastructures or changes quickly and with confidence.
Spacelift offers a unique set of IaC management capabilities:
- a more intuitive, versatile and robust workflow
- extremely granular access controls on account and project level that work well with an identity provider of your choice (SSO);
- an automated code review and threat detection
- the ability to declare complex workflows between projects across multiple repositories
- a built-in private module registry with a full CI system for modules
- effortless setup and customization with per-project environment management and Docker integration
- programmatic configuration using Terraform;
- drift detection
- resource visualization
… and a myriad of creature comforts like contexts, tasks or stack locking.
Key Points
There are many ways of working with Terraform. Each way is different in terms of complexity and offers a different set of features. It is important to keep in mind that choosing one way or another should be based on business and technical requirements. Most often, there is no point in implementing an in-house solution as the cost and effort of building and maintaining it may exceed its potential benefits. It is much easier and more efficient to leverage platforms such as Spacelift to provide these features for you instead. You can try Spacelift for free or book a demo with one of our engineers.
This content originally appeared on DEV Community and was authored by Marcin Wyszynski
![](https://www.radiofree.org/wp-content/plugins/print-app/icon.jpg)
Marcin Wyszynski | Sciencx (2021-11-17T22:40:00+00:00) How to Quickly Improve Your Infrastructure as Code. Retrieved from https://www.scien.cx/2021/11/17/how-to-quickly-improve-your-infrastructure-as-code/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.