pulumi-azure-native
pulumi-azure-native copied to clipboard
Input type for `cdn.Rule` don't generate correctly?
What happened?
I'm trying to create an Azure CDN rule and the input types don't seem to type check
Steps to reproduce
I have the following code:
import * as pulumi from "@pulumi/pulumi";
import * as resources from "@pulumi/azure-native/resources";
import * as cdn from "@pulumi/azure-native/cdn";
// Create an Azure Resource Group
const resourceGroup = new resources.ResourceGroup("resourceGroup");
const profile = new cdn.Profile("profile", {
location: "WestUS",
profileName: "profile",
resourceGroupName: resourceGroup.name,
sku: {
name: "Standard_Verizon",
},
});
const rewriteRule = new cdn.Rule('rewriteRule', {
ruleSetName: 'MyAppRuleSet',
ruleName: 'test',
order: 1,
profileName: profile.name,
resourceGroupName: resourceGroup.name,
actions: [
{
name: "UrlRewrite",
parameters: {
destination: '/index.html',
preserveUnmatchedPath: false,
sourcePattern: '/',
},
},
],
conditions: [
{
name: 'UrlFileExtension',
parameters: {
matchValues: ['0'],
operator: cdn.Operator.GreaterThan,
negateCondition: true,
},
},
],
});
The action names seem to indicate UrlRewrite is an option, but it still doesn't allow it on the typecheck
Expected Behavior
I can create a CDN rule
Actual Behavior
pulumi:pulumi:Stack (azure-cdn-ts-dev):
error: Running program '/Users/lbriggs/src/git/jaxxstorm/pulumi-examples/typescript/azure/cdn' failed with an unhandled exception:
TSError: ⨯ Unable to compile TypeScript:
index.ts(24,5): error TS2322: Type '{ name: string; parameters: { destination: string; preserveUnmatchedPath: boolean; sourcePattern: string; }; }[]' is not assignable to type 'Input<Input<DeliveryRuleCacheExpirationActionArgs | DeliveryRuleCacheKeyQueryStringActionArgs | ... 5 more ... | UrlSigningActionArgs>[]>'.
Type '{ name: string; parameters: { destination: string; preserveUnmatchedPath: boolean; sourcePattern: string; }; }[]' is not assignable to type 'Input<DeliveryRuleCacheExpirationActionArgs | DeliveryRuleCacheKeyQueryStringActionArgs | ... 5 more ... | UrlSigningActionArgs>[]'.
Type '{ name: string; parameters: { destination: string; preserveUnmatchedPath: boolean; sourcePattern: string; }; }' is not assignable to type 'Input<DeliveryRuleCacheExpirationActionArgs | DeliveryRuleCacheKeyQueryStringActionArgs | ... 5 more ... | UrlSigningActionArgs>'.
Type '{ name: string; parameters: { destination: string; preserveUnmatchedPath: boolean; sourcePattern: string; }; }' is not assignable to type 'UrlSigningActionArgs'.
Types of property 'name' are incompatible.
Type 'string' is not assignable to type 'Input<"UrlSigning">'.
index.ts(34,5): error TS2322: Type '{ name: string; parameters: { matchValues: string[]; operator: "GreaterThan"; negateCondition: boolean; }; }[]' is not assignable to type 'Input<DeliveryRuleCookiesConditionArgs | DeliveryRuleHttpVersionConditionArgs | DeliveryRuleIsDeviceConditionArgs | ... 10 more ... | DeliveryRuleUrlPathConditionArgs>[] | Promise<...> | OutputInstance<...> | undefined'.
Type '{ name: string; parameters: { matchValues: string[]; operator: "GreaterThan"; negateCondition: boolean; }; }[]' is not assignable to type 'Input<DeliveryRuleCookiesConditionArgs | DeliveryRuleHttpVersionConditionArgs | DeliveryRuleIsDeviceConditionArgs | ... 10 more ... | DeliveryRuleUrlPathConditionArgs>[]'.
Type '{ name: string; parameters: { matchValues: string[]; operator: "GreaterThan"; negateCondition: boolean; }; }' is not assignable to type 'Input<DeliveryRuleCookiesConditionArgs | DeliveryRuleHttpVersionConditionArgs | DeliveryRuleIsDeviceConditionArgs | ... 10 more ... | DeliveryRuleUrlPathConditionArgs>'.
Type '{ name: string; parameters: { matchValues: string[]; operator: "GreaterThan"; negateCondition: boolean; }; }' is not assignable to type 'DeliveryRuleUrlPathConditionArgs'.
Types of property 'name' are incompatible.
Type 'string' is not assignable to type 'Input<"UrlPath">'.
Versions used
CLI
Version 3.32.1
Go Version go1.18.1
Go Compiler gc
Plugins
NAME VERSION
azure-native 1.64.0
nodejs unknown
Host
OS darwin
Version 12.3.1
Arch x86_64
This project is written in nodejs (/Users/lbriggs/.nvm/versions/node/v12.18.4/bin/node v12.18.4)
Current Stack: dev
Found no resources associated with dev
Found no pending operations associated with dev
Backend
Name pulumi.com
URL https://app.pulumi.com/jaxxstorm
User jaxxstorm
Organizations jaxxstorm, lbrlabs, team-ce, demo, pulumi
NAME VERSION
@pulumi/azure-native 1.64.0
@pulumi/pulumi 3.32.1
@types/node 14.18.16
Pulumi locates its logs in /var/folders/1y/s9gz0_l10hb2y8mtknj45stc0000gn/T/ by default
Additional context
No response
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).
This is actually this:
https://github.com/pulumi/pulumi-azure-native/issues/647
I'm not sure why type annotations are required, but this type-checks:
import * as types from "@pulumi/azure-native/types";
const rewriteRule = new cdn.Rule('rewriteRule', {
ruleSetName: 'MyAppRuleSet',
ruleName: 'test',
order: 1,
profileName: profile.name,
resourceGroupName: resourceGroup.name,
actions: [
{
name: "UrlRewrite",
parameters: {
destination: '/index.html',
preserveUnmatchedPath: false,
sourcePattern: '/',
},
} as types.input.cdn.UrlRewriteActionArgs,
],
conditions: [
{
name: 'UrlFileExtension',
parameters: {
matchValues: ['0'],
operator: cdn.Operator.GreaterThan,
negateCondition: true,
},
} as types.input.cdn.DeliveryRuleUrlFileExtensionConditionArgs,
],
});
A bit ugly, but should unblock anyone.
Just an update that as of Azure Native v2.24.0, this still reproduces (including Mikhail's unblocking suggestion).