microsoft-cdktfconstructs 0.0.3.dev11__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- microsoft-cdktfconstructs-0.0.3.dev11/LICENSE +19 -0
- microsoft-cdktfconstructs-0.0.3.dev11/MANIFEST.in +1 -0
- microsoft-cdktfconstructs-0.0.3.dev11/PKG-INFO +179 -0
- microsoft-cdktfconstructs-0.0.3.dev11/README.md +156 -0
- microsoft-cdktfconstructs-0.0.3.dev11/pyproject.toml +9 -0
- microsoft-cdktfconstructs-0.0.3.dev11/setup.cfg +4 -0
- microsoft-cdktfconstructs-0.0.3.dev11/setup.py +84 -0
- microsoft-cdktfconstructs-0.0.3.dev11/src/microsoft_cdktfconstructs/__init__.py +217 -0
- microsoft-cdktfconstructs-0.0.3.dev11/src/microsoft_cdktfconstructs/_jsii/__init__.py +31 -0
- microsoft-cdktfconstructs-0.0.3.dev11/src/microsoft_cdktfconstructs/_jsii/terraform-cdk-constructs@0.0.3-pre.11.jsii.tgz +0 -0
- microsoft-cdktfconstructs-0.0.3.dev11/src/microsoft_cdktfconstructs/azure_applicationgateway/__init__.py +823 -0
- microsoft-cdktfconstructs-0.0.3.dev11/src/microsoft_cdktfconstructs/azure_applicationinsights/__init__.py +397 -0
- microsoft-cdktfconstructs-0.0.3.dev11/src/microsoft_cdktfconstructs/azure_containerregistry/__init__.py +320 -0
- microsoft-cdktfconstructs-0.0.3.dev11/src/microsoft_cdktfconstructs/azure_eventhub/__init__.py +2213 -0
- microsoft-cdktfconstructs-0.0.3.dev11/src/microsoft_cdktfconstructs/azure_functionapp/__init__.py +908 -0
- microsoft-cdktfconstructs-0.0.3.dev11/src/microsoft_cdktfconstructs/azure_keyvault/__init__.py +1982 -0
- microsoft-cdktfconstructs-0.0.3.dev11/src/microsoft_cdktfconstructs/azure_kubernetes/__init__.py +400 -0
- microsoft-cdktfconstructs-0.0.3.dev11/src/microsoft_cdktfconstructs/azure_kusto/__init__.py +2485 -0
- microsoft-cdktfconstructs-0.0.3.dev11/src/microsoft_cdktfconstructs/azure_loganalytics/__init__.py +652 -0
- microsoft-cdktfconstructs-0.0.3.dev11/src/microsoft_cdktfconstructs/azure_metricalert/__init__.py +1260 -0
- microsoft-cdktfconstructs-0.0.3.dev11/src/microsoft_cdktfconstructs/azure_networksecuritygroup/__init__.py +1742 -0
- microsoft-cdktfconstructs-0.0.3.dev11/src/microsoft_cdktfconstructs/azure_queryrulealert/__init__.py +1189 -0
- microsoft-cdktfconstructs-0.0.3.dev11/src/microsoft_cdktfconstructs/azure_resourcegroup/__init__.py +320 -0
- microsoft-cdktfconstructs-0.0.3.dev11/src/microsoft_cdktfconstructs/azure_storageaccount/__init__.py +1910 -0
- microsoft-cdktfconstructs-0.0.3.dev11/src/microsoft_cdktfconstructs/azure_virtualmachine/__init__.py +1460 -0
- microsoft-cdktfconstructs-0.0.3.dev11/src/microsoft_cdktfconstructs/azure_virtualmachinescaleset/__init__.py +1185 -0
- microsoft-cdktfconstructs-0.0.3.dev11/src/microsoft_cdktfconstructs/azure_virtualnetwork/__init__.py +707 -0
- microsoft-cdktfconstructs-0.0.3.dev11/src/microsoft_cdktfconstructs/core_azure/__init__.py +931 -0
- microsoft-cdktfconstructs-0.0.3.dev11/src/microsoft_cdktfconstructs/py.typed +1 -0
- microsoft-cdktfconstructs-0.0.3.dev11/src/microsoft_cdktfconstructs.egg-info/PKG-INFO +179 -0
- microsoft-cdktfconstructs-0.0.3.dev11/src/microsoft_cdktfconstructs.egg-info/SOURCES.txt +32 -0
- microsoft-cdktfconstructs-0.0.3.dev11/src/microsoft_cdktfconstructs.egg-info/dependency_links.txt +1 -0
- microsoft-cdktfconstructs-0.0.3.dev11/src/microsoft_cdktfconstructs.egg-info/requires.txt +6 -0
- microsoft-cdktfconstructs-0.0.3.dev11/src/microsoft_cdktfconstructs.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2024 Microsoft
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
include pyproject.toml
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: microsoft-cdktfconstructs
|
|
3
|
+
Version: 0.0.3.dev11
|
|
4
|
+
Summary: A collection of CDK modules for provisioning and managing Terraform resources efficiently.
|
|
5
|
+
Home-page: https://github.com/azure/terraform-cdk-constructs.git
|
|
6
|
+
Author: Microsoft
|
|
7
|
+
License: MIT
|
|
8
|
+
Project-URL: Source, https://github.com/azure/terraform-cdk-constructs.git
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Programming Language :: JavaScript
|
|
12
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Typing :: Typed
|
|
18
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
19
|
+
Classifier: License :: OSI Approved
|
|
20
|
+
Requires-Python: ~=3.8
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
|
|
24
|
+
# Azure Terraform CDK Constructs
|
|
25
|
+
|
|
26
|
+
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).
|
|
27
|
+
|
|
28
|
+
## Benefits of Using L2 Constructs
|
|
29
|
+
|
|
30
|
+
With L2 Constructs, you get the following benefits:
|
|
31
|
+
|
|
32
|
+
* **Abstraction**: Higher-level abstractions over Azure resources make your infrastructure code more declarative and easier to understand.
|
|
33
|
+
* **Reusability**: Encapsulate common patterns and best practices in your infrastructure code, promoting reusability across different projects and teams.
|
|
34
|
+
* **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.
|
|
35
|
+
* **Direct IDE Integration**: Access detailed documentation directly within your Integrated Development Environment (IDE), streamlining your development workflow: 
|
|
36
|
+
|
|
37
|
+
## Quick Example
|
|
38
|
+
|
|
39
|
+
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:
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
|
|
43
|
+
// Create a new instance of a storage account as an object
|
|
44
|
+
const sa = new azcdk.azure_storageaccount.Account(stack, "storageaccount", {
|
|
45
|
+
name: "testStorageAccount",
|
|
46
|
+
location: "eastus",
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// Add a container to the storage account by calling a method on the storage account object
|
|
50
|
+
const container = sa.addContainer("testcontainer");
|
|
51
|
+
|
|
52
|
+
// Add a blob to the container by calling a method on the container object
|
|
53
|
+
// The path "../../../test.txt" points to the source file to be uploaded as a blob
|
|
54
|
+
container.addBlob("testblob.txt", "../../../test.txt");
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Getting Started
|
|
58
|
+
|
|
59
|
+
This guide will walk you through the process of using the Azure L2 Constructs to define and provision infrastructure on Azure.
|
|
60
|
+
|
|
61
|
+
### Prerequisites
|
|
62
|
+
|
|
63
|
+
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.
|
|
64
|
+
|
|
65
|
+
### Installation
|
|
66
|
+
|
|
67
|
+
First, install the CDK for Terraform CLI globally using npm:
|
|
68
|
+
|
|
69
|
+
```sh
|
|
70
|
+
npm install -g cdktf-cli
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Next, initialize a new CDK for Terraform project with TypeScript template:
|
|
74
|
+
|
|
75
|
+
```sh
|
|
76
|
+
cdktf init --template="TypeScript" --local
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Install the AzureRM provider for CDKTF:
|
|
80
|
+
|
|
81
|
+
```sh
|
|
82
|
+
npm install @cdktf/provider-azurerm
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Then, add the Microsoft Terraform CDK constructs for Azure:
|
|
86
|
+
|
|
87
|
+
```sh
|
|
88
|
+
npm install @micrsoft/terraform-cdk-constructs
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Example 1: Creating a Storage Account
|
|
93
|
+
|
|
94
|
+
Now let's create a simple Azure storage account. The following TypeScript snippet defines a storage account resource using the CDKTF:
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
// Import necessary modules and classes
|
|
98
|
+
import * as azcdk from "@microsoft/terraform-cdk-constructs";
|
|
99
|
+
import { Construct } from 'constructs';
|
|
100
|
+
import { App, TerraformStack } from 'cdktf';
|
|
101
|
+
import { AzurermProvider } from "@cdktf/provider-azurerm/lib/provider";
|
|
102
|
+
|
|
103
|
+
// Define a new Terraform stack
|
|
104
|
+
class AzureAppInfra extends TerraformStack {
|
|
105
|
+
constructor(scope: Construct, name: string) {
|
|
106
|
+
super(scope, name);
|
|
107
|
+
|
|
108
|
+
// Initialize Azure provider
|
|
109
|
+
new AzurermProvider(this, "azureFeature", { features: {} });
|
|
110
|
+
|
|
111
|
+
// Create a new Azure storage account with the specified name and location
|
|
112
|
+
new azcdk.azure_storageaccount.Account(this, "storageaccount", {
|
|
113
|
+
name: "test42348808",
|
|
114
|
+
location: "eastus",
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Initialize the CDK app and synthesize Terraform configurations
|
|
120
|
+
const app = new App();
|
|
121
|
+
new AzureAppInfra(app, 'cdk');
|
|
122
|
+
app.synth();
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
After defining your infrastructure, generate the Terraform configuration files:
|
|
126
|
+
|
|
127
|
+
```sh
|
|
128
|
+
cdktf synth
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Finally, deploy your infrastructure to Azure:
|
|
132
|
+
|
|
133
|
+
```sh
|
|
134
|
+
cdktf deploy
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Supported Languages
|
|
138
|
+
|
|
139
|
+
Currently, our CDK L2 constructs are available in the following languages:
|
|
140
|
+
|
|
141
|
+
| Language | Status |
|
|
142
|
+
|------------|--------------|
|
|
143
|
+
| TypeScript | Available |
|
|
144
|
+
| Python | Coming soon |
|
|
145
|
+
| Java | Coming soon |
|
|
146
|
+
| Go | Coming soon |
|
|
147
|
+
| C# | Coming soon |
|
|
148
|
+
|
|
149
|
+
Stay tuned for updates as we work to expand support to other popular programming languages!
|
|
150
|
+
|
|
151
|
+
## Contributing
|
|
152
|
+
|
|
153
|
+
This project welcomes contributions and suggestions. Most contributions require you to agree to a
|
|
154
|
+
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
|
|
155
|
+
the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
|
|
156
|
+
|
|
157
|
+
When you submit a pull request, a CLA bot will automatically determine whether you need to provide
|
|
158
|
+
a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
|
|
159
|
+
provided by the bot. You will only need to do this once across all repos using our CLA.
|
|
160
|
+
|
|
161
|
+
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
|
|
162
|
+
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
|
|
163
|
+
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
|
|
164
|
+
|
|
165
|
+
We welcome contributions to this project! See our documentation on [how to get started contributing](./docs/CONTRIBUTING.md).
|
|
166
|
+
|
|
167
|
+
## Code Spaces
|
|
168
|
+
|
|
169
|
+
To open this repository in a Code Space, click the button below:
|
|
170
|
+
|
|
171
|
+
[](https://github.com/microsoft/terraform-azure-cdk-modules/codespaces)
|
|
172
|
+
|
|
173
|
+
## Trademarks
|
|
174
|
+
|
|
175
|
+
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft
|
|
176
|
+
trademarks or logos is subject to and must follow
|
|
177
|
+
[Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
|
|
178
|
+
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
|
|
179
|
+
Any use of third-party trademarks or logos are subject to those third-party's policies.
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# Azure Terraform CDK Constructs
|
|
2
|
+
|
|
3
|
+
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).
|
|
4
|
+
|
|
5
|
+
## Benefits of Using L2 Constructs
|
|
6
|
+
|
|
7
|
+
With L2 Constructs, you get the following benefits:
|
|
8
|
+
|
|
9
|
+
* **Abstraction**: Higher-level abstractions over Azure resources make your infrastructure code more declarative and easier to understand.
|
|
10
|
+
* **Reusability**: Encapsulate common patterns and best practices in your infrastructure code, promoting reusability across different projects and teams.
|
|
11
|
+
* **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.
|
|
12
|
+
* **Direct IDE Integration**: Access detailed documentation directly within your Integrated Development Environment (IDE), streamlining your development workflow: 
|
|
13
|
+
|
|
14
|
+
## Quick Example
|
|
15
|
+
|
|
16
|
+
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:
|
|
17
|
+
|
|
18
|
+
```python
|
|
19
|
+
|
|
20
|
+
// Create a new instance of a storage account as an object
|
|
21
|
+
const sa = new azcdk.azure_storageaccount.Account(stack, "storageaccount", {
|
|
22
|
+
name: "testStorageAccount",
|
|
23
|
+
location: "eastus",
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
// Add a container to the storage account by calling a method on the storage account object
|
|
27
|
+
const container = sa.addContainer("testcontainer");
|
|
28
|
+
|
|
29
|
+
// Add a blob to the container by calling a method on the container object
|
|
30
|
+
// The path "../../../test.txt" points to the source file to be uploaded as a blob
|
|
31
|
+
container.addBlob("testblob.txt", "../../../test.txt");
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Getting Started
|
|
35
|
+
|
|
36
|
+
This guide will walk you through the process of using the Azure L2 Constructs to define and provision infrastructure on Azure.
|
|
37
|
+
|
|
38
|
+
### Prerequisites
|
|
39
|
+
|
|
40
|
+
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.
|
|
41
|
+
|
|
42
|
+
### Installation
|
|
43
|
+
|
|
44
|
+
First, install the CDK for Terraform CLI globally using npm:
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
npm install -g cdktf-cli
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Next, initialize a new CDK for Terraform project with TypeScript template:
|
|
51
|
+
|
|
52
|
+
```sh
|
|
53
|
+
cdktf init --template="TypeScript" --local
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Install the AzureRM provider for CDKTF:
|
|
57
|
+
|
|
58
|
+
```sh
|
|
59
|
+
npm install @cdktf/provider-azurerm
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Then, add the Microsoft Terraform CDK constructs for Azure:
|
|
63
|
+
|
|
64
|
+
```sh
|
|
65
|
+
npm install @micrsoft/terraform-cdk-constructs
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Example 1: Creating a Storage Account
|
|
70
|
+
|
|
71
|
+
Now let's create a simple Azure storage account. The following TypeScript snippet defines a storage account resource using the CDKTF:
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
// Import necessary modules and classes
|
|
75
|
+
import * as azcdk from "@microsoft/terraform-cdk-constructs";
|
|
76
|
+
import { Construct } from 'constructs';
|
|
77
|
+
import { App, TerraformStack } from 'cdktf';
|
|
78
|
+
import { AzurermProvider } from "@cdktf/provider-azurerm/lib/provider";
|
|
79
|
+
|
|
80
|
+
// Define a new Terraform stack
|
|
81
|
+
class AzureAppInfra extends TerraformStack {
|
|
82
|
+
constructor(scope: Construct, name: string) {
|
|
83
|
+
super(scope, name);
|
|
84
|
+
|
|
85
|
+
// Initialize Azure provider
|
|
86
|
+
new AzurermProvider(this, "azureFeature", { features: {} });
|
|
87
|
+
|
|
88
|
+
// Create a new Azure storage account with the specified name and location
|
|
89
|
+
new azcdk.azure_storageaccount.Account(this, "storageaccount", {
|
|
90
|
+
name: "test42348808",
|
|
91
|
+
location: "eastus",
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Initialize the CDK app and synthesize Terraform configurations
|
|
97
|
+
const app = new App();
|
|
98
|
+
new AzureAppInfra(app, 'cdk');
|
|
99
|
+
app.synth();
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
After defining your infrastructure, generate the Terraform configuration files:
|
|
103
|
+
|
|
104
|
+
```sh
|
|
105
|
+
cdktf synth
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Finally, deploy your infrastructure to Azure:
|
|
109
|
+
|
|
110
|
+
```sh
|
|
111
|
+
cdktf deploy
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Supported Languages
|
|
115
|
+
|
|
116
|
+
Currently, our CDK L2 constructs are available in the following languages:
|
|
117
|
+
|
|
118
|
+
| Language | Status |
|
|
119
|
+
|------------|--------------|
|
|
120
|
+
| TypeScript | Available |
|
|
121
|
+
| Python | Coming soon |
|
|
122
|
+
| Java | Coming soon |
|
|
123
|
+
| Go | Coming soon |
|
|
124
|
+
| C# | Coming soon |
|
|
125
|
+
|
|
126
|
+
Stay tuned for updates as we work to expand support to other popular programming languages!
|
|
127
|
+
|
|
128
|
+
## Contributing
|
|
129
|
+
|
|
130
|
+
This project welcomes contributions and suggestions. Most contributions require you to agree to a
|
|
131
|
+
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
|
|
132
|
+
the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
|
|
133
|
+
|
|
134
|
+
When you submit a pull request, a CLA bot will automatically determine whether you need to provide
|
|
135
|
+
a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
|
|
136
|
+
provided by the bot. You will only need to do this once across all repos using our CLA.
|
|
137
|
+
|
|
138
|
+
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
|
|
139
|
+
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
|
|
140
|
+
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
|
|
141
|
+
|
|
142
|
+
We welcome contributions to this project! See our documentation on [how to get started contributing](./docs/CONTRIBUTING.md).
|
|
143
|
+
|
|
144
|
+
## Code Spaces
|
|
145
|
+
|
|
146
|
+
To open this repository in a Code Space, click the button below:
|
|
147
|
+
|
|
148
|
+
[](https://github.com/microsoft/terraform-azure-cdk-modules/codespaces)
|
|
149
|
+
|
|
150
|
+
## Trademarks
|
|
151
|
+
|
|
152
|
+
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft
|
|
153
|
+
trademarks or logos is subject to and must follow
|
|
154
|
+
[Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
|
|
155
|
+
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
|
|
156
|
+
Any use of third-party trademarks or logos are subject to those third-party's policies.
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import setuptools
|
|
3
|
+
|
|
4
|
+
kwargs = json.loads(
|
|
5
|
+
"""
|
|
6
|
+
{
|
|
7
|
+
"name": "microsoft-cdktfconstructs",
|
|
8
|
+
"version": "0.0.3.dev11",
|
|
9
|
+
"description": "A collection of CDK modules for provisioning and managing Terraform resources efficiently.",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"url": "https://github.com/azure/terraform-cdk-constructs.git",
|
|
12
|
+
"long_description_content_type": "text/markdown",
|
|
13
|
+
"author": "Microsoft",
|
|
14
|
+
"bdist_wheel": {
|
|
15
|
+
"universal": true
|
|
16
|
+
},
|
|
17
|
+
"project_urls": {
|
|
18
|
+
"Source": "https://github.com/azure/terraform-cdk-constructs.git"
|
|
19
|
+
},
|
|
20
|
+
"package_dir": {
|
|
21
|
+
"": "src"
|
|
22
|
+
},
|
|
23
|
+
"packages": [
|
|
24
|
+
"microsoft_cdktfconstructs",
|
|
25
|
+
"microsoft_cdktfconstructs._jsii",
|
|
26
|
+
"microsoft_cdktfconstructs.azure_applicationgateway",
|
|
27
|
+
"microsoft_cdktfconstructs.azure_applicationinsights",
|
|
28
|
+
"microsoft_cdktfconstructs.azure_containerregistry",
|
|
29
|
+
"microsoft_cdktfconstructs.azure_eventhub",
|
|
30
|
+
"microsoft_cdktfconstructs.azure_functionapp",
|
|
31
|
+
"microsoft_cdktfconstructs.azure_keyvault",
|
|
32
|
+
"microsoft_cdktfconstructs.azure_kubernetes",
|
|
33
|
+
"microsoft_cdktfconstructs.azure_kusto",
|
|
34
|
+
"microsoft_cdktfconstructs.azure_loganalytics",
|
|
35
|
+
"microsoft_cdktfconstructs.azure_metricalert",
|
|
36
|
+
"microsoft_cdktfconstructs.azure_networksecuritygroup",
|
|
37
|
+
"microsoft_cdktfconstructs.azure_queryrulealert",
|
|
38
|
+
"microsoft_cdktfconstructs.azure_resourcegroup",
|
|
39
|
+
"microsoft_cdktfconstructs.azure_storageaccount",
|
|
40
|
+
"microsoft_cdktfconstructs.azure_virtualmachine",
|
|
41
|
+
"microsoft_cdktfconstructs.azure_virtualmachinescaleset",
|
|
42
|
+
"microsoft_cdktfconstructs.azure_virtualnetwork",
|
|
43
|
+
"microsoft_cdktfconstructs.core_azure"
|
|
44
|
+
],
|
|
45
|
+
"package_data": {
|
|
46
|
+
"microsoft_cdktfconstructs._jsii": [
|
|
47
|
+
"terraform-cdk-constructs@0.0.3-pre.11.jsii.tgz"
|
|
48
|
+
],
|
|
49
|
+
"microsoft_cdktfconstructs": [
|
|
50
|
+
"py.typed"
|
|
51
|
+
]
|
|
52
|
+
},
|
|
53
|
+
"python_requires": "~=3.8",
|
|
54
|
+
"install_requires": [
|
|
55
|
+
"cdktf-cdktf-provider-azurerm==9.0.8",
|
|
56
|
+
"cdktf==0.17.3",
|
|
57
|
+
"constructs>=10.1.106, <11.0.0",
|
|
58
|
+
"jsii>=1.98.0, <2.0.0",
|
|
59
|
+
"publication>=0.0.3",
|
|
60
|
+
"typeguard~=2.13.3"
|
|
61
|
+
],
|
|
62
|
+
"classifiers": [
|
|
63
|
+
"Intended Audience :: Developers",
|
|
64
|
+
"Operating System :: OS Independent",
|
|
65
|
+
"Programming Language :: JavaScript",
|
|
66
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
67
|
+
"Programming Language :: Python :: 3.8",
|
|
68
|
+
"Programming Language :: Python :: 3.9",
|
|
69
|
+
"Programming Language :: Python :: 3.10",
|
|
70
|
+
"Programming Language :: Python :: 3.11",
|
|
71
|
+
"Typing :: Typed",
|
|
72
|
+
"Development Status :: 5 - Production/Stable",
|
|
73
|
+
"License :: OSI Approved"
|
|
74
|
+
],
|
|
75
|
+
"scripts": []
|
|
76
|
+
}
|
|
77
|
+
"""
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
with open("README.md", encoding="utf8") as fp:
|
|
81
|
+
kwargs["long_description"] = fp.read()
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
setuptools.setup(**kwargs)
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
'''
|
|
2
|
+
# Azure Terraform CDK Constructs
|
|
3
|
+
|
|
4
|
+
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).
|
|
5
|
+
|
|
6
|
+
## Benefits of Using L2 Constructs
|
|
7
|
+
|
|
8
|
+
With L2 Constructs, you get the following benefits:
|
|
9
|
+
|
|
10
|
+
* **Abstraction**: Higher-level abstractions over Azure resources make your infrastructure code more declarative and easier to understand.
|
|
11
|
+
* **Reusability**: Encapsulate common patterns and best practices in your infrastructure code, promoting reusability across different projects and teams.
|
|
12
|
+
* **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.
|
|
13
|
+
* **Direct IDE Integration**: Access detailed documentation directly within your Integrated Development Environment (IDE), streamlining your development workflow: 
|
|
14
|
+
|
|
15
|
+
## Quick Example
|
|
16
|
+
|
|
17
|
+
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:
|
|
18
|
+
|
|
19
|
+
```python
|
|
20
|
+
|
|
21
|
+
// Create a new instance of a storage account as an object
|
|
22
|
+
const sa = new azcdk.azure_storageaccount.Account(stack, "storageaccount", {
|
|
23
|
+
name: "testStorageAccount",
|
|
24
|
+
location: "eastus",
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// Add a container to the storage account by calling a method on the storage account object
|
|
28
|
+
const container = sa.addContainer("testcontainer");
|
|
29
|
+
|
|
30
|
+
// Add a blob to the container by calling a method on the container object
|
|
31
|
+
// The path "../../../test.txt" points to the source file to be uploaded as a blob
|
|
32
|
+
container.addBlob("testblob.txt", "../../../test.txt");
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Getting Started
|
|
36
|
+
|
|
37
|
+
This guide will walk you through the process of using the Azure L2 Constructs to define and provision infrastructure on Azure.
|
|
38
|
+
|
|
39
|
+
### Prerequisites
|
|
40
|
+
|
|
41
|
+
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.
|
|
42
|
+
|
|
43
|
+
### Installation
|
|
44
|
+
|
|
45
|
+
First, install the CDK for Terraform CLI globally using npm:
|
|
46
|
+
|
|
47
|
+
```sh
|
|
48
|
+
npm install -g cdktf-cli
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Next, initialize a new CDK for Terraform project with TypeScript template:
|
|
52
|
+
|
|
53
|
+
```sh
|
|
54
|
+
cdktf init --template="TypeScript" --local
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Install the AzureRM provider for CDKTF:
|
|
58
|
+
|
|
59
|
+
```sh
|
|
60
|
+
npm install @cdktf/provider-azurerm
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Then, add the Microsoft Terraform CDK constructs for Azure:
|
|
64
|
+
|
|
65
|
+
```sh
|
|
66
|
+
npm install @micrsoft/terraform-cdk-constructs
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Example 1: Creating a Storage Account
|
|
71
|
+
|
|
72
|
+
Now let's create a simple Azure storage account. The following TypeScript snippet defines a storage account resource using the CDKTF:
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
// Import necessary modules and classes
|
|
76
|
+
import * as azcdk from "@microsoft/terraform-cdk-constructs";
|
|
77
|
+
import { Construct } from 'constructs';
|
|
78
|
+
import { App, TerraformStack } from 'cdktf';
|
|
79
|
+
import { AzurermProvider } from "@cdktf/provider-azurerm/lib/provider";
|
|
80
|
+
|
|
81
|
+
// Define a new Terraform stack
|
|
82
|
+
class AzureAppInfra extends TerraformStack {
|
|
83
|
+
constructor(scope: Construct, name: string) {
|
|
84
|
+
super(scope, name);
|
|
85
|
+
|
|
86
|
+
// Initialize Azure provider
|
|
87
|
+
new AzurermProvider(this, "azureFeature", { features: {} });
|
|
88
|
+
|
|
89
|
+
// Create a new Azure storage account with the specified name and location
|
|
90
|
+
new azcdk.azure_storageaccount.Account(this, "storageaccount", {
|
|
91
|
+
name: "test42348808",
|
|
92
|
+
location: "eastus",
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Initialize the CDK app and synthesize Terraform configurations
|
|
98
|
+
const app = new App();
|
|
99
|
+
new AzureAppInfra(app, 'cdk');
|
|
100
|
+
app.synth();
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
After defining your infrastructure, generate the Terraform configuration files:
|
|
104
|
+
|
|
105
|
+
```sh
|
|
106
|
+
cdktf synth
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Finally, deploy your infrastructure to Azure:
|
|
110
|
+
|
|
111
|
+
```sh
|
|
112
|
+
cdktf deploy
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Supported Languages
|
|
116
|
+
|
|
117
|
+
Currently, our CDK L2 constructs are available in the following languages:
|
|
118
|
+
|
|
119
|
+
| Language | Status |
|
|
120
|
+
|------------|--------------|
|
|
121
|
+
| TypeScript | Available |
|
|
122
|
+
| Python | Coming soon |
|
|
123
|
+
| Java | Coming soon |
|
|
124
|
+
| Go | Coming soon |
|
|
125
|
+
| C# | Coming soon |
|
|
126
|
+
|
|
127
|
+
Stay tuned for updates as we work to expand support to other popular programming languages!
|
|
128
|
+
|
|
129
|
+
## Contributing
|
|
130
|
+
|
|
131
|
+
This project welcomes contributions and suggestions. Most contributions require you to agree to a
|
|
132
|
+
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
|
|
133
|
+
the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
|
|
134
|
+
|
|
135
|
+
When you submit a pull request, a CLA bot will automatically determine whether you need to provide
|
|
136
|
+
a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
|
|
137
|
+
provided by the bot. You will only need to do this once across all repos using our CLA.
|
|
138
|
+
|
|
139
|
+
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
|
|
140
|
+
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
|
|
141
|
+
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
|
|
142
|
+
|
|
143
|
+
We welcome contributions to this project! See our documentation on [how to get started contributing](./docs/CONTRIBUTING.md).
|
|
144
|
+
|
|
145
|
+
## Code Spaces
|
|
146
|
+
|
|
147
|
+
To open this repository in a Code Space, click the button below:
|
|
148
|
+
|
|
149
|
+
[](https://github.com/microsoft/terraform-azure-cdk-modules/codespaces)
|
|
150
|
+
|
|
151
|
+
## Trademarks
|
|
152
|
+
|
|
153
|
+
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft
|
|
154
|
+
trademarks or logos is subject to and must follow
|
|
155
|
+
[Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
|
|
156
|
+
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
|
|
157
|
+
Any use of third-party trademarks or logos are subject to those third-party's policies.
|
|
158
|
+
'''
|
|
159
|
+
from pkgutil import extend_path
|
|
160
|
+
__path__ = extend_path(__path__, __name__)
|
|
161
|
+
|
|
162
|
+
import abc
|
|
163
|
+
import builtins
|
|
164
|
+
import datetime
|
|
165
|
+
import enum
|
|
166
|
+
import typing
|
|
167
|
+
|
|
168
|
+
import jsii
|
|
169
|
+
import publication
|
|
170
|
+
import typing_extensions
|
|
171
|
+
|
|
172
|
+
from typeguard import check_type
|
|
173
|
+
|
|
174
|
+
from ._jsii import *
|
|
175
|
+
|
|
176
|
+
__all__ = [
|
|
177
|
+
"azure_applicationgateway",
|
|
178
|
+
"azure_applicationinsights",
|
|
179
|
+
"azure_containerregistry",
|
|
180
|
+
"azure_eventhub",
|
|
181
|
+
"azure_functionapp",
|
|
182
|
+
"azure_keyvault",
|
|
183
|
+
"azure_kubernetes",
|
|
184
|
+
"azure_kusto",
|
|
185
|
+
"azure_loganalytics",
|
|
186
|
+
"azure_metricalert",
|
|
187
|
+
"azure_networksecuritygroup",
|
|
188
|
+
"azure_queryrulealert",
|
|
189
|
+
"azure_resourcegroup",
|
|
190
|
+
"azure_storageaccount",
|
|
191
|
+
"azure_virtualmachine",
|
|
192
|
+
"azure_virtualmachinescaleset",
|
|
193
|
+
"azure_virtualnetwork",
|
|
194
|
+
"core_azure",
|
|
195
|
+
]
|
|
196
|
+
|
|
197
|
+
publication.publish()
|
|
198
|
+
|
|
199
|
+
# Loading modules to ensure their types are registered with the jsii runtime library
|
|
200
|
+
from . import azure_applicationgateway
|
|
201
|
+
from . import azure_applicationinsights
|
|
202
|
+
from . import azure_containerregistry
|
|
203
|
+
from . import azure_eventhub
|
|
204
|
+
from . import azure_functionapp
|
|
205
|
+
from . import azure_keyvault
|
|
206
|
+
from . import azure_kubernetes
|
|
207
|
+
from . import azure_kusto
|
|
208
|
+
from . import azure_loganalytics
|
|
209
|
+
from . import azure_metricalert
|
|
210
|
+
from . import azure_networksecuritygroup
|
|
211
|
+
from . import azure_queryrulealert
|
|
212
|
+
from . import azure_resourcegroup
|
|
213
|
+
from . import azure_storageaccount
|
|
214
|
+
from . import azure_virtualmachine
|
|
215
|
+
from . import azure_virtualmachinescaleset
|
|
216
|
+
from . import azure_virtualnetwork
|
|
217
|
+
from . import core_azure
|