I'm trying to use one instance's privateIp in the ...
# typescript
I'm trying to use one instance's privateIp in the user data of another instance. I tried doing something like
Copy code
function getIp (server: aws.ec2.Instance) {
  return pulumi.all([server.privateIp]).apply(([privateIp]) => {
                      return pulumi.interpolate`${privateIp}`;
to get the IP, but it still gives me the calling toString on an output error instead of the value. Thoughts on how to do this?
You can use
directly in that case.
Copy code
const userData = pulumi.interpolate`
IP Address: ${instance.publicIp}
Subnet ID: ${vpc.publicSubnetIds[0]}
Without needing .all and .apply
👏 👏 👏 👏
Okay, so here was the wrinkle.
It looks like this doesn't work, but I just stopped doing it with two strings.
Copy code
const str = pulumi.interpolate'config ${inst.privateIp}';

const otherStr = '${str}'
So I stopped using two strings, which is ugly, but since it works, whatever. I'll move on.
For two strings you can use .all and then .apply