broad-boots-45639
01/09/2020, 7:19 PMconst floating_ips = new pulumi.StackReference(`<org>/floating-ips/stage`);
var ip1 = floating_ips.getOutput("floating_ip1")
var ip2 = floating_ips.getOutput("floating_ip2")
const proxychains = new kubernetes.core.v1.ConfigMap(`${app}-proxychains-config`,
pulumi.output({
metadata: {
name: "proxychains-config",
namespace: "default"
},
data: {
"proxychains.conf": `strict_chain\ntcp_read_time_out 15000\ntcp_connect_time_out 8000\nlocalnet 10.244.0.0/255.255.0.0\nlocalnet 127.0.0.1/255.0.0.0\n[ProxyList]\nsocks4 ${floating_ips.getOutput("floating_ip1")} 1080\nsocks4 ${floating_ips.getOutput("floating_ip2")} 1080\n`
}
}), { dependsOn: vars_configmap } );
kind: ConfigMap
metadata:
annotations:
<http://kubectl.kubernetes.io/last-applied-configuration|kubectl.kubernetes.io/last-applied-configuration>: |
{"apiVersion":"v1","data":{"proxychains.conf":"strict_chain\ntcp_read_time_out 15000\ntcp_connect_time_out 8000\nlocalnet 10.244.0.0/255.255.0.0\nlocalnet 127.0.0.1/255.0.0.0\n[ProxyList]\nsocks4 Calling [toString] on an [Output\u003cT\u003e] is not supported.\n\nTo get the value of an Output\u003cT\u003e as an Output\u003cstring\u003e consider either:\n1: o.apply(v =\u003e `prefix${v}suffix`)\n2: pulumi.interpolate `prefix${v}suffix`\n\nSee <https://pulumi.io/help/outputs> for more details.\nThis function may throw in a future version of @pulumi/pulumi. 1080\nsocks4 Calling [toString] on an [Output\u003cT\u003e] is not supported.\n\nTo get the value of an Output\u003cT\u003e as an Output\u003cstring\u003e consider either:\n1: o.apply(v =\u003e `prefix${v}suffix`)\n2: pulumi.interpolate `prefix${v}suffix`\n\nSee <https://pulumi.io/help/outputs> for more details.\nThis function may throw in a future version of @pulumi/pulumi. 1080\n"},"kind":"ConfigMap","metadata":{"labels":{"<http://app.kubernetes.io/managed-by|app.kubernetes.io/managed-by>":"pulumi"},"name":"proxychains-config","namespace":"default"}}
astonishing-cartoon-37000
01/09/2020, 7:24 PMgetOutputSync
because getOutput
returns a pulumi.Output
.It looks like it's pissed because it calls toString()
behind the scenes, which isn't valid for a pulumi.Output
. If you use Sync it will return a the underlying valuetoString()
method. So the two options are either make sure it's a string
or use the .apply()
or pulumi.interpolate
function
Example With Snyc)
const floating_ips = new pulumi.StackReference(`<org>/floating-ips/stage`);
var ip1 = floating_ips.getOutputSync("floating_ip1") // will return actual value
var ip2 = floating_ips.getOutputSync("floating_ip2") // will return actual value
const proxychains = new kubernetes.core.v1.ConfigMap(`${app}-proxychains-config`,
pulumi.output({
metadata: {
name: "proxychains-config",
namespace: "default"
},
data: {
"proxychains.conf": `strict_chain\ntcp_read_time_out 15000\ntcp_connect_time_out 8000\nlocalnet 10.244.0.0/255.255.0.0\nlocalnet 127.0.0.1/255.0.0.0\n[ProxyList]\nsocks4 ${ip1} 1080\nsocks4 ${ip2} 1080\n`
}
}), { dependsOn: vars_configmap } )
broad-boots-45639
01/09/2020, 7:31 PMastonishing-cartoon-37000
01/09/2020, 7:32 PMbroad-boots-45639
01/09/2020, 7:35 PMbrave-angle-33257
01/09/2020, 7:41 PMCompatibility
StackReference.getOutputSync and requireOutputSync are deprecated as they may cause hangs on some combinations of Node and certain OS platforms. StackReference.getOutput and requireOutput should be used instead.
astonishing-cartoon-37000
01/09/2020, 7:52 PMbrave-angle-33257
01/09/2020, 7:53 PMastonishing-cartoon-37000
01/09/2020, 8:00 PM/**
* Data contains the configuration data. Each key must consist of alphanumeric characters,
* '-', '_' or '.'. Values with non-UTF-8 byte sequences must use the BinaryData field. The
* keys stored in Data must not overlap with the keys in the BinaryData field, this is
* enforced during validation process.
*/
readonly data: pulumi.Output<{
[key: string]: pulumi.Output<string>;
}>;
brave-angle-33257
01/09/2020, 8:00 PMpulumi.outputStringTemplate()
or something where you pass in the template, and a bunch of keys and values, like a python format()
or jinja styleastonishing-cartoon-37000
01/09/2020, 8:03 PMpulumi.output
shouldn't need to do that my final take would be this. Without using deprecated Sync
. Sorry for blowing up Thread.
const floating_ips = new pulumi.StackReference(`<org>/floating-ips/stage`)
const ip1 = floating_ips.getOutput('floating_ip1')
const ip2 = floating_ips.getOutput('floating_ip1')
const proxychains = new kubernetes.core.v1.ConfigMap(
`${app}-proxychains-config`,
{
metadata: {
name: 'proxychains-config',
namespace: 'default'
},
data: {
'proxychains.conf': pulumi.interpolate `strict_chain\ntcp_read_time_out 15000\ntcp_connect_time_out 8000\nlocalnet 10.244.0.0/255.255.0.0\nlocalnet 127.0.0.1/255.0.0.0\n[ProxyList]\nsocks4 ${ip1} 1080\nsocks4 ${ip2} 1080\n`
} //use the newly transformed pulumi.Output
},
{ dependsOn: vars_configmap }
)
acoustic-florist-12628
01/09/2020, 8:23 PMip1
and ip2
(which are pulumi.Output type), isn't it much easier to just use pulumi.interpolate
...${ip1}......${ip2}...`` ? Is there a reason this isn't an option?
Also in the k8s configmap arguments i'm not sure there's a reason to wrap the properties in a pulumi.output() call; it appears there are only strings and pulumi.Outputs involved already, which will work... If I'm reading it all correctly, wouldn't Aubrey's original code snippet work just fine with `"proxychains.conf": pulumi.interpolate `<original content>``?astonishing-cartoon-37000
01/09/2020, 8:24 PM