forked from hashicorp/terraform-cdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
executable file
·38 lines (32 loc) · 1022 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python
import os
from constructs import Construct
from cdktf import App, TerraformStack
from imports.ucloud import DataUcloudImages, Instance, UcloudProvider
class MyStack(TerraformStack):
def __init__(self, scope: Construct, ns: str):
super().__init__(scope, ns)
UcloudProvider(
self, "UCloud",
region="cn-bj2",
project_id=os.getenv("UCLOUD_PROJECT_ID") or "",
)
images = DataUcloudImages(
self, "images",
availability_zone="cn-bj2-04",
name_regex="^CentOS 8.2 64",
image_type="base",
)
Instance(
self, "web",
availability_zone="cn-bj2-04",
image_id=images.images("0").id,
instance_type="n-basic-2",
root_password="wA1234567",
name="cdktf-example-instance",
tag="tf-example",
boot_disk_type="cloud_ssd",
)
app = App()
MyStack(app, "python-ucloud")
app.synth()