https://pulumi.com logo
#general
Title
# general
w

worried-engineer-33884

02/27/2019, 10:37 PM
how do i use the result of a data source function as an input to a resource?
f

fancy-magazine-29876

02/27/2019, 10:39 PM
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

white-balloon-205

02/27/2019, 10:39 PM
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

worried-engineer-33884

02/27/2019, 10:41 PM
yes i was, and thanks Luke, I'll give that a try