Hey I'm working with go/aws and having trouble get...
# general
s
Hey I'm working with go/aws and having trouble getting an EIP and NATGateway to work together. I have the EIP being created and the NATGateway taking the EIP's AllocationID as a param but pulumi is blowing up saying the AllocaitonID is a missing argument
w
Could you share the error message?
(And if possible, the code snippet?)
s
Copy code
// Make an EIP for the NAT Gateway
natEIP, err := ec2.NewEip(ctx, "NATEIP", &ec2.EipArgs{
    PublicIpv4Pool: "amazon",
    Vpc:            true,
})

// Make a NAT gateway
natGateway, err := ec2.NewNatGateway(ctx, "NATGateway", &ec2.NatGatewayArgs{
    AllocationId: natEIP.AllocationId(),
    SubnetId:     publicSubnet.ID(),
}
======== ERROR MESSAGE ========
Copy code
Diagnostics:
  aws:ec2:NatGateway (NATGateway):
    error: aws:ec2/natGateway:NatGateway resource 'NATGateway' has a problem: "allocation_id": required field is not set
The EIP is being created and I can see the allocation id inside the AWS console
w
It appears that
natEIP.AllocationId()
is undefined for this type of
Eip
resource. Instead, you need to use
natEIP.ID()
. Can't explain why that is the API design personally - but it is the pattern used here https://pulumi.io/reference/pkg/nodejs/@pulumi/aws/ec2/#example-usage-10 and I tried it in Go and it worked.
s
Huh how weird! I'll give it a try, thanks!