tencentcloud.KubernetesLogConfig
Explore with Pulumi AI
Provides a resource to create a tke kubernetes_log_config
Example Usage
Create a cls log config
import * as pulumi from "@pulumi/pulumi";
import * as tencentcloud from "@pulumi/tencentcloud";
const vpcOne = tencentcloud.getVpcSubnets({
isDefault: true,
availabilityZone: "ap-guangzhou-3",
});
const firstVpcId = vpcOne.then(vpcOne => vpcOne.instanceLists?.[0]?.vpcId);
const firstSubnetId = vpcOne.then(vpcOne => vpcOne.instanceLists?.[0]?.subnetId);
const gz = tencentcloud.getAvailabilityZonesByProduct({
name: "ap-guangzhou-3",
product: "ckafka",
});
const zoneId = gz.then(gz => gz.zones?.[0]?.id);
const config = new pulumi.Config();
const exampleClusterCidr = config.get("exampleClusterCidr") || "10.31.0.0/16";
const example = new tencentcloud.KubernetesCluster("example", {
vpcId: firstVpcId,
clusterCidr: exampleClusterCidr,
clusterMaxPodNum: 32,
clusterName: "tf_example_cluster",
clusterDesc: "example for tke cluster",
clusterMaxServiceNum: 32,
clusterInternet: false,
clusterVersion: "1.22.5",
clusterOs: "tlinux2.2(tkernel3)x86_64",
clusterDeployType: "MANAGED_CLUSTER",
logAgent: {
enabled: true,
},
});
// without any worker config
const logset = new tencentcloud.ClsLogset("logset", {
logsetName: "tf-test-example",
tags: {
createdBy: "terraform",
},
});
const kubernetesLogConfigCls = new tencentcloud.KubernetesLogConfig("kubernetesLogConfigCls", {
logConfigName: "tf-test-cls",
clusterId: example.kubernetesClusterId,
logsetId: logset.clsLogsetId,
logConfig: JSON.stringify({
apiVersion: "cls.cloud.tencent.com/v1",
kind: "LogConfig",
metadata: {
name: "tf-test-cls",
},
spec: {
clsDetail: {
extractRule: {
backtracking: "0",
isGBK: "false",
jsonStandard: "false",
unMatchUpload: "false",
},
indexs: [
{
indexName: "namespace",
},
{
indexName: "pod_name",
},
{
indexName: "container_name",
},
],
logFormat: "default",
logType: "minimalist_log",
maxSplitPartitions: 0,
region: "ap-guangzhou",
storageType: "",
},
inputDetail: {
containerStdout: {
metadataContainer: [
"namespace",
"pod_name",
"pod_ip",
"pod_uid",
"container_id",
"container_name",
"image_name",
"cluster_id",
],
nsLabelSelector: "",
workloads: [{
kind: "deployment",
name: "testlog1",
namespace: "default",
}],
},
type: "container_stdout",
},
},
}),
});
import pulumi
import json
import pulumi_tencentcloud as tencentcloud
vpc_one = tencentcloud.get_vpc_subnets(is_default=True,
availability_zone="ap-guangzhou-3")
first_vpc_id = vpc_one.instance_lists[0].vpc_id
first_subnet_id = vpc_one.instance_lists[0].subnet_id
gz = tencentcloud.get_availability_zones_by_product(name="ap-guangzhou-3",
product="ckafka")
zone_id = gz.zones[0].id
config = pulumi.Config()
example_cluster_cidr = config.get("exampleClusterCidr")
if example_cluster_cidr is None:
example_cluster_cidr = "10.31.0.0/16"
example = tencentcloud.KubernetesCluster("example",
vpc_id=first_vpc_id,
cluster_cidr=example_cluster_cidr,
cluster_max_pod_num=32,
cluster_name="tf_example_cluster",
cluster_desc="example for tke cluster",
cluster_max_service_num=32,
cluster_internet=False,
cluster_version="1.22.5",
cluster_os="tlinux2.2(tkernel3)x86_64",
cluster_deploy_type="MANAGED_CLUSTER",
log_agent={
"enabled": True,
})
# without any worker config
logset = tencentcloud.ClsLogset("logset",
logset_name="tf-test-example",
tags={
"createdBy": "terraform",
})
kubernetes_log_config_cls = tencentcloud.KubernetesLogConfig("kubernetesLogConfigCls",
log_config_name="tf-test-cls",
cluster_id=example.kubernetes_cluster_id,
logset_id=logset.cls_logset_id,
log_config=json.dumps({
"apiVersion": "cls.cloud.tencent.com/v1",
"kind": "LogConfig",
"metadata": {
"name": "tf-test-cls",
},
"spec": {
"clsDetail": {
"extractRule": {
"backtracking": "0",
"isGBK": "false",
"jsonStandard": "false",
"unMatchUpload": "false",
},
"indexs": [
{
"indexName": "namespace",
},
{
"indexName": "pod_name",
},
{
"indexName": "container_name",
},
],
"logFormat": "default",
"logType": "minimalist_log",
"maxSplitPartitions": 0,
"region": "ap-guangzhou",
"storageType": "",
},
"inputDetail": {
"containerStdout": {
"metadataContainer": [
"namespace",
"pod_name",
"pod_ip",
"pod_uid",
"container_id",
"container_name",
"image_name",
"cluster_id",
],
"nsLabelSelector": "",
"workloads": [{
"kind": "deployment",
"name": "testlog1",
"namespace": "default",
}],
},
"type": "container_stdout",
},
},
}))
package main
import (
"encoding/json"
"github.com/pulumi/pulumi-terraform-provider/sdks/go/tencentcloud/tencentcloud"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
vpcOne, err := tencentcloud.GetVpcSubnets(ctx, &tencentcloud.GetVpcSubnetsArgs{
IsDefault: pulumi.BoolRef(true),
AvailabilityZone: pulumi.StringRef("ap-guangzhou-3"),
}, nil)
if err != nil {
return err
}
firstVpcId := vpcOne.InstanceLists[0].VpcId
_ := vpcOne.InstanceLists[0].SubnetId
gz, err := tencentcloud.GetAvailabilityZonesByProduct(ctx, &tencentcloud.GetAvailabilityZonesByProductArgs{
Name: pulumi.StringRef("ap-guangzhou-3"),
Product: "ckafka",
}, nil)
if err != nil {
return err
}
_ := gz.Zones[0].Id
cfg := config.New(ctx, "")
exampleClusterCidr := "10.31.0.0/16"
if param := cfg.Get("exampleClusterCidr"); param != "" {
exampleClusterCidr = param
}
example, err := tencentcloud.NewKubernetesCluster(ctx, "example", &tencentcloud.KubernetesClusterArgs{
VpcId: pulumi.String(firstVpcId),
ClusterCidr: pulumi.String(exampleClusterCidr),
ClusterMaxPodNum: pulumi.Float64(32),
ClusterName: pulumi.String("tf_example_cluster"),
ClusterDesc: pulumi.String("example for tke cluster"),
ClusterMaxServiceNum: pulumi.Float64(32),
ClusterInternet: pulumi.Bool(false),
ClusterVersion: pulumi.String("1.22.5"),
ClusterOs: pulumi.String("tlinux2.2(tkernel3)x86_64"),
ClusterDeployType: pulumi.String("MANAGED_CLUSTER"),
LogAgent: &tencentcloud.KubernetesClusterLogAgentArgs{
Enabled: pulumi.Bool(true),
},
})
if err != nil {
return err
}
logset, err := tencentcloud.NewClsLogset(ctx, "logset", &tencentcloud.ClsLogsetArgs{
LogsetName: pulumi.String("tf-test-example"),
Tags: pulumi.StringMap{
"createdBy": pulumi.String("terraform"),
},
})
if err != nil {
return err
}
tmpJSON0, err := json.Marshal(map[string]interface{}{
"apiVersion": "cls.cloud.tencent.com/v1",
"kind": "LogConfig",
"metadata": map[string]interface{}{
"name": "tf-test-cls",
},
"spec": map[string]interface{}{
"clsDetail": map[string]interface{}{
"extractRule": map[string]interface{}{
"backtracking": "0",
"isGBK": "false",
"jsonStandard": "false",
"unMatchUpload": "false",
},
"indexs": []map[string]interface{}{
map[string]interface{}{
"indexName": "namespace",
},
map[string]interface{}{
"indexName": "pod_name",
},
map[string]interface{}{
"indexName": "container_name",
},
},
"logFormat": "default",
"logType": "minimalist_log",
"maxSplitPartitions": 0,
"region": "ap-guangzhou",
"storageType": "",
},
"inputDetail": map[string]interface{}{
"containerStdout": map[string]interface{}{
"metadataContainer": []string{
"namespace",
"pod_name",
"pod_ip",
"pod_uid",
"container_id",
"container_name",
"image_name",
"cluster_id",
},
"nsLabelSelector": "",
"workloads": []map[string]interface{}{
map[string]interface{}{
"kind": "deployment",
"name": "testlog1",
"namespace": "default",
},
},
},
"type": "container_stdout",
},
},
})
if err != nil {
return err
}
json0 := string(tmpJSON0)
_, err = tencentcloud.NewKubernetesLogConfig(ctx, "kubernetesLogConfigCls", &tencentcloud.KubernetesLogConfigArgs{
LogConfigName: pulumi.String("tf-test-cls"),
ClusterId: example.KubernetesClusterId,
LogsetId: logset.ClsLogsetId,
LogConfig: pulumi.String(json0),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using Pulumi;
using Tencentcloud = Pulumi.Tencentcloud;
return await Deployment.RunAsync(() =>
{
var vpcOne = Tencentcloud.GetVpcSubnets.Invoke(new()
{
IsDefault = true,
AvailabilityZone = "ap-guangzhou-3",
});
var firstVpcId = vpcOne.Apply(getVpcSubnetsResult => getVpcSubnetsResult.InstanceLists[0]?.VpcId);
var firstSubnetId = vpcOne.Apply(getVpcSubnetsResult => getVpcSubnetsResult.InstanceLists[0]?.SubnetId);
var gz = Tencentcloud.GetAvailabilityZonesByProduct.Invoke(new()
{
Name = "ap-guangzhou-3",
Product = "ckafka",
});
var zoneId = gz.Apply(getAvailabilityZonesByProductResult => getAvailabilityZonesByProductResult.Zones[0]?.Id);
var config = new Config();
var exampleClusterCidr = config.Get("exampleClusterCidr") ?? "10.31.0.0/16";
var example = new Tencentcloud.KubernetesCluster("example", new()
{
VpcId = firstVpcId,
ClusterCidr = exampleClusterCidr,
ClusterMaxPodNum = 32,
ClusterName = "tf_example_cluster",
ClusterDesc = "example for tke cluster",
ClusterMaxServiceNum = 32,
ClusterInternet = false,
ClusterVersion = "1.22.5",
ClusterOs = "tlinux2.2(tkernel3)x86_64",
ClusterDeployType = "MANAGED_CLUSTER",
LogAgent = new Tencentcloud.Inputs.KubernetesClusterLogAgentArgs
{
Enabled = true,
},
});
// without any worker config
var logset = new Tencentcloud.ClsLogset("logset", new()
{
LogsetName = "tf-test-example",
Tags =
{
{ "createdBy", "terraform" },
},
});
var kubernetesLogConfigCls = new Tencentcloud.KubernetesLogConfig("kubernetesLogConfigCls", new()
{
LogConfigName = "tf-test-cls",
ClusterId = example.KubernetesClusterId,
LogsetId = logset.ClsLogsetId,
LogConfig = JsonSerializer.Serialize(new Dictionary<string, object?>
{
["apiVersion"] = "cls.cloud.tencent.com/v1",
["kind"] = "LogConfig",
["metadata"] = new Dictionary<string, object?>
{
["name"] = "tf-test-cls",
},
["spec"] = new Dictionary<string, object?>
{
["clsDetail"] = new Dictionary<string, object?>
{
["extractRule"] = new Dictionary<string, object?>
{
["backtracking"] = "0",
["isGBK"] = "false",
["jsonStandard"] = "false",
["unMatchUpload"] = "false",
},
["indexs"] = new[]
{
new Dictionary<string, object?>
{
["indexName"] = "namespace",
},
new Dictionary<string, object?>
{
["indexName"] = "pod_name",
},
new Dictionary<string, object?>
{
["indexName"] = "container_name",
},
},
["logFormat"] = "default",
["logType"] = "minimalist_log",
["maxSplitPartitions"] = 0,
["region"] = "ap-guangzhou",
["storageType"] = "",
},
["inputDetail"] = new Dictionary<string, object?>
{
["containerStdout"] = new Dictionary<string, object?>
{
["metadataContainer"] = new[]
{
"namespace",
"pod_name",
"pod_ip",
"pod_uid",
"container_id",
"container_name",
"image_name",
"cluster_id",
},
["nsLabelSelector"] = "",
["workloads"] = new[]
{
new Dictionary<string, object?>
{
["kind"] = "deployment",
["name"] = "testlog1",
["namespace"] = "default",
},
},
},
["type"] = "container_stdout",
},
},
}),
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.tencentcloud.TencentcloudFunctions;
import com.pulumi.tencentcloud.inputs.GetVpcSubnetsArgs;
import com.pulumi.tencentcloud.inputs.GetAvailabilityZonesByProductArgs;
import com.pulumi.tencentcloud.KubernetesCluster;
import com.pulumi.tencentcloud.KubernetesClusterArgs;
import com.pulumi.tencentcloud.inputs.KubernetesClusterLogAgentArgs;
import com.pulumi.tencentcloud.ClsLogset;
import com.pulumi.tencentcloud.ClsLogsetArgs;
import com.pulumi.tencentcloud.KubernetesLogConfig;
import com.pulumi.tencentcloud.KubernetesLogConfigArgs;
import static com.pulumi.codegen.internal.Serialization.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
final var config = ctx.config();
final var vpcOne = TencentcloudFunctions.getVpcSubnets(GetVpcSubnetsArgs.builder()
.isDefault(true)
.availabilityZone("ap-guangzhou-3")
.build());
final var firstVpcId = vpcOne.applyValue(getVpcSubnetsResult -> getVpcSubnetsResult.instanceLists()[0].vpcId());
final var firstSubnetId = vpcOne.applyValue(getVpcSubnetsResult -> getVpcSubnetsResult.instanceLists()[0].subnetId());
final var gz = TencentcloudFunctions.getAvailabilityZonesByProduct(GetAvailabilityZonesByProductArgs.builder()
.name("ap-guangzhou-3")
.product("ckafka")
.build());
final var zoneId = gz.applyValue(getAvailabilityZonesByProductResult -> getAvailabilityZonesByProductResult.zones()[0].id());
final var exampleClusterCidr = config.get("exampleClusterCidr").orElse("10.31.0.0/16");
var example = new KubernetesCluster("example", KubernetesClusterArgs.builder()
.vpcId(firstVpcId)
.clusterCidr(exampleClusterCidr)
.clusterMaxPodNum(32)
.clusterName("tf_example_cluster")
.clusterDesc("example for tke cluster")
.clusterMaxServiceNum(32)
.clusterInternet(false)
.clusterVersion("1.22.5")
.clusterOs("tlinux2.2(tkernel3)x86_64")
.clusterDeployType("MANAGED_CLUSTER")
.logAgent(KubernetesClusterLogAgentArgs.builder()
.enabled(true)
.build())
.build());
// without any worker config
var logset = new ClsLogset("logset", ClsLogsetArgs.builder()
.logsetName("tf-test-example")
.tags(Map.of("createdBy", "terraform"))
.build());
var kubernetesLogConfigCls = new KubernetesLogConfig("kubernetesLogConfigCls", KubernetesLogConfigArgs.builder()
.logConfigName("tf-test-cls")
.clusterId(example.kubernetesClusterId())
.logsetId(logset.clsLogsetId())
.logConfig(serializeJson(
jsonObject(
jsonProperty("apiVersion", "cls.cloud.tencent.com/v1"),
jsonProperty("kind", "LogConfig"),
jsonProperty("metadata", jsonObject(
jsonProperty("name", "tf-test-cls")
)),
jsonProperty("spec", jsonObject(
jsonProperty("clsDetail", jsonObject(
jsonProperty("extractRule", jsonObject(
jsonProperty("backtracking", "0"),
jsonProperty("isGBK", "false"),
jsonProperty("jsonStandard", "false"),
jsonProperty("unMatchUpload", "false")
)),
jsonProperty("indexs", jsonArray(
jsonObject(
jsonProperty("indexName", "namespace")
),
jsonObject(
jsonProperty("indexName", "pod_name")
),
jsonObject(
jsonProperty("indexName", "container_name")
)
)),
jsonProperty("logFormat", "default"),
jsonProperty("logType", "minimalist_log"),
jsonProperty("maxSplitPartitions", 0),
jsonProperty("region", "ap-guangzhou"),
jsonProperty("storageType", "")
)),
jsonProperty("inputDetail", jsonObject(
jsonProperty("containerStdout", jsonObject(
jsonProperty("metadataContainer", jsonArray(
"namespace",
"pod_name",
"pod_ip",
"pod_uid",
"container_id",
"container_name",
"image_name",
"cluster_id"
)),
jsonProperty("nsLabelSelector", ""),
jsonProperty("workloads", jsonArray(jsonObject(
jsonProperty("kind", "deployment"),
jsonProperty("name", "testlog1"),
jsonProperty("namespace", "default")
)))
)),
jsonProperty("type", "container_stdout")
))
))
)))
.build());
}
}
configuration:
exampleClusterCidr:
type: string
default: 10.31.0.0/16
resources:
example:
type: tencentcloud:KubernetesCluster
properties:
vpcId: ${firstVpcId}
clusterCidr: ${exampleClusterCidr}
clusterMaxPodNum: 32
clusterName: tf_example_cluster
clusterDesc: example for tke cluster
clusterMaxServiceNum: 32
clusterInternet: false
# (can be ignored) open it after the nodes added
clusterVersion: 1.22.5
clusterOs: tlinux2.2(tkernel3)x86_64
clusterDeployType: MANAGED_CLUSTER
logAgent:
enabled: true
logset:
type: tencentcloud:ClsLogset
properties:
logsetName: tf-test-example
tags:
createdBy: terraform
kubernetesLogConfigCls:
type: tencentcloud:KubernetesLogConfig
properties:
logConfigName: tf-test-cls
clusterId: ${example.kubernetesClusterId}
logsetId: ${logset.clsLogsetId}
logConfig:
fn::toJSON:
apiVersion: cls.cloud.tencent.com/v1
kind: LogConfig
metadata:
name: tf-test-cls
spec:
clsDetail:
extractRule:
backtracking: '0'
isGBK: 'false'
jsonStandard: 'false'
unMatchUpload: 'false'
indexs:
- indexName: namespace
- indexName: pod_name
- indexName: container_name
logFormat: default
logType: minimalist_log
maxSplitPartitions: 0
region: ap-guangzhou
storageType: ""
inputDetail:
containerStdout:
metadataContainer:
- namespace
- pod_name
- pod_ip
- pod_uid
- container_id
- container_name
- image_name
- cluster_id
nsLabelSelector: ""
workloads:
- kind: deployment
name: testlog1
namespace: default
type: container_stdout
variables:
firstVpcId: ${vpcOne.instanceLists[0].vpcId}
firstSubnetId: ${vpcOne.instanceLists[0].subnetId}
zoneId: ${gz.zones[0].id}
vpcOne:
fn::invoke:
function: tencentcloud:getVpcSubnets
arguments:
isDefault: true
availabilityZone: ap-guangzhou-3
gz:
fn::invoke:
function: tencentcloud:getAvailabilityZonesByProduct
arguments:
name: ap-guangzhou-3
product: ckafka
Create a ckafka log config
import * as pulumi from "@pulumi/pulumi";
import * as tencentcloud from "@pulumi/tencentcloud";
const exampleCkafkaInstance = new tencentcloud.CkafkaInstance("exampleCkafkaInstance", {
instanceName: "ckafka-instance-postpaid",
zoneId: local.zone_id,
vpcId: local.first_vpc_id,
subnetId: local.first_subnet_id,
msgRetentionTime: 1300,
kafkaVersion: "1.1.1",
diskSize: 500,
bandWidth: 20,
diskType: "CLOUD_BASIC",
partition: 400,
chargeType: "POSTPAID_BY_HOUR",
config: {
autoCreateTopicEnable: true,
defaultNumPartitions: 3,
defaultReplicationFactor: 3,
},
dynamicRetentionConfig: {
enable: 1,
},
});
const exampleCkafkaTopic = new tencentcloud.CkafkaTopic("exampleCkafkaTopic", {
instanceId: exampleCkafkaInstance.ckafkaInstanceId,
topicName: "tmp",
note: "topic note",
replicaNum: 2,
partitionNum: 1,
cleanUpPolicy: "delete",
syncReplicaMinNum: 1,
uncleanLeaderElectionEnable: false,
retention: 60000,
});
const ckafkaTopic = exampleCkafkaTopic.topicName;
const kubernetesLogConfigCkafka = new tencentcloud.KubernetesLogConfig("kubernetesLogConfigCkafka", {
logConfigName: "tf-test-ckafka",
clusterId: tencentcloud_kubernetes_cluster.example.id,
logsetId: tencentcloud_cls_logset.logset.id,
logConfig: pulumi.jsonStringify({
apiVersion: "cls.cloud.tencent.com/v1",
kind: "LogConfig",
metadata: {
name: "tf-test-ckafka",
},
spec: {
inputDetail: {
containerStdout: {
allContainers: true,
namespace: "default",
nsLabelSelector: "",
},
type: "container_stdout",
},
kafkaDetail: {
brokers: "172.16.0.30:9092",
extractRule: {},
instanceId: "",
kafkaType: "SelfBuildKafka",
logType: "minimalist_log",
messageKey: {
value: "",
valueFrom: {
fieldRef: {
fieldPath: "",
},
},
},
metadata: {},
timestampFormat: "double",
timestampKey: "",
topic: ckafkaTopic,
},
},
}),
});
import pulumi
import json
import pulumi_tencentcloud as tencentcloud
example_ckafka_instance = tencentcloud.CkafkaInstance("exampleCkafkaInstance",
instance_name="ckafka-instance-postpaid",
zone_id=local["zone_id"],
vpc_id=local["first_vpc_id"],
subnet_id=local["first_subnet_id"],
msg_retention_time=1300,
kafka_version="1.1.1",
disk_size=500,
band_width=20,
disk_type="CLOUD_BASIC",
partition=400,
charge_type="POSTPAID_BY_HOUR",
config={
"auto_create_topic_enable": True,
"default_num_partitions": 3,
"default_replication_factor": 3,
},
dynamic_retention_config={
"enable": 1,
})
example_ckafka_topic = tencentcloud.CkafkaTopic("exampleCkafkaTopic",
instance_id=example_ckafka_instance.ckafka_instance_id,
topic_name="tmp",
note="topic note",
replica_num=2,
partition_num=1,
clean_up_policy="delete",
sync_replica_min_num=1,
unclean_leader_election_enable=False,
retention=60000)
ckafka_topic = example_ckafka_topic.topic_name
kubernetes_log_config_ckafka = tencentcloud.KubernetesLogConfig("kubernetesLogConfigCkafka",
log_config_name="tf-test-ckafka",
cluster_id=tencentcloud_kubernetes_cluster["example"]["id"],
logset_id=tencentcloud_cls_logset["logset"]["id"],
log_config=pulumi.Output.json_dumps({
"apiVersion": "cls.cloud.tencent.com/v1",
"kind": "LogConfig",
"metadata": {
"name": "tf-test-ckafka",
},
"spec": {
"inputDetail": {
"containerStdout": {
"allContainers": True,
"namespace": "default",
"nsLabelSelector": "",
},
"type": "container_stdout",
},
"kafkaDetail": {
"brokers": "172.16.0.30:9092",
"extractRule": {},
"instanceId": "",
"kafkaType": "SelfBuildKafka",
"logType": "minimalist_log",
"messageKey": {
"value": "",
"valueFrom": {
"fieldRef": {
"fieldPath": "",
},
},
},
"metadata": {},
"timestampFormat": "double",
"timestampKey": "",
"topic": ckafka_topic,
},
},
}))
package main
import (
"encoding/json"
"github.com/pulumi/pulumi-terraform-provider/sdks/go/tencentcloud/tencentcloud"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
exampleCkafkaInstance, err := tencentcloud.NewCkafkaInstance(ctx, "exampleCkafkaInstance", &tencentcloud.CkafkaInstanceArgs{
InstanceName: pulumi.String("ckafka-instance-postpaid"),
ZoneId: pulumi.Any(local.Zone_id),
VpcId: pulumi.Any(local.First_vpc_id),
SubnetId: pulumi.Any(local.First_subnet_id),
MsgRetentionTime: pulumi.Float64(1300),
KafkaVersion: pulumi.String("1.1.1"),
DiskSize: pulumi.Float64(500),
BandWidth: pulumi.Float64(20),
DiskType: pulumi.String("CLOUD_BASIC"),
Partition: pulumi.Float64(400),
ChargeType: pulumi.String("POSTPAID_BY_HOUR"),
Config: &tencentcloud.CkafkaInstanceConfigArgs{
AutoCreateTopicEnable: pulumi.Bool(true),
DefaultNumPartitions: pulumi.Float64(3),
DefaultReplicationFactor: pulumi.Float64(3),
},
DynamicRetentionConfig: &tencentcloud.CkafkaInstanceDynamicRetentionConfigArgs{
Enable: pulumi.Float64(1),
},
})
if err != nil {
return err
}
exampleCkafkaTopic, err := tencentcloud.NewCkafkaTopic(ctx, "exampleCkafkaTopic", &tencentcloud.CkafkaTopicArgs{
InstanceId: exampleCkafkaInstance.CkafkaInstanceId,
TopicName: pulumi.String("tmp"),
Note: pulumi.String("topic note"),
ReplicaNum: pulumi.Float64(2),
PartitionNum: pulumi.Float64(1),
CleanUpPolicy: pulumi.String("delete"),
SyncReplicaMinNum: pulumi.Float64(1),
UncleanLeaderElectionEnable: pulumi.Bool(false),
Retention: pulumi.Float64(60000),
})
if err != nil {
return err
}
ckafkaTopic := exampleCkafkaTopic.TopicName
_, err = tencentcloud.NewKubernetesLogConfig(ctx, "kubernetesLogConfigCkafka", &tencentcloud.KubernetesLogConfigArgs{
LogConfigName: pulumi.String("tf-test-ckafka"),
ClusterId: pulumi.Any(tencentcloud_kubernetes_cluster.Example.Id),
LogsetId: pulumi.Any(tencentcloud_cls_logset.Logset.Id),
LogConfig: ckafkaTopic.ApplyT(func(ckafkaTopic string) (pulumi.String, error) {
var _zero pulumi.String
tmpJSON0, err := json.Marshal(map[string]interface{}{
"apiVersion": "cls.cloud.tencent.com/v1",
"kind": "LogConfig",
"metadata": map[string]interface{}{
"name": "tf-test-ckafka",
},
"spec": map[string]interface{}{
"inputDetail": map[string]interface{}{
"containerStdout": map[string]interface{}{
"allContainers": true,
"namespace": "default",
"nsLabelSelector": "",
},
"type": "container_stdout",
},
"kafkaDetail": map[string]interface{}{
"brokers": "172.16.0.30:9092",
"extractRule": map[string]interface{}{},
"instanceId": "",
"kafkaType": "SelfBuildKafka",
"logType": "minimalist_log",
"messageKey": map[string]interface{}{
"value": "",
"valueFrom": map[string]interface{}{
"fieldRef": map[string]interface{}{
"fieldPath": "",
},
},
},
"metadata": map[string]interface{}{},
"timestampFormat": "double",
"timestampKey": "",
"topic": ckafkaTopic,
},
},
})
if err != nil {
return _zero, err
}
json0 := string(tmpJSON0)
return pulumi.String(json0), nil
}).(pulumi.StringOutput),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using Pulumi;
using Tencentcloud = Pulumi.Tencentcloud;
return await Deployment.RunAsync(() =>
{
var exampleCkafkaInstance = new Tencentcloud.CkafkaInstance("exampleCkafkaInstance", new()
{
InstanceName = "ckafka-instance-postpaid",
ZoneId = local.Zone_id,
VpcId = local.First_vpc_id,
SubnetId = local.First_subnet_id,
MsgRetentionTime = 1300,
KafkaVersion = "1.1.1",
DiskSize = 500,
BandWidth = 20,
DiskType = "CLOUD_BASIC",
Partition = 400,
ChargeType = "POSTPAID_BY_HOUR",
Config = new Tencentcloud.Inputs.CkafkaInstanceConfigArgs
{
AutoCreateTopicEnable = true,
DefaultNumPartitions = 3,
DefaultReplicationFactor = 3,
},
DynamicRetentionConfig = new Tencentcloud.Inputs.CkafkaInstanceDynamicRetentionConfigArgs
{
Enable = 1,
},
});
var exampleCkafkaTopic = new Tencentcloud.CkafkaTopic("exampleCkafkaTopic", new()
{
InstanceId = exampleCkafkaInstance.CkafkaInstanceId,
TopicName = "tmp",
Note = "topic note",
ReplicaNum = 2,
PartitionNum = 1,
CleanUpPolicy = "delete",
SyncReplicaMinNum = 1,
UncleanLeaderElectionEnable = false,
Retention = 60000,
});
var ckafkaTopic = exampleCkafkaTopic.TopicName;
var kubernetesLogConfigCkafka = new Tencentcloud.KubernetesLogConfig("kubernetesLogConfigCkafka", new()
{
LogConfigName = "tf-test-ckafka",
ClusterId = tencentcloud_kubernetes_cluster.Example.Id,
LogsetId = tencentcloud_cls_logset.Logset.Id,
LogConfig = Output.JsonSerialize(Output.Create(new Dictionary<string, object?>
{
["apiVersion"] = "cls.cloud.tencent.com/v1",
["kind"] = "LogConfig",
["metadata"] = new Dictionary<string, object?>
{
["name"] = "tf-test-ckafka",
},
["spec"] = new Dictionary<string, object?>
{
["inputDetail"] = new Dictionary<string, object?>
{
["containerStdout"] = new Dictionary<string, object?>
{
["allContainers"] = true,
["namespace"] = "default",
["nsLabelSelector"] = "",
},
["type"] = "container_stdout",
},
["kafkaDetail"] = new Dictionary<string, object?>
{
["brokers"] = "172.16.0.30:9092",
["extractRule"] = new Dictionary<string, object?>
{
},
["instanceId"] = "",
["kafkaType"] = "SelfBuildKafka",
["logType"] = "minimalist_log",
["messageKey"] = new Dictionary<string, object?>
{
["value"] = "",
["valueFrom"] = new Dictionary<string, object?>
{
["fieldRef"] = new Dictionary<string, object?>
{
["fieldPath"] = "",
},
},
},
["metadata"] = new Dictionary<string, object?>
{
},
["timestampFormat"] = "double",
["timestampKey"] = "",
["topic"] = ckafkaTopic,
},
},
})),
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.tencentcloud.CkafkaInstance;
import com.pulumi.tencentcloud.CkafkaInstanceArgs;
import com.pulumi.tencentcloud.inputs.CkafkaInstanceConfigArgs;
import com.pulumi.tencentcloud.inputs.CkafkaInstanceDynamicRetentionConfigArgs;
import com.pulumi.tencentcloud.CkafkaTopic;
import com.pulumi.tencentcloud.CkafkaTopicArgs;
import com.pulumi.tencentcloud.KubernetesLogConfig;
import com.pulumi.tencentcloud.KubernetesLogConfigArgs;
import static com.pulumi.codegen.internal.Serialization.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var exampleCkafkaInstance = new CkafkaInstance("exampleCkafkaInstance", CkafkaInstanceArgs.builder()
.instanceName("ckafka-instance-postpaid")
.zoneId(local.zone_id())
.vpcId(local.first_vpc_id())
.subnetId(local.first_subnet_id())
.msgRetentionTime(1300)
.kafkaVersion("1.1.1")
.diskSize(500)
.bandWidth(20)
.diskType("CLOUD_BASIC")
.partition(400)
.chargeType("POSTPAID_BY_HOUR")
.config(CkafkaInstanceConfigArgs.builder()
.autoCreateTopicEnable(true)
.defaultNumPartitions(3)
.defaultReplicationFactor(3)
.build())
.dynamicRetentionConfig(CkafkaInstanceDynamicRetentionConfigArgs.builder()
.enable(1)
.build())
.build());
var exampleCkafkaTopic = new CkafkaTopic("exampleCkafkaTopic", CkafkaTopicArgs.builder()
.instanceId(exampleCkafkaInstance.ckafkaInstanceId())
.topicName("tmp")
.note("topic note")
.replicaNum(2)
.partitionNum(1)
.cleanUpPolicy("delete")
.syncReplicaMinNum(1)
.uncleanLeaderElectionEnable(false)
.retention(60000)
.build());
final var ckafkaTopic = exampleCkafkaTopic.topicName();
var kubernetesLogConfigCkafka = new KubernetesLogConfig("kubernetesLogConfigCkafka", KubernetesLogConfigArgs.builder()
.logConfigName("tf-test-ckafka")
.clusterId(tencentcloud_kubernetes_cluster.example().id())
.logsetId(tencentcloud_cls_logset.logset().id())
.logConfig(ckafkaTopic.applyValue(ckafkaTopic -> serializeJson(
jsonObject(
jsonProperty("apiVersion", "cls.cloud.tencent.com/v1"),
jsonProperty("kind", "LogConfig"),
jsonProperty("metadata", jsonObject(
jsonProperty("name", "tf-test-ckafka")
)),
jsonProperty("spec", jsonObject(
jsonProperty("inputDetail", jsonObject(
jsonProperty("containerStdout", jsonObject(
jsonProperty("allContainers", true),
jsonProperty("namespace", "default"),
jsonProperty("nsLabelSelector", "")
)),
jsonProperty("type", "container_stdout")
)),
jsonProperty("kafkaDetail", jsonObject(
jsonProperty("brokers", "172.16.0.30:9092"),
jsonProperty("extractRule", jsonObject(
)),
jsonProperty("instanceId", ""),
jsonProperty("kafkaType", "SelfBuildKafka"),
jsonProperty("logType", "minimalist_log"),
jsonProperty("messageKey", jsonObject(
jsonProperty("value", ""),
jsonProperty("valueFrom", jsonObject(
jsonProperty("fieldRef", jsonObject(
jsonProperty("fieldPath", "")
))
))
)),
jsonProperty("metadata", jsonObject(
)),
jsonProperty("timestampFormat", "double"),
jsonProperty("timestampKey", ""),
jsonProperty("topic", ckafkaTopic)
))
))
))))
.build());
}
}
resources:
exampleCkafkaInstance:
type: tencentcloud:CkafkaInstance
properties:
instanceName: ckafka-instance-postpaid
zoneId: ${local.zone_id}
vpcId: ${local.first_vpc_id}
subnetId: ${local.first_subnet_id}
msgRetentionTime: 1300
kafkaVersion: 1.1.1
diskSize: 500
bandWidth: 20
diskType: CLOUD_BASIC
partition: 400
chargeType: POSTPAID_BY_HOUR
config:
autoCreateTopicEnable: true
defaultNumPartitions: 3
defaultReplicationFactor: 3
dynamicRetentionConfig:
enable: 1
exampleCkafkaTopic:
type: tencentcloud:CkafkaTopic
properties:
instanceId: ${exampleCkafkaInstance.ckafkaInstanceId}
topicName: tmp
note: topic note
replicaNum: 2
partitionNum: 1
cleanUpPolicy: delete
syncReplicaMinNum: 1
uncleanLeaderElectionEnable: false
retention: 60000
kubernetesLogConfigCkafka:
type: tencentcloud:KubernetesLogConfig
properties:
logConfigName: tf-test-ckafka
clusterId: ${tencentcloud_kubernetes_cluster.example.id}
logsetId: ${tencentcloud_cls_logset.logset.id}
logConfig:
fn::toJSON:
apiVersion: cls.cloud.tencent.com/v1
kind: LogConfig
metadata:
name: tf-test-ckafka
spec:
inputDetail:
containerStdout:
allContainers: true
namespace: default
nsLabelSelector: ""
type: container_stdout
kafkaDetail:
brokers: 172.16.0.30:9092
extractRule: {}
instanceId: ""
kafkaType: SelfBuildKafka
logType: minimalist_log
messageKey:
value: ""
valueFrom:
fieldRef:
fieldPath: ""
metadata: {}
timestampFormat: double
timestampKey: ""
topic: ${ckafkaTopic}
variables:
ckafkaTopic: ${exampleCkafkaTopic.topicName}
Create KubernetesLogConfig Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new KubernetesLogConfig(name: string, args: KubernetesLogConfigArgs, opts?: CustomResourceOptions);
@overload
def KubernetesLogConfig(resource_name: str,
args: KubernetesLogConfigArgs,
opts: Optional[ResourceOptions] = None)
@overload
def KubernetesLogConfig(resource_name: str,
opts: Optional[ResourceOptions] = None,
cluster_id: Optional[str] = None,
log_config: Optional[str] = None,
log_config_name: Optional[str] = None,
cluster_type: Optional[str] = None,
kubernetes_log_config_id: Optional[str] = None,
logset_id: Optional[str] = None)
func NewKubernetesLogConfig(ctx *Context, name string, args KubernetesLogConfigArgs, opts ...ResourceOption) (*KubernetesLogConfig, error)
public KubernetesLogConfig(string name, KubernetesLogConfigArgs args, CustomResourceOptions? opts = null)
public KubernetesLogConfig(String name, KubernetesLogConfigArgs args)
public KubernetesLogConfig(String name, KubernetesLogConfigArgs args, CustomResourceOptions options)
type: tencentcloud:KubernetesLogConfig
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args KubernetesLogConfigArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args KubernetesLogConfigArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args KubernetesLogConfigArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args KubernetesLogConfigArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args KubernetesLogConfigArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
KubernetesLogConfig Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The KubernetesLogConfig resource accepts the following input properties:
- Cluster
Id string - Cluster ID.
- Log
Config string - JSON expression of log collection configuration.
- Log
Config stringName - Log config name.
- Cluster
Type string - The current cluster type supports tke and eks, default is tke.
- Kubernetes
Log stringConfig Id - ID of the resource.
- Logset
Id string - CLS log set ID.
- Cluster
Id string - Cluster ID.
- Log
Config string - JSON expression of log collection configuration.
- Log
Config stringName - Log config name.
- Cluster
Type string - The current cluster type supports tke and eks, default is tke.
- Kubernetes
Log stringConfig Id - ID of the resource.
- Logset
Id string - CLS log set ID.
- cluster
Id String - Cluster ID.
- log
Config String - JSON expression of log collection configuration.
- log
Config StringName - Log config name.
- cluster
Type String - The current cluster type supports tke and eks, default is tke.
- kubernetes
Log StringConfig Id - ID of the resource.
- logset
Id String - CLS log set ID.
- cluster
Id string - Cluster ID.
- log
Config string - JSON expression of log collection configuration.
- log
Config stringName - Log config name.
- cluster
Type string - The current cluster type supports tke and eks, default is tke.
- kubernetes
Log stringConfig Id - ID of the resource.
- logset
Id string - CLS log set ID.
- cluster_
id str - Cluster ID.
- log_
config str - JSON expression of log collection configuration.
- log_
config_ strname - Log config name.
- cluster_
type str - The current cluster type supports tke and eks, default is tke.
- kubernetes_
log_ strconfig_ id - ID of the resource.
- logset_
id str - CLS log set ID.
- cluster
Id String - Cluster ID.
- log
Config String - JSON expression of log collection configuration.
- log
Config StringName - Log config name.
- cluster
Type String - The current cluster type supports tke and eks, default is tke.
- kubernetes
Log StringConfig Id - ID of the resource.
- logset
Id String - CLS log set ID.
Outputs
All input properties are implicitly available as output properties. Additionally, the KubernetesLogConfig resource produces the following output properties:
- Id string
- The provider-assigned unique ID for this managed resource.
- Id string
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
- id string
- The provider-assigned unique ID for this managed resource.
- id str
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
Look up Existing KubernetesLogConfig Resource
Get an existing KubernetesLogConfig resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: KubernetesLogConfigState, opts?: CustomResourceOptions): KubernetesLogConfig
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
cluster_id: Optional[str] = None,
cluster_type: Optional[str] = None,
kubernetes_log_config_id: Optional[str] = None,
log_config: Optional[str] = None,
log_config_name: Optional[str] = None,
logset_id: Optional[str] = None) -> KubernetesLogConfig
func GetKubernetesLogConfig(ctx *Context, name string, id IDInput, state *KubernetesLogConfigState, opts ...ResourceOption) (*KubernetesLogConfig, error)
public static KubernetesLogConfig Get(string name, Input<string> id, KubernetesLogConfigState? state, CustomResourceOptions? opts = null)
public static KubernetesLogConfig get(String name, Output<String> id, KubernetesLogConfigState state, CustomResourceOptions options)
resources: _: type: tencentcloud:KubernetesLogConfig get: id: ${id}
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- Cluster
Id string - Cluster ID.
- Cluster
Type string - The current cluster type supports tke and eks, default is tke.
- Kubernetes
Log stringConfig Id - ID of the resource.
- Log
Config string - JSON expression of log collection configuration.
- Log
Config stringName - Log config name.
- Logset
Id string - CLS log set ID.
- Cluster
Id string - Cluster ID.
- Cluster
Type string - The current cluster type supports tke and eks, default is tke.
- Kubernetes
Log stringConfig Id - ID of the resource.
- Log
Config string - JSON expression of log collection configuration.
- Log
Config stringName - Log config name.
- Logset
Id string - CLS log set ID.
- cluster
Id String - Cluster ID.
- cluster
Type String - The current cluster type supports tke and eks, default is tke.
- kubernetes
Log StringConfig Id - ID of the resource.
- log
Config String - JSON expression of log collection configuration.
- log
Config StringName - Log config name.
- logset
Id String - CLS log set ID.
- cluster
Id string - Cluster ID.
- cluster
Type string - The current cluster type supports tke and eks, default is tke.
- kubernetes
Log stringConfig Id - ID of the resource.
- log
Config string - JSON expression of log collection configuration.
- log
Config stringName - Log config name.
- logset
Id string - CLS log set ID.
- cluster_
id str - Cluster ID.
- cluster_
type str - The current cluster type supports tke and eks, default is tke.
- kubernetes_
log_ strconfig_ id - ID of the resource.
- log_
config str - JSON expression of log collection configuration.
- log_
config_ strname - Log config name.
- logset_
id str - CLS log set ID.
- cluster
Id String - Cluster ID.
- cluster
Type String - The current cluster type supports tke and eks, default is tke.
- kubernetes
Log StringConfig Id - ID of the resource.
- log
Config String - JSON expression of log collection configuration.
- log
Config StringName - Log config name.
- logset
Id String - CLS log set ID.
Package Details
- Repository
- tencentcloud tencentcloudstack/terraform-provider-tencentcloud
- License
- Notes
- This Pulumi package is based on the
tencentcloud
Terraform Provider.