-
Notifications
You must be signed in to change notification settings - Fork 879
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
Update C# examples to use the new F.Invoke feature #1093
Conversation
To be continued. |
For a second, I thought I missed that we landed .NET invokes already. These changes look great! |
@mikhailshilkov it's fairly close, I expect next planned release to land SDK changes and the cycle after that land the providers changes. |
CI indicates pulumi-aws has not upgraded yet, but this should be coming shortly. |
I think the remaining CI failure is legitimate, it's indicative of preview failure; waiting on this fix: pulumi/pulumi#8339 |
var vpcId = vpc.Apply(vpc => vpc.Id); | ||
var subnet = vpcId.Apply(id => Ec2.GetSubnetIds.InvokeAsync(new Ec2.GetSubnetIdsArgs {VpcId = id})); | ||
var subnetIds = subnet.Apply(s => s.Ids); | ||
var vpcId = Ec2.GetVpc.Invoke(new Ec2.GetVpcInvokeArgs { Default = true }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Invokes normally run at preview time right? So while this looks neater and smaller it's unnecessarily moved to Output space?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's bad about that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well in general Output is more constrained in what you can do with it than Task. I don't think it really matters here because the inputs are always going to be known and so these invokes will run anyway just wondering out loud if this is going to make things more difficult with preview constraints as even more stuff is in Outputs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We had a similar debate in TypeScript with Pat eventually resolved it to the rule "if the change makes Output appear that was not there before, it's a bad change". I'm happy to roll it back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Invokes should not be running in preview AFAIK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Invokes should run in preview if the Inputs are known though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Old-style invokes totally run in preview unless inside an unresolved apply
7b418e3
to
1a33e59
Compare
Undoing classic-azure examples as C# feature has not rolled out yet. |
Confirming CI failure fixed on 3.17.1 but something is busted with the release as release automation is picking up 3.17.0. |
So @Frassle check this out. using System;
using Pulumi;
using Ec2 = Pulumi.Aws.Ec2;
class EksStack : Stack
{
public EksStack()
{
//NewVersion();
OldVersion();
}
public void NewVersion()
{
// Read back the default VPC and public subnets, which we will use.
var vpc = Ec2.GetVpc.Invoke(new Ec2.GetVpcInvokeArgs { Default = true });
PrintIsKnown(vpc);
var vpcId = vpc.Apply(vpc =>
{
Console.WriteLine($"vpc.Id={vpc.Id}");
return vpc.Id;
});
PrintIsKnown(vpcId);
var subnetIds = Ec2.GetSubnetIds.Invoke(new Ec2.GetSubnetIdsInvokeArgs { VpcId = vpcId })
.Apply(s =>
{
Console.WriteLine($"s.Ids={s.Ids}");
return s.Ids;
});
PrintIsKnown(subnetIds);
}
public void OldVersion()
{
var vpc = Output.Create(Ec2.GetVpc.InvokeAsync(new Ec2.GetVpcArgs
{
Default = true
}));
PrintIsKnown(vpc);
var vpcId = vpc.Apply(vpc =>
{
Console.WriteLine($"vpc.Id={vpc.Id}");
return vpc.Id;
});
PrintIsKnown(vpcId);
var subnet = vpcId.Apply(id => Ec2.GetSubnetIds.InvokeAsync(new Ec2.GetSubnetIdsArgs {VpcId = id}));
var subnetIds = subnet.Apply(s =>
{
Console.WriteLine($"s.Ids={s.Ids}");
return s.Ids;
});
PrintIsKnown(subnetIds);
}
public void PrintIsKnown<T>(Output<T> output)
{
Output.Create(Pulumi.Utilities.OutputUtilities.GetIsKnownAsync(output)).Apply(isKnown =>
{
Console.WriteLine($"IsKnown: {isKnown}");
return 0;
});
}
} Both versions print the same output in pulumi preview:
|
So yes it sounds like invokes would run in preview if known. The two forms seem equivalent. |
Unbelievable, green checkmark from CI! 🙂 |
* Update aws-cs-eks * Update aws-cs-fargate * Updated aws-cs-webserver * Update azure-cs-aks-cosmos-helm * Update azure-cs-aks-helm * Update azure-cs-aks * Updated azure-cs-appservice-docker * Update azure-cs-appservice * Update azure-cs-cosmosdb-logicapp * Update azure-cs-credential-rotation-one-set * Update azure-cs-functions * Updated azure-cs-net5-aks-webapp * Update aws-cs-fargate/Infra * Update testing-unit-cs * No-op change to trigger CI * Force 3.17.1 upgrade * Trigger CI again * Fix indent
Context: pulumi/pulumi#7948
Updates C# examples to use F.Invoke feature.
This PR will not compile and be ready to merge until:
It is ready for review however, only minimal changes to build refs are expected once the prereqs land.