https://pulumi.com logo
Join the conversationJoin Slack
Channels
announcements
automation-api
aws
azure
blog-posts
built-with-pulumi
cloudengineering
cloudengineering-support
content-share
contribex
contribute
docs
dotnet
finops
general
getting-started
gitlab
golang
google-cloud
hackathon-03-19-2020
hacktoberfest
install
java
jobs
kubernetes
learn-pulumi-events
linen
localstack
multi-language-hackathon
office-hours
oracle-cloud-infrastructure
plugin-framework
pulumi-cdk
pulumi-crosscode
pulumi-deployments
pulumi-kubernetes-operator
pulumi-service
pulumiverse
python
registry
status
testingtesting123
testingtesting321
typescript
welcome
workshops
yaml
Powered by Linen
python
  • h

    handsome-rocket-92204

    05/21/2019, 6:18 PM
    Basically, is there any way to use the future outside of a Pulumi resource instantiation?
  • i

    incalculable-sundown-82514

    05/21/2019, 6:38 PM
    not sure what you mean - the future is a standard Python-ism and you can
    await
    them in an
    async
    function
  • i

    incalculable-sundown-82514

    05/21/2019, 6:39 PM
    the bridge between async and non-async functions are that you can use the values returned by async functions as inputs into Pulumi resources
  • h

    handsome-rocket-92204

    05/21/2019, 6:43 PM
    But can I use the values returned by async functions outside of a Pulumi resource? Ex:
    async def get_restapi(name):
      result = await apigateway.get_rest_api(name=name)
      return result.id
    
    if get_restapi('test-jenkins') == None:
      rest_api = apigateway.RestApi(name, name=name)
    Obviously this wouldn't work but that's the functionality I'm looking for
  • i

    incalculable-sundown-82514

    05/21/2019, 6:44 PM
    You’re assuming that
    apigateway.get_rest_api
    returns None when the rest API isn’t found, but I think it’s more likely that it’ll throw an exception instead
  • i

    incalculable-sundown-82514

    05/21/2019, 6:44 PM
    If you did want to do this sort of control flow, though, you could move the
    if get_restapi
    logic inside its own async function and then
    await get_restapi
    to await the future.
  • h

    handsome-rocket-92204

    05/21/2019, 6:47 PM
    I'll give that a shot, thanks
  • h

    handsome-rocket-92204

    05/21/2019, 7:48 PM
    I'm still too unfamiliar with async functions to do what you said but I was able to get what I wanted using boto3 like so:
    apigwclient = boto3.client('apigateway')
    existingapigws = apigwclient.get_rest_apis().get('items')
    
    for gw in existingapigws:
      name = gw.get('name')
      if name in names:
        names.remove(name)
    So I'm just removing gateways that already exist from my list of ones to create before the main loop
  • h

    handsome-rocket-92204

    05/21/2019, 7:53 PM
    Another question: does Pulumi have a way to import resources like Terraform does?
  • l

    little-river-49422

    05/21/2019, 8:33 PM
    not yet
  • l

    little-river-49422

    05/21/2019, 8:33 PM
    at least officially, but there is a hack
  • l

    little-river-49422

    05/21/2019, 8:36 PM
    https://github.com/pulumi/pulumi/issues/1662#issuecomment-483718863
    i
    h
    • 3
    • 2
  • h

    handsome-rocket-92204

    05/21/2019, 8:38 PM
    Interesting. Thanks for the link, that will probably come in handy later
    😛artypus: 1
  • b

    big-glass-16858

    05/22/2019, 12:34 PM
    Hello people, I'm wondering what's the puprose of
    props
    in
    pulumi.ComponentResource()
    , documentation says the following : props (Optional[dict]) – An optional list of input properties to use as inputs for the resource. , When checking Node.JS docs for `new ComponentResource()`it doesn't have props and it says : unused . Component resources do not communicate or store their properties with the Pulumi engine. I'm a little bit confused, did I miss something ?
  • h

    handsome-rocket-92204

    05/22/2019, 2:44 PM
    Use get functions to read the existing resource and bring its parameters into the stack, like this:
    
     export const database = gcp.sql.DatabaseInstance.get('test-database', 'name-in-gcp');
    Is there a way to do the same in Python? Trying to come up with a feasible solution for migrating Terraform-controlled resources into a Pulumi stack
  • l

    little-river-49422

    05/22/2019, 4:30 PM
    do the same get?
  • l

    little-river-49422

    05/22/2019, 4:32 PM
    ah right, i dont think they are implemented?
  • l

    little-river-49422

    05/22/2019, 4:32 PM
    https://pulumi.io/reference/pkg/python/pulumi_gcp/sql/
  • l

    little-river-49422

    05/22/2019, 4:32 PM
    at least looking at this
  • h

    handsome-rocket-92204

    05/22/2019, 4:33 PM
    doesn't look like it. I'm now debating trying to learn JS lol
  • l

    little-river-49422

    05/22/2019, 4:34 PM
    lol, yeah, i'm not going that route for sure 😉
  • h

    handsome-rocket-92204

    05/22/2019, 5:08 PM
    Well thank you again for the link, that worked in JS. Now I'm going to look into using JS to create the state file but then switching the project to Python using the same state file...
  • l

    little-river-49422

    05/22/2019, 6:34 PM
    i wonder if that will work xD
  • l

    little-river-49422

    05/22/2019, 6:35 PM
    i wonder if you can just create a similar resource and just edit it into the existing state file
  • h

    handsome-rocket-92204

    05/22/2019, 7:06 PM
    I was looking into that earlier but it seems like more effort and very error-prone
  • h

    handsome-rocket-92204

    05/22/2019, 7:09 PM
    lol it worked 😛
    🤗 1
  • p

    proud-artist-4864

    05/23/2019, 7:06 AM
    Given the latest changes in terraform 0.12 and the lack of support of provider/engine side python code in pulumi, when will pulumi’s python support add the ability to have callbacks/hooks to python user code during the execution of a pulumi up/refresh/destroy?
  • l

    little-river-49422

    05/23/2019, 7:07 AM
    you can run code on
    pulumi up
    for sure
  • l

    little-river-49422

    05/23/2019, 7:07 AM
    not sure why would you need to run code on refresh though
  • p

    proud-artist-4864

    05/23/2019, 7:07 AM
    No you can’t, not on the “other” side of the engine
Powered by Linen
Title
p

proud-artist-4864

05/23/2019, 7:07 AM
No you can’t, not on the “other” side of the engine
View count: 1