Hi I am following a tutorial: Creating Kubernetes Cluster on Azure with Terraform and Python using CDK for Terraform | by Guray Yildirim | Medium
I get few errors when trying to create a Kubernetes cluster and I am not sure where in my python script I am having the error. I have updated everything on my end, but the issue is still there. Any help?
My code:
#!/usr/bin/env python
from constructs import Construct
from cdktf import App, TerraformStack, TerraformOutput
from imports.azurerm import
AzurermProvider,
KubernetesCluster,
KubernetesClusterDefaultNodePool,
KubernetesClusterIdentity, ResourceGroupConfig, AzurermProviderFeatures
class MyStack(TerraformStack):
def init(self, scope: Construct, ns: str):
super().init(scope, ns)
# define resources here
features = AzurermProviderFeatures()
provider = AzurermProvider(self, 'azure', features=[features])
node_pool = KubernetesClusterDefaultNodePool(
name='default', node_count=1, vm_size='Standard_D2_v2')
resource_group = ResourceGroupConfig(name='dev-python-automation', location='East US')
identity = KubernetesClusterIdentity(type='SystemAssigned')
cluster = KubernetesCluster(
self, 'our-kube-cluster',
name='our-kube-cluster',
default_node_pool=[node_pool],
dns_prefix='test',
location=resource_group.location,
resource_group_name=resource_group.name,
identity=[identity],
tags={"foo": "bar"}
)
app = App()
MyStack(app, “test”)
app.synth()
Error:
[2022-02-21T13:47:23.659] [ERROR] default - jsii.errors.JavaScriptError:
Error: Got an array where a azurerm.AzurermProviderFeatures was expected. Did you mean to pass a variable number of arguments?
at Object.deserialize (/private/var/folders/yv/2hr2lc0n0dx5hxgfvz8n6h8m0000gn/T/tmp9ehl51ie/lib/program.js:9331:31)
at Kernel._toSandbox (/private/var/folders/yv/2hr2lc0n0dx5hxgfvz8n6h8m0000gn/T/tmp9ehl51ie/lib/program.js:8763:69)
at /private/var/folders/yv/2hr2lc0n0dx5hxgfvz8n6h8m0000gn/T/tmp9ehl51ie/lib/program.js:9352:37
at mapValues (/private/var/folders/yv/2hr2lc0n0dx5hxgfvz8n6h8m0000gn/T/tmp9ehl51ie/lib/program.js:9623:35)
at Object.deserialize (/private/var/folders/yv/2hr2lc0n0dx5hxgfvz8n6h8m0000gn/T/tmp9ehl51ie/lib/program.js:9348:28)
at Kernel._toSandbox (/private/var/folders/yv/2hr2lc0n0dx5hxgfvz8n6h8m0000gn/T/tmp9ehl51ie/lib/program.js:8763:69)
at /private/var/folders/yv/2hr2lc0n0dx5hxgfvz8n6h8m0000gn/T/tmp9ehl51ie/lib/program.js:8811:42
at Array.map ()
at Kernel._boxUnboxParameters (/private/var/folders/yv/2hr2lc0n0dx5hxgfvz8n6h8m0000gn/T/tmp9ehl51ie/lib/program.js:8811:27)
at Kernel._toSandboxValues (/private/var/folders/yv/2hr2lc0n0dx5hxgfvz8n6h8m0000gn/T/tmp9ehl51ie/lib/program.js:8797:29)
The above exception was the direct cause of the following exception: