A collection of CDK modules for provisioning and managing Terraform resources efficiently.
Project description
Azure Terraform CDK Constructs
Welcome to the Azure Terraform CDK Constructs project! This library offers a comprehensive suite of L2 Constructs designed to simplify and enhance the experience of building and managing Azure infrastructure with the Cloud Development Kit for Terraform (CDKTF).
Benefits of Using L2 Constructs
With L2 Constructs, you get the following benefits:
- Abstraction: Higher-level abstractions over Azure resources make your infrastructure code more declarative and easier to understand.
- Reusability: Encapsulate common patterns and best practices in your infrastructure code, promoting reusability across different projects and teams.
- Rapid Development: Accelerate your cloud development process with pre-built constructs that have been tested for common use cases, allowing you to focus on your unique application logic.
- Direct IDE Integration: Access detailed documentation directly within your Integrated Development Environment (IDE), streamlining your development workflow:
Quick Example
This is a quick example that showcases the simplicity and power of L2 Constructs. We'll create a storage account, add a container to it, and then upload a blob—all with a few lines of intuitive, object-oriented code:
// Create a new instance of a storage account as an object
const sa = new azcdk.azure_storageaccount.Account(stack, "storageaccount", {
name: "testStorageAccount",
location: "eastus",
});
// Add a container to the storage account by calling a method on the storage account object
const container = sa.addContainer("testcontainer");
// Add a blob to the container by calling a method on the container object
// The path "../../../test.txt" points to the source file to be uploaded as a blob
container.addBlob("testblob.txt", "../../../test.txt");
Getting Started
This guide will walk you through the process of using the Azure L2 Constructs to define and provision infrastructure on Azure.
Prerequisites
Make sure you have Node.js and npm installed on your machine. These will be used to install the CDK for Terraform and Azure provider packages.
Installation
First, install the CDK for Terraform CLI globally using npm:
npm install -g cdktf-cli
Next, initialize a new CDK for Terraform project with TypeScript template:
cdktf init --template="TypeScript" --local
Install the AzureRM provider for CDKTF:
npm install @cdktf/provider-azurerm
Then, add the Microsoft Terraform CDK constructs for Azure:
npm install @micrsoft/terraform-cdk-constructs
Example 1: Creating a Storage Account
Now let's create a simple Azure storage account. The following TypeScript snippet defines a storage account resource using the CDKTF:
// Import necessary modules and classes
import * as azcdk from "@microsoft/terraform-cdk-constructs";
import { Construct } from 'constructs';
import { App, TerraformStack } from 'cdktf';
import { AzurermProvider } from "@cdktf/provider-azurerm/lib/provider";
// Define a new Terraform stack
class AzureAppInfra extends TerraformStack {
constructor(scope: Construct, name: string) {
super(scope, name);
// Initialize Azure provider
new AzurermProvider(this, "azureFeature", { features: {} });
// Create a new Azure storage account with the specified name and location
new azcdk.azure_storageaccount.Account(this, "storageaccount", {
name: "test42348808",
location: "eastus",
});
}
}
// Initialize the CDK app and synthesize Terraform configurations
const app = new App();
new AzureAppInfra(app, 'cdk');
app.synth();
After defining your infrastructure, generate the Terraform configuration files:
cdktf synth
Finally, deploy your infrastructure to Azure:
cdktf deploy
Supported Languages
Currently, our CDK L2 constructs are available in the following languages:
Language | Status |
---|---|
TypeScript | Available |
Python | Coming soon |
Java | Coming soon |
Go | Coming soon |
C# | Coming soon |
Stay tuned for updates as we work to expand support to other popular programming languages!
Contributing
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.
We welcome contributions to this project! See our documentation on how to get started contributing.
Code Spaces
To open this repository in a Code Space, click the button below:
Trademarks
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file microsoft-cdktfconstructs-0.0.3.dev11.tar.gz
.
File metadata
- Download URL: microsoft-cdktfconstructs-0.0.3.dev11.tar.gz
- Upload date:
- Size: 1.6 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: RestSharp/106.13.0.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f32555494c9299d36c9f887f77e9e7b90233f2a781281d347455988fbd3207b0 |
|
MD5 | 9faa08a35eaca151648efdeb93a1e523 |
|
BLAKE2b-256 | 4d977d67e62e521c87f0a150c059aedb3a8fa2a4e24e60c05ddc68db4c1ec0ee |
File details
Details for the file microsoft_cdktfconstructs-0.0.3.dev11-py3-none-any.whl
.
File metadata
- Download URL: microsoft_cdktfconstructs-0.0.3.dev11-py3-none-any.whl
- Upload date:
- Size: 1.6 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: RestSharp/106.13.0.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9330cb57c5b50e75a2a72aff63401c31d27bbec66c5d3c7a7ab1baf983f34211 |
|
MD5 | a418f69d8b47c719da07b38943fe4288 |
|
BLAKE2b-256 | 4effe9be2bd940aba21818d4ce2fc99d917248e7314a54c86db9f6aa2374c4b7 |