Is there a way to get the dnsIpAddresses of a Micr...
# aws
l
Is there a way to get the dnsIpAddresses of a MicrosoftAD instance in the same run as it is being created? The Terraform module provides them on the DirectoryService resource, but the only thing in the Pulumi equivalent is its ID. If I
.apply()
the ID, I can use getDirectory which returns the dnsIPAddresses, but I can't create a new resource from within an
.apply()
. So I can't create my VpcDhcpOptions from those IP addresses 😞
Found it. The example code from the
getDirectory
function was a good start. This is passing tests:
Copy code
const dnsIpAddresses = this.ad.id.apply(async (directoryId) => {
      const result = await aws.directoryservice.getDirectory({ directoryId: directoryId }, { async: true });
      return result.dnsIpAddresses;
    });
(It's not deployed yet, so I might be back later for more help 🙂 )
I wonder if it's possible to have async dynamic properties in TypeScript... having that code in the
aws.directoryservice.Directory
object would be handy..
g
dnsIpAddresses
is an output of
aws.directoryservice.Directory
- https://www.pulumi.com/docs/reference/pkg/aws/directoryservice/directory/#dnsipaddresses_nodejs. You should be able to export/output this directly or use this as an input to other resources. So you should not need to use
getDirectory
after the fact. Is this not working for you?
l
I don't think so. I'm having a lot of issues with dnsIpAddress fields all over the place. I used this workaround because those fields weren't being populated. I can't use them in VpcDhcpOptions either, they're not even getting into that. If I pass the the dnsIpAddresses returned as outputs (that I can see in my test breakpoints) into VpcDhcpOptions
domainNameServers
,
ntpServers
and
netbiosNameServers
input args, they're not there when I break in
setMocks
with type = "awsec2/vpcDhcpOptionsVpcDhcpOptions". The other args fields are there, like
netbiosNodeType
, but the 3 servers fields are gone.
I'll review my test code, I'm actively working on it right now. Maybe I've missed something fundamental...
I've got dnsIpAddresses working in my test stub code.. I'd tied myself into so many little knots...
Thanks for pointing out the output property, that was a basic mistake on my part.
Plus the issue is when I run with Mocha CLI. It's actually all good with Pulumi...