sparse-intern-71089
04/11/2021, 5:03 PMred-match-15116
04/11/2021, 5:32 PMbetter-shampoo-48884
04/11/2021, 6:09 PMlet akv2k8sValues = yaml.load(fs.readFileSync("./components/chart-values/akv2k8s-production.yml")) as any
let tlsCrt = tlsCert.crt.certPem.apply(tlsCrt => {
let curObj = akv2k8sValues;
akv2k8sValues.env_injector.certificate = {
useCertManager: false,
custom: {
enabled: true,
server: {
tls: {
crt: tlsCert.crt.certPem.apply(x => x),
key: "toBeFilled"
}
},
ca: {
crt: "toBeFilled"
}
}
}
return akv2k8sValues;
})
let tlsKey = pulumi.all([tlsCrt, tlsCert.key.privateKeyPem]).apply(([objValue, key]) => {
objValue.env_injector.certificate.custom.server.tls.key = key;
return objValue;
})
let finalAkv2k8sValues = pulumi.all([tlsKey, tlsCert.caCert.certPem]).apply(([objValue, cert]) => {
objValue.env_injector.certificate.custom.ca.crt = cert;
return objValue;
})
const SPVakv2k8s = new k8s.helm.v3.Chart("akv2k8s",{
chart: "akv2k8s",
version: "2.0.10",
namespace: akv2k8sNamespace.metadata.name,
fetchOpts: {
repo: helmRepos.spv.url
},
values: finalAkv2k8sValues.apply(x => x)
},{
provider: cluster,
dependsOn: [tlsCert.crt, tlsCert.key, tlsCert.caCert]
})
With the following resulting output:
Error: invocation of kubernetes:helm:template returned an error: failed to generate YAML for specified Helm chart: failed to create chart from template: YAML parse error on akv2k8s/templates/env-injector-apiservice.yaml: error converting YAML to JSON: yaml: line 15: could not find expected ':'
Tried with up -f in the event that preview couldn't materialize sufficient output, and tried multiple other permutations of .apply and .interpolate.bored-oyster-3147
04/11/2021, 8:34 PMbored-oyster-3147
04/11/2021, 8:41 PMbored-oyster-3147
04/11/2021, 8:42 PMbored-oyster-3147
04/11/2021, 8:49 PMlet tlsCrt = tlsCert.crt.certPem.apply(tlsCrt => {
let curObj = akv2k8sValues;
akv2k8sValues.env_injector.certificate = {
useCertManager: false,
custom: {
enabled: true,
server: {
tls: {
crt: tlsCert.crt.certPem.apply(x => x),
key: "toBeFilled"
}
},
ca: {
crt: "toBeFilled"
}
}
}
return akv2k8sValues;
})
should be this:
let tlsCrt = tlsCert.crt.certPem.apply(tlsCrt => {
let curObj = akv2k8sValues;
akv2k8sValues.env_injector.certificate = {
useCertManager: false,
custom: {
enabled: true,
server: {
tls: {
crt: tlsCrt,
key: "toBeFilled"
}
},
ca: {
crt: "toBeFilled"
}
}
}
return akv2k8sValues;
})
and this:
const SPVakv2k8s = new k8s.helm.v3.Chart("akv2k8s",{
chart: "akv2k8s",
version: "2.0.10",
namespace: akv2k8sNamespace.metadata.name,
fetchOpts: {
repo: helmRepos.spv.url
},
values: finalAkv2k8sValues.apply(x => x)
},{
provider: cluster,
dependsOn: [tlsCert.crt, tlsCert.key, tlsCert.caCert]
})
is equivalent to this:
const SPVakv2k8s = new k8s.helm.v3.Chart("akv2k8s",{
chart: "akv2k8s",
version: "2.0.10",
namespace: akv2k8sNamespace.metadata.name,
fetchOpts: {
repo: helmRepos.spv.url
},
values: finalAkv2k8sValues
},{
provider: cluster,
dependsOn: [tlsCert.crt, tlsCert.key, tlsCert.caCert]
})bored-oyster-3147
04/11/2021, 8:55 PMdependsOn: [tlsCert.crt, tlsCert.key, tlsCert.caCert] may be completely redundant. You are already providing inputs to the helm chart that are built from outputs that came from tlsCert, so pulumi is smart enough to recognize that the helm chart depends on tlsCert by inference.bored-oyster-3147
04/11/2021, 8:58 PMtlsCert? I can't figure out what type it is so I can't find it but I suspect your code to build finalAkv2k8sValues could be much simpler.red-match-15116
04/12/2021, 12:35 AMlet akv2k8sValues = yaml.load(fs.readFileSync("./components/chart-values/akv2k8s-production.yml")) as any
const finalAkv2k8sValues = pulumi.all([akv2k8sValues, tlsCert.crt.certPem, tlSCert.key.privateKeyPem, tlsCert.caCert.certPem])
.apply(([akv2k8sValues, crtCertPem, privateKeyPem, caCertCertPem]) => {
const k8sValues = {...akv2k8sValues} // Copy to a new object to avoid mutating akv2k8sValues
k8sValues.env_injector.certificate = {
useCertManager: false,
custom: {
enabled: true,
server: {
tls: {
crt: crtCertPem,
key: privateKeyPem
}
},
ca: {
crt: caCertCertPem
}
}
}
return k8sValues;
}
const SPVakv2k8s = new k8s.helm.v3.Chart("akv2k8s",{
chart: "akv2k8s",
version: "2.0.10",
namespace: akv2k8sNamespace.metadata.name,
fetchOpts: {
repo: helmRepos.spv.url
},
values: finalAkv2k8sValues
},{
provider: cluster
});red-match-15116
04/12/2021, 12:40 AMlet akv2k8sValues = yaml.load(fs.readFileSync("./components/chart-values/akv2k8s-production.yml")) as any
const finalAkv2k8sValues = pulumi.all([akv2k8sValues, tlsCert])
.apply(([akv2k8sValues, tlsCert]) => {
const k8sValues = {...akv2k8sValues} // Copy to a new object to avoid mutating akv2k8sValues
k8sValues.env_injector.certificate = {
useCertManager: false,
custom: {
enabled: true,
server: {
tls: {
crt: tlsCert.crt.CertPem,
key: tlsCert.key.privateKeyPem
}
},
ca: {
crt: tlsCert.caCert.CertPem
}
}
}
return k8sValues;
}
const SPVakv2k8s = new k8s.helm.v3.Chart("akv2k8s",{
chart: "akv2k8s",
version: "2.0.10",
namespace: akv2k8sNamespace.metadata.name,
fetchOpts: {
repo: helmRepos.spv.url
},
values: finalAkv2k8sValues
},{
provider: cluster
});better-shampoo-48884
04/12/2021, 5:50 AMup -f, but I get the same error there.bored-oyster-3147
04/12/2021, 12:24 PMred-match-15116
04/12/2021, 3:02 PMred-match-15116
04/12/2021, 3:07 PMbetter-shampoo-48884
04/13/2021, 7:19 AMDuring some program executions, apply doesn't run. For example, it won't run during a preview, when resource output values may be unknown. Therefore, you should avoid side-effects within the callbacks. For this reason, you should not allocate new resources inside of your callbacks either, as it could lead to pulumi preview being wrong.
from https://www.pulumi.com/docs/intro/concepts/inputs-outputs/better-shampoo-48884
04/13/2021, 7:19 AMbored-oyster-3147
04/13/2021, 1:27 PM