Managing SAP BTP with CDK for Terraform

 

In the rapidly evolving landscape of cloud technologies, SAP Business Technology Platform (BTP) stands out as a comprehensive platform-as-a-service offering from SAP, enabling businesses to innovate, integrate, and extend applications across a connected ecosystem. As enterprises move to S/4 and the importance for a Clean Core grows, they increasingly rely on SAP BTP to build, deploy, and manage their cloud solutions. An efficient infrastructure management becomes crucial.

With HashiCorp Terraform, managing infrastructure can be done through what is called infrastructure as code (IaC). Infrastructure as Code (IaC) automates the management and provisioning of IT infrastructure using code, replacing manual processes for greater consistency and efficiency.

About a year ago, it became possible to start using Terraform for SAP BTP, allowing engineers to define and deploy infrastructure using the declarative HashiCorp Configuration Language (HCL). However, for developers and teams more accustomed to general-purpose programming languages, the transition to HCL can sometimes be a hurdle, especially when dealing with complex infrastructure requirements.

This is where the Cloud Development Kit for Terraform (CDKTF) comes into play. CDKTF allows you to define your cloud infrastructure using familiar programming languages like TypeScript, rather than HCL. By using CDKTF, you can leverage the full power of these languages, including loops, conditionals, and functions, making it easier to maintain large codebases and creating reusable components.

Cloud Development Kit

The CDKTF is inspired by the popular Amazon Web Services Cloud Development kit (AWS CDK), a tool that let you define AWS infrastructure using familiar programming languages. By bridging the gap between development and operations, CDKTF brings the same ease and efficiency to a wider range of cloud platforms.

What CDKTF does, is converting the definitions that you write, in for instance Typescript, to Terraform configuration files. It then uses Terraform to provision and manage your BTP infrastructure when you deploy.
CDKTF supports the following programming languages: Go, Python, Java, Typescript and C# and it supports all the existing Terraform providers and modules, including the BTP provider.

CDKTF uses the core Terraform workflow, including planning and applying your infrastructure changes to the platform of choice.

Blog Erik Leemans 082024 V1

How to use CDKTF

Like Terraform HCL, CDKTF uses a command-line-interface (CLI) to initialise and manage your project. To make CDKTF development faster and easier to use, Terraform provides pre-built providers. Several Terraform providers are already pre-build and available in multiple languages. You can find them in GitHub: https://github.com/cdktf searching by “cdktf-provider- “.

While there isn't a direct CDKTF pre-built provider with SAP BTP as of the latest updates, we can also “ask” CDKTF to generate our BTP provider in our desired language. Like we mentioned before, it supports all existing providers.
Adding the BTP provider manually and using the “CDKTF GET” command downloads the provider for you, together with the corresponding files, classes and more. This automatic code generation allows the use of any Terraform providers and modules with CDKTF, which is how CDKTF offers code completion in compatible editors.

After setting up your infrastructure, CDKTF CLI operations can communicate with Terraform to synthesise and deploy the infrastructure.

Blog Erik Leemans 082024 V2

Why Use CDKTF with SAP BTP?

For developers working within the SAP ecosystem, the ability to manage SAP BTP resources programmatically is invaluable. Using infrastructure as code, your state of the infrastructure is stored in git, which provides you with a history and traceability of your infrastructure’s state.
By adopting CDKTF, you can integrate SAP BTP resource management into your existing development workflows, using the same languages and tools you're already comfortable with.

With CDKTF, you can benefit from the rich ecosystem of libraries, IDE support, and tooling available in your chosen language, which can significantly boost productivity and code quality.

Maturity

As organisations increasingly adopt IaC to automate and manage their cloud, the choice of tools becomes a critical decision. CDK for Terraform is an innovative new tool from the widely used Terraform platform, but relatively new and has not yet reached version 1.0.0.

Terraform’s core engine, responsible for managing infrastructure state and applying changes, remains the same whether you use HCL or CDKTF. This means that CDKTF inherits much of Terraform’s robustness, stability, and broad provider support. However, CDKTF is still evolving with regular updates and features. This rapid pace of development is a double-edged sword however: while CDKTF is powerful and innovative, it is also less stable and not as rich compared to the HCL ecosystem. Moreover, it will have regular updates, breaking changes and bugs.

Conclusion

CDKTF is a very cool new tool for automating and managing SAP BTP. As an AWS CDK user and enthusiast of the developer experience that goes with a CDK, I’m very excited. It will definitely bring a lot of improvements on top of Terraform HCL and boost productivity when you are able to use your own stack.

CDKTF might be "too early" for use in production environments, and it does require careful consideration. That being said, if your infrastructure needs are not extremely complex and your team is comfortable with the languages supported by CDKTF, it can be a great tool for managing infrastructure with the added benefits of a familiar language, even if this means taking into account the risks of refactoring or breaking changes. However, for mission-critical or highly complex environments, it's wise to evaluate its fit thoroughly.

My next blog will dive deeper into the technical part of CDKTF and how to create a basic setup. Stay tuned!

About the author

Photo of Erik Leemans
Erik Leemans

Erik Leemans is a Senior BI & Innovation consultant at Expertum. Erik has more than 6 years of experience in SAP consulting. Erik specializes in designing and realizing a technical solution by combining his functional SAP knowledge with his technical background.

Read more articles by Erik Leemans