sparse-intern-71089
07/10/2020, 2:15 PMtall-librarian-49374
07/10/2020, 2:26 PMGetOutput
instead of GetValueAsync
. Second, there is a pattern of
1. Using a helper async method.
2. Returning outputs from it.
3. Invoking it from the constructor and assigning the result to an Output<T>
property.
This way, Pulumi would know how to await it properly using the output.
See an example here: https://github.com/pulumi/pulumi/blob/master/pkg/codegen/internal/test/testdata/aws-eks.pp.cs#L13-L17bored-activity-40468
07/10/2020, 2:54 PMbored-activity-40468
07/10/2020, 2:56 PMnamespace StackReferenceExample {
public class SimpleStack : Stack {
[Output( "vpc" )]
public Output<Output<object?>> Vpc { get; set; }
public SimpleStack( ) {
Vpc = Output.Create( Initialize( ) );
}
private async Task<Output<object?>> Initialize( ) {
var vpcStack = new StackReference( "orionadvisortech/vpc/sandbox" );
var vpc = vpcStack.GetOutput( "vpc" );
return vpc;
}
}
}
tall-librarian-49374
07/10/2020, 5:06 PMOutput<Output<object?>>
doesnโt look correctbored-activity-40468
07/10/2020, 6:51 PMtall-librarian-49374
07/10/2020, 7:11 PMpublic class SimpleStack : Stack {
[Output( "vpc" )]
public Output<object?> Vpc { get; set; }
public SimpleStack( ) {
Vpc = Output.Create( Initialize( ) );
}
private async Task<object?> Initialize( ) {
var vpcStack = new StackReference( "orionadvisortech/vpc/sandbox" );
var vpc = await vpcStack.GetValueAsync( "vpc" );
return vpc;
}
}
if you need async
for something elsetall-librarian-49374
07/10/2020, 7:12 PMpublic SimpleStack( ) {
var vpcStack = new StackReference( "orionadvisortech/vpc/sandbox" );
this.Vpc = vpcStack.GetOutput( "vpc" );
}
otherwisetall-librarian-49374
07/10/2020, 7:15 PMpublic SimpleStack( ) {
Vpc = Output.Create( Initialize( ) ).Apply(v => v);
}
private async Task<Output<object?>> Initialize( ) {
var vpcStack = new StackReference( "orionadvisortech/vpc/sandbox" );
var vpc = vpcStack.GetOutput( "vpc" );
return vpc;
}
If vpc
is a secret and you need async for something elsetall-librarian-49374
07/10/2020, 7:15 PMbored-activity-40468
07/12/2020, 3:56 PMbored-activity-40468
07/12/2020, 3:58 PMpulumi preview
bored-activity-40468
07/12/2020, 4:19 PMbored-activity-40468
07/12/2020, 4:20 PMVpc = vpcStack.GetOutput( "vpc" ).Apply(x => (string)x);
bored-activity-40468
07/12/2020, 9:03 PM