This message was deleted.
# general
s
This message was deleted.
l
Are you using
Apply
? Can you post some code?
m
This is the relevant bit:
// NAT gateway needs an elastic IP
var elasticIpForNat = new Eip($"{Request.Name}_NAT_Gateway", new EipArgs
{
Vpc = true
});
Result.NatGateway = new NatGateway(NatGatewayName, new NatGatewayArgs
{
SubnetId = PublicPrimarySubnet.Id,
AllocationId = elasticIpForNat.AllocationId
});
l
I haven't worked with Eips, so it's just a guess, but try
AllocationId = elasticIpForNat.Apply(eip => eip.AllocationId)
m
Unfortunately, that did not work 😞 I had to call Apply on the property itself, like so:
Result.NatGateway = new NatGateway(NatGatewayName, new NatGatewayArgs
{
SubnetId = PublicPrimarySubnet.Id,
AllocationId = elasticIpForNat.AllocationId.Apply(x=>x)
});
But I get the same error. This did cause a few other things to try to create that it did not get to before - and those failed too, but that's something else I can work through
l
Looks like it shouldn't be needed anyway. The typescript version of this (from Crosswalk) doesn't need to use apply: https://github.com/pulumi/pulumi-awsx/blob/6e41506897a3d7bf3985beb8ecdc596638047699/nodejs/awsx/ec2/natGateway.ts#L62
m
Got it working, after taking a closer look at the example you posted above. I needed the Eip.Id property. This makes sense as we use the .Id property when referencing other infrastructure items. However, the "AllocationId" property on the NatGatewayArgs is confusing, and the docs for dotnet, while better than nothing, are pretty basic. Final code that works:
// NAT gateway needs an elastic IP
var elasticIpForNat = new Eip($"{Request.Name}_NAT_Gateway", new EipArgs
{
Vpc = true
});
Result.NatGateway = new NatGateway(NatGatewayName, new NatGatewayArgs
{
SubnetId = PublicPrimarySubnet.Id,
AllocationId = elasticIpForNat.Id
});
👍 1