:wave: hi all! new to Pulumi, very much enjoying i...
# dotnet
n
đź‘‹ hi all! new to Pulumi, very much enjoying it so far. I had a quick question - my understanding of inputs and outputs is that they should be fairly interchangeable (eg an
Output
can be an
Input
to some other resource). In particular, I was testing creating a VPC with pre-existing IPs (eg IPs that are allowlisted for various things far outside of my control)
Copy code
var allocatedIps = new List<Eip> 
{
  Eip.Get(...)
  ...
}

var eksVpc = new Ec2.Vpc("eks-vpc", new()
{
  ...
  NatGateways = new Ec2.Inputs.NatGatewayConfigurationArgs
  { 
    Strategy = Ec2.NatGatewayStrategy.OnePerAz,
    ElasticIpAllocationIds = allocatedIps.Select(x => (Input<string>) x.AllocationId).ToList()
  }
}
This feels very weird, but it works. Is there a better way? Am I missing something?
b
Maybe something like...
var eips = Output.Create(GetEips.InvokeAsync(new GetEipsArgs
{
Filters = new List<GetEipsFilterArgs>()
})).Apply(result =>
{
//shape result
return new List<string>();
});
n
it feels a little weird that these don’t return outputs to begin with
b
GetEips returns GetEipsResult.
Output<List<string>> eips = Output.Create(GetEips.InvokeAsync(new GetEipsArgs
{
Filters = new List<GetEipsFilterArgs>()
})).Apply(result =>
{
//shape result
return new List<string>();
});
Output<GetEipsResult> eips2 = Output.Create(GetEips.InvokeAsync(new GetEipsArgs
{
Filters = new List<GetEipsFilterArgs>()
}));
n
yeah, i mean, i get that. this feels like a lot of verbose type conversions to say something that is easily expressible in terraform - versus just being able to use the output of
InvokeAsync
directly with whatever expects it. the differentiation between “output that might eventually return” (eg creation of a vpc, whatever) and “output that returns immediately” (get me a list of vpcs) especially with a lack of explicit casting feels fairly unergonomic
b
like
ElasticIpAllocationIds = eips2.Apply(e => e.AllocationIds);
?
n
well, or really
ElasticIpAllocationIds = GetEips.InvokeAsync(…)