rapid-ram-37207
10/29/2019, 7:06 PMconsulRule
and sshRule
are incorrect.
All the rule outputs have the same property values :
https://gist.github.com/MathieuBuisson/0aeb53488077beb4da484cc79caad079#file-outputs-txt
As you can see in the Gist, all rules outputs are identical.
It looks like these 3 rules outputs are all referencing the same object : the first rule.
Could anyone give me any pointers on what I'm doing wrong here ?
Thank you.white-balloon-205
10/29/2019, 9:56 PMnsg.rules
here?function getRuleByName(name: string) {
return pulumi.all(nsg.rules.map(r => r.rule.name)).apply(ruleNames => {
return ruleNames.find(ruleName => name === ruleName);
});
}
rapid-ram-37207
10/30/2019, 9:48 AMnsg.rules
is of type NetworkSecurityRule[]
, NetworkSecurityRule
being a custom ComponentResource and has a rule
property of type azure.network.NetworkSecurityRule
.tall-librarian-49374
11/01/2019, 2:34 PMapply
and all
rapid-ram-37207
11/02/2019, 11:24 AMPromise()
is just to unwrap the underlying object from the output, as explained in this article :
https://www.pulumi.com/blog/unit-testing-infrastructure-in-nodejs-and-mocha/
As per your suggestion, i modified getRuleByName
like so :
function getRuleByName(name: string) {
return pulumi.all(nsg.rules.apply(r => {
return r.find(r => r.rule.name === name)
})
}
But then I get the error :
Property 'apply' does not exist on type 'NetworkSecurityRule[]'.
NetworkSecurityRule
is a custom ComponentResource which contains an azure.network.NetworkSecurityRule.
tall-librarian-49374
11/02/2019, 11:35 AMreturn pulumi.all(nsg.rules).apply(r => ...
rapid-ram-37207
11/02/2019, 12:43 PMfunction getRuleByName(name: string) {
return pulumi.all(nsg.rules).apply(r => {
return r.find(r => r.rule.name === name)
})
}
Results in the following error for the test in the find method:
This condition will always return 'false' since the types 'Output<string>' and 'string' have no overlap
function getRuleByName(name: string) {
return pulumi.all(nsg.rules).apply(r => {
return r.find(r => r.rule.name.get() === name)
})
}
But it result in the following error :
Error: Cannot call '.get' during update or preview.
To manipulate the value of this Output, use '.apply' instead.
tall-librarian-49374
11/02/2019, 9:10 PMfunction getRuleByName(name: string) {
return pulumi.all(nsg.rules.map(r => r.name)).apply(names => {
const index = names.indexOf(name);
return index >= 0 ? nsg.rules[index] : undefined;
});
}
rapid-ram-37207
11/03/2019, 2:13 PMtall-librarian-49374
11/03/2019, 2:24 PM