how do i use the result of a data source function ...
# general
w
how do i use the result of a data source function as an input to a resource?
f
like this?
Copy code
export const aws_vpc = pulumi.output(aws.ec2.getVpc({
    filters: [
        {
            name: "tag:env",
            values: [`${config.env}`],
        },  
        {
            name: "tag:Name",
            values: [`${config.env}-us-west-2`],
        },  
    ],    
}));    

const vpc_id = aws_vpc.apply(__arg0 => __arg0.id);
w
Building on the earlier example. Something like this should work. You can pass
Futures
in anywhere
Input
is accepted - so you can pass an
Output
, a
Future
or a raw value):
Copy code
async def get_public_ip(public_ip_name, resource_group_name):
    ip_result = await network.get_public_ip(name=public_ip_name, resource_group_name=resource_group_name)
    return ip_result.ip_address

r = Resource("my-resource",
  ip_addres = get_public_ip("a", "b"))
I think that @worried-engineer-33884 was asking specifically about Python given his earlier questions - but @fancy-magazine-29876 is exactly right for JavaScript.
👍 1
w
yes i was, and thanks Luke, I'll give that a try