https://pulumi.com logo
#dotnet
Title
# dotnet
n

nutritious-air-21788

03/18/2024, 3:33 PM
đź‘‹ 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

bored-activity-40468

03/19/2024, 9:16 PM
Maybe something like...
var eips = Output.Create(GetEips.InvokeAsync(new GetEipsArgs
{
Filters = new List<GetEipsFilterArgs>()
})).Apply(result =>
{
//shape result
return new List<string>();
});
n

nutritious-air-21788

03/20/2024, 3:02 PM
it feels a little weird that these don’t return outputs to begin with
b

bored-activity-40468

03/20/2024, 3:10 PM
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

nutritious-air-21788

03/20/2024, 3:45 PM
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

bored-activity-40468

03/20/2024, 3:50 PM
like
ElasticIpAllocationIds = eips2.Apply(e => e.AllocationIds);
?
n

nutritious-air-21788

03/20/2024, 5:59 PM
well, or really
ElasticIpAllocationIds = GetEips.InvokeAsync(…)