sparse-intern-71089
02/19/2021, 12:57 PMfresh-pilot-59899
02/19/2021, 1:05 PMfresh-pilot-59899
02/19/2021, 1:05 PMconst SPAWN_PROCESS_BUFFER_SIZE = 104857600;
const helmArgs = [
--version 3.15.2
,
--namespace default
,
--repo <https://kubernetes.github.io/ingress-nginx>
,
--set controller.service.annotations."service\\\.beta\\\.kubernetes\\\.io/azure-load-balancer-internal"=true
,
--set controller.service.loadBalancerIP=${props.backendIpAddress}
,
].join(" ");
const helmCmd = `helm template ${name} ingress-nginx ${helmArgs}`;
console.log(helmCmd)
const rendered = child_process.execSync(helmCmd, {
maxBuffer: SPAWN_PROCESS_BUFFER_SIZE
}).toString();
new k8s.yaml.ConfigGroup(name, {
yaml: rendered,
}, {
provider: cluster,
customTimeouts: {
create: "30m"
},
parent: this,
});future-nail-59564
02/19/2021, 1:32 PMpulumi up
, however in our case, we need to call the external script only when the resource is created, and we have another script that needs to be called when the resource gets deleted. Hence the need for a dynamic provider, which handles that life-cycle. Unfortunately, currently, dynamic providers seem to be rather limited in what you can do with them, because of the special tricks that pulumi pulls behind the scene to make them execute within the pulumi engine! 😕gentle-diamond-70147
02/19/2021, 3:15 PMchild_process
at https://github.com/pulumi/examples/blob/3736042d67c422d703b97cef4fc63b91aca3273a/azure-ts-static-website/staticWebsite.ts#L46 that works just fine.gentle-monitor-55086
02/19/2021, 3:16 PMimport * as pulumi from "@pulumi/pulumi";
import * as child from 'child_process';
const myProvider: pulumi.dynamic.ResourceProvider = {
async create(inputs) {
var foo: child.ChildProcess = child.exec("powershell ./test.ps1", (error: any, stdout: string, stderr: string) => {
console.log(error);
console.log(stderr);
console.log(stdout);
});;
return { id: "foo", outs: {} };
}
}
class MyResource extends pulumi.dynamic.Resource {
constructor(name: string, props: {}, opts?: pulumi.CustomResourceOptions) {
super(myProvider, name, props, opts);
}
}
let x = new MyResource('thisisatest', {});
export const makes = x;
part of the output
Diagnostics:
pulumi:pulumi:Stack (pulumi-company1):
null
Directory: C:\Users\abrothers\Desktop\pulumi
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 2/19/2021 10:12 AM 0 i_came_from_a_script.txt
test.ps1 just
New-Item $PSScriptRoot\i_came_from_a_script.txt
Some gotchas i encountered:
1. notice i'm on windows but had to forward slash the powershell invocation ./
even though cmd on windows wants .\test.ps1
2. i found that i needed powershell
infront of the script
These probably get simplified on non windowsfuture-nail-59564
02/19/2021, 3:58 PMfuture-nail-59564
02/19/2021, 4:00 PMfuture-nail-59564
02/19/2021, 5:30 PMpromisify
that made it break. More specifically, moving the call to promisify
directly into the create()
and delete()
functions fixed the error! Thank you so much for your support! 🎉gentle-monitor-55086
02/19/2021, 5:31 PM