salmon-account-74572
08/13/2019, 3:37 PM<http://kubernetes.io/cluster/<clustername>|kubernetes.io/cluster/<clustername>>
(the value is immaterial). I'd like to be able to define the <clustername>
value once in a variable, and then include it in the tags to be applied to resources. Any suggestions?gentle-diamond-70147
08/13/2019, 3:48 PMconst tagName = "my-tag";
const webServer = new aws.ec2.Instance("web-server", {
tags: {
[tagName]: "my-value",
},
...
});
salmon-account-74572
08/13/2019, 4:14 PMquaint-artist-58613
11/28/2019, 11:44 PMsalmon-account-74572
12/02/2019, 3:23 PMcuddly-flower-91328
02/17/2023, 7:20 PMsalmon-account-74572
02/17/2023, 7:22 PMcuddly-flower-91328
02/17/2023, 7:22 PMsalmon-account-74572
02/17/2023, 7:24 PM// Set some default values for later
let k8sClusterTag: string = "<http://kubernetes.io/cluster/agtest|kubernetes.io/cluster/agtest>";
let k8sRoleTag: string = "<http://kubernetes.io/role|kubernetes.io/role>";
// Create new VPC
const vpc = new aws.ec2.Vpc("agtest-vpc", {
cidrBlock: "10.1.0.0/16",
enableDnsHostnames: true,
enableDnsSupport: true,
tags: {
Name: "agtest-vpc",
[k8sClusterTag]: "unmanaged",
[k8sRoleTag]: "common",
},
});
cuddly-flower-91328
02/17/2023, 7:33 PMlet clusterName = cluster.core.cluster.name;
let clusterTag = pulumi.interpolate `<http://k8s.io/cluster-autoscaler/${clusterName}`;|k8s.io/cluster-autoscaler/${clusterName}`;>
This is what I was trying to accomplish in some fashionsalmon-account-74572
02/17/2023, 7:50 PM// Create a map of regions and friendly names
regionNames := make(map[string]string)
regionNames["us-west-2"] = "oregon"
regionNames["us-east-2"] = "ohio"
regionNames["eu-west-1"] = "ireland"
regionNames["ap-northeast-1"] = "tokyo"
regionNames["ca-central-1"] = "central"
// Define some values to be used later
k8sTag := fmt.Sprintf("<http://kubernetes.io/cluster/%s-mgmt|kubernetes.io/cluster/%s-mgmt>", regionNames[awsRegion])
I’m not sure of the equivalent TypeScript syntax, but it should definitely be possible.cuddly-flower-91328
02/17/2023, 9:34 PMlet clusterName = cluster.core.cluster.name;
let clusterTag = pulumi.interpolate `<http://k8s.io/cluster-autoscaler/${clusterName}`;|k8s.io/cluster-autoscaler/${clusterName}`;>
let tags = {
"<http://k8s.io/cluster-autoscaler/enabled|k8s.io/cluster-autoscaler/enabled>": "true",
}
clusterTag.apply(s => tags[s] = "owned");
salmon-account-74572
02/17/2023, 9:38 PMcuddly-flower-91328
02/17/2023, 9:41 PMsalmon-account-74572
02/17/2023, 9:43 PMcuddly-flower-91328
02/17/2023, 9:45 PMsalmon-account-74572
02/17/2023, 11:14 PM