https://pulumi.com logo
#general
Title
# general
m

mammoth-night-22453

05/20/2020, 9:31 PM
Hello, just getting started with Pulumi on dotnet for AWS. Creating a VPC, with a NatGateway. Have EIPs created, and trying to reference the AllocationId. However, I'm getting this error: error: awsec2/natGatewayNatGateway resource 'Production' has a problem: Missing required property 'allocationId' My code is clearly setting the AllocationId property of the NatGatewayArgs using the EIP.AllocationId output property. Not sure what I'm doing wrong, any thoughts?
l

little-cartoon-10569

05/20/2020, 9:38 PM
Are you using
Apply
? Can you post some code?
m

mammoth-night-22453

05/20/2020, 9:43 PM
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

little-cartoon-10569

05/20/2020, 9:55 PM
I haven't worked with Eips, so it's just a guess, but try
AllocationId = elasticIpForNat.Apply(eip => eip.AllocationId)
m

mammoth-night-22453

05/20/2020, 9:58 PM
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

little-cartoon-10569

05/20/2020, 10:02 PM
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

mammoth-night-22453

05/20/2020, 10:35 PM
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