-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
validateResourceOfType
doesn't work for a Provider
resource.
#323
Comments
pulumi-policy/sdk/nodejs/policy/server.ts Lines 584 to 593 in 2fa7cab
In generated Node.js provider SDKs, it looks like there is a difference in values for Provider /** @internal */
public static readonly __pulumiType = 'azure';
/**
* Returns true if the given object is an instance of Provider. This is designed to work even
* when multiple copies of the Pulumi SDK have been loaded into the same process.
*/
public static isInstance(obj: any): obj is Provider {
if (obj === undefined || obj === null) {
return false;
}
return obj['__pulumiType'] === "pulumi:providers:" + Provider.__pulumiType;
} Custom Resource /** @internal */
public static readonly __pulumiType = 'azure:storage/blob:Blob';
/**
* Returns true if the given object is an instance of Blob. This is designed to work even
* when multiple copies of the Pulumi SDK have been loaded into the same process.
*/
public static isInstance(obj: any): obj is Blob {
if (obj === undefined || obj === null) {
return false;
}
return obj['__pulumiType'] === Blob.__pulumiType;
} I'd have to double check to see if it's always been like that, but the likely fix would be to adjust the internal |
@ringods, actually, I can't repro this. I tried to repro with Azure classic program and policy pack, and the policy using I see your Pulumi program is using |
@justinvp I instantiated a new policy pack from template "@pulumi/azure": "^4.0.0", A number of the policy templates haven't had their dependencies updated in years. 😮 When I update |
This should be fixed with pulumi/templates-policy#27. |
Cannot close issue:
Please fix these problems and try again. |
What happened?
For a customer case, I tried writing a policy that enforces the
subscriptionId
to be set on the Azure provider. I can make this work if I write a custom validation fucntion which checksargs.type === 'pulumi:providers:azure'
manually.Using
validateResourceOfType(azure.Provicer, ... )
doesn't seem to work. In the example below, only the fileargs-my.json
gets written, notargs-typed.json
.Example
Output of
pulumi about
Additional context
Test this with this small Azure Classic app:
Running with the local policy pack:
Contributing
Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).
The text was updated successfully, but these errors were encountered: