https://pulumi.com logo
c

chilly-photographer-60932

01/29/2019, 9:08 PM
Question , how do I convert an
Output<string>
to
string
? One of the function returns an
Output<string>
and the other one expects a
string
.
@gentle-diamond-70147 @gorgeous-egg-16927 Would you guys be able to answer this?
g

gentle-diamond-70147

01/29/2019, 9:35 PM
Depending on where you're needing to do this
.apply(x=>x)
might be the best option or my favorite
pulumi.interpolate...
.
c

chilly-photographer-60932

01/29/2019, 9:44 PM
I want to convert an
Output<string>
to
Input<string>
I don’t see an example
Copy code
export async function createAliasRecord(
  targetDomain: string,
  loadBalancername: Output<string>
): Promise<aws.route53.Record> {
  const domainParts = getDomainAndSubdomain(targetDomain);
  const hostedZone = await aws.route53.getZone({
    name: domainParts.parentDomain
  });

  return new aws.route53.Record(targetDomain, {
    name: domainParts.subdomain,
    zoneId: hostedZone.zoneId,
    type: "A",
    aliases: [
      {
        name: loadBalancername,
        zoneId: getHostedZoneId().then(s => s.id),
        evaluateTargetHealth: true
      }
    ]
  });
}
In the above example I would like to pass
loadBalancername
to
aliases
name
the
name
requires
Input<string>
g

gorgeous-egg-16927

01/29/2019, 9:59 PM
Does that not run? IIRC, you can pass
Output<string>
into places requiring an
Input<String>
c

chilly-photographer-60932

01/29/2019, 10:00 PM
I get an error
Copy code
Diagnostics:
  aws:route53:Record (<http://xyz.xyz.io|xyz.xyz.io>):
    error: aws:route53/record:Record resource '<http://xyz.xyz.io|xyz.xyz.io>' has a problem: "alias.0.name": required field is not set
If I hardcode the string it works.
But that’s not what I want.
g

gentle-diamond-70147

01/29/2019, 10:01 PM
how are you calling the function
createAliasRecord(...)
?
g

gorgeous-egg-16927

01/29/2019, 10:01 PM
What if you do
loadBalancername.get()
?
o

orange-tailor-85423

01/29/2019, 10:02 PM
Is pulumi.io running in Azure? 🙂
c

chilly-photographer-60932

01/29/2019, 10:02 PM
I am calling
createAliasRecord(<http://config.xyz|config.xyz>, xyz);
I cannot do a
get
because it errors
Copy code
error: Error: Cannot call '.get' during update or preview.
    To manipulate the value of this Output, use '.apply' instead.
g

gentle-diamond-70147

01/29/2019, 10:06 PM
what is
xyz
in
createAliasRecord(<http://config.xyz|config.xyz>, xyz);
?
g

gorgeous-egg-16927

01/29/2019, 10:06 PM
Sorry, I'm still learning myself. I see this in the library code:
Copy code
/**
 * Input is a property input for a resource.  It may be a promptly available T, a promise
 * for one, or the output from a existing Resource.
 */
export declare type Input<T> = T | Promise<T> | Output<T>;
g

gentle-diamond-70147

01/29/2019, 10:07 PM
@orange-tailor-85423 I'm pretty sure it's on AWS?
o

orange-tailor-85423

01/29/2019, 10:07 PM
ok - took a while to load and Azure is having issues. Just wondering 🙂
c

chilly-photographer-60932

01/29/2019, 10:07 PM
xyz
is
Output<String>
g

gentle-diamond-70147

01/29/2019, 10:09 PM
so something like
const xyz = loadbalancer.name;
is further up in your code?
c

chilly-photographer-60932

01/29/2019, 10:11 PM
My mistake i had the
ip
instead of
name
which was causing the issue.
The error message wasn’t clear. Thanks guys