https://pulumi.com logo
Docs
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
  • l

    little-river-49422

    05/09/2019, 3:42 PM
    if one of these happen - pulumi will attempt to reconfigure resource to desired state
  • g

    gentle-diamond-70147

    05/09/2019, 3:52 PM
    @straight-napkin-70642 can you elaborate on what you're trying to achieve? By default, a
    pulumi up
    does not do a refresh from your cloud. That's what
    --refresh
    or
    pulumi refresh
    is for.
    s
    • 2
    • 5
  • g

    gentle-diamond-70147

    05/09/2019, 3:54 PM
    Pulumi does support dependencies... they're usually implicit by references between resources using outputs.
  • g

    gentle-diamond-70147

    05/09/2019, 3:55 PM
    For example, this line https://github.com/pulumi/examples/blob/master/aws-py-webserver/__main__.py#L23 creates a dependency on the security group defined further up in the application.
  • l

    little-river-49422

    05/09/2019, 4:04 PM
    @gentle-diamond-70147 you can do pulumi up --refresh?
  • l

    little-river-49422

    05/09/2019, 4:05 PM
    and it would do a refresh + up? or force up or what?
  • g

    gentle-diamond-70147

    05/09/2019, 4:21 PM
    yes, you can do
    pulumi up --refresh
    . It essentially does the same as
    pulumi refresh
    and then
    pulumi up
    when run separately. It does the refresh and then diff against the updated state and still prompts you before continuing.
  • l

    little-river-49422

    05/09/2019, 5:03 PM
    ok, thats useful, i suppose. as I was using refresh followed by up, thanks!
  • w

    worried-engineer-33884

    05/09/2019, 7:16 PM
    Anyone have experience writing python tests for pulumi? Read @big-piano-35669’s blog post and trying to kick the tires on this. https://blog.pulumi.com/testing-your-infrastructure-as-code-with-pulumi Is there an example of the tests from that blog but written in Python?
    l
    g
    +2
    • 5
    • 9
  • s

    straight-napkin-70642

    05/09/2019, 7:28 PM
    Another experience request: has anyone experience integrating pulumi and AWS chalice ( chalice.readthedocs.io ) ? Particularly I would love to develop with chalice and deploy with pulumi but proxy integration doesn't look to work with chalice, and I don't want to manually sync methods between chalice and pulumi.
  • b

    big-glass-16858

    05/10/2019, 1:49 PM
    Hi there, just getting started on pulumi (awesome software btw) , I'm having troubles retrieving AZs with pulumi_aws, I think i may be doing something wrong, just want to double check with you. I'm creating a ComponentResource and getting the AZs but asyncio is complaining it can't be called from a running loop. I spend a lot of time searching in the documentation but I couldn't find anything.
    -.py
  • b

    big-glass-16858

    05/10/2019, 1:51 PM
    I'm running Python 3.7.3 and the error is the following
    RuntimeError: asyncio.run() cannot be called from a running event loop
    if anyone can point me to the right docs or code, that would be nice 👍
    b
    • 2
    • 2
  • s

    straight-napkin-70642

    05/13/2019, 7:16 PM
    Hi, I'm trying to use aws provider to setup a domain, I don't know how to translate a alias in pulumi python, could someone give a pointer?
    # Example DNS record using Route53.
    # Route53 is not specifically required; any DNS host can be used.
    resource "aws_route53_record" "example" {
      name    = "${aws_api_gateway_domain_name.example.domain_name}"
      type    = "A"
      zone_id = "${aws_route53_zone.example.id}"
    
      alias {
        evaluate_target_health = true
        name                   = "${aws_api_gateway_domain_name.example.cloudfront_domain_name}"
        zone_id                = "${aws_api_gateway_domain_name.example.cloudfront_zone_id}"
      }
    }
    Example from https://www.terraform.io/docs/providers/aws/r/api_gateway_domain_name.html
    • 1
    • 5
  • l

    little-river-49422

    05/15/2019, 9:09 AM
    hey, is this expected: when doing pulumi up --refresh it would fail if there is a pod in failed state. but to me this makes no sense, because the UP should (at least in theory) introduce my changes to fix the problem.
    w
    • 2
    • 7
  • c

    colossal-room-15708

    05/16/2019, 8:35 PM
    Will we soon get a better experience writing pulumi in python? At the moment I prefer nodejs over python because intellisense works much better and drilling into resources for examples actually works.
    w
    i
    +2
    • 5
    • 41
  • b

    boundless-room-36997

    05/17/2019, 11:26 PM
    Is pulumi/python still behind the other languages ? Last time I looked at pulumi JS and TS were far ahead of python in terms of i.e. examples ...\
  • w

    worried-engineer-33884

    05/20/2019, 5:34 PM
    @big-piano-35669 @white-balloon-205 I'm trying to understand the event loop especially when writing Python test. If I execute
    my_resource.some_output.apply(lambda val: print(val))
    , I get back another output that I believe has a future wrapped up in it that will execute my lambda. When does that actually get awaited?
    w
    • 2
    • 7
  • h

    handsome-rocket-92204

    05/20/2019, 5:42 PM
    I'm just starting with Pulumi so this may be a stupid question, but how am I supposed to be using apigateway.get_vpc_link() ? Do I have to import asyncio in order to make use of it? I'm not having any luck finding help with google
  • l

    little-river-49422

    05/20/2019, 6:05 PM
    probably, here's what I've been using to get AKS data:
    async def get_aks_credentials():
        result = await get_kubernetes_cluster(name=gen_name('aks'),
                                              resource_group_name=gen_name('rg')
                                              )
        return result.kube_config_raw
    and then I'm just calling
    get_aks_credentials()
    in my code
  • l

    little-river-49422

    05/20/2019, 6:05 PM
    that will work if you use it in a pulumi resource
  • h

    handsome-rocket-92204

    05/20/2019, 6:47 PM
    I've got this so far:
    import pulumi
    from pulumi_aws import apigateway
    
    async def get_vpclink():
      result = await apigateway.get_vpc_link(name="test-link")
      return result.id
    
    rest_api = apigateway.RestApi('test-api-jenkins')
    
    api_method = apigateway.Method('post', authorization='NONE', http_method='POST', resource_id=rest_api.root_resource_id, rest_api=rest_api.id)
    
    integration = apigateway.Integration('post', connection_id=get_vpclink(), connection_type='VPC_LINK', http_method='POST', resource_id=rest_api.root_resource_id, rest_api=rest_api.id, type='HTTP_PROXY', uri='<https://test-api-jenkins.example.com/generic-webhook-trigger/invoke>')
    
    pulumi.export('REST API ID', rest_api.id)
    and I'm getting the
    RuntimeError: cannot reuse already awaited coroutine
  • l

    little-river-49422

    05/20/2019, 8:05 PM
    whats your pulumi\python versions?
  • h

    handsome-rocket-92204

    05/20/2019, 8:09 PM
    Pulumi: v0.17.12 Python: v3.7.3
  • l

    little-river-49422

    05/20/2019, 8:13 PM
    ok, i think i recall some issues with 3.5.x (which is not supported), probably doesnt apply to your case
  • h

    handsome-rocket-92204

    05/21/2019, 1:40 PM
    I tried creating a new event loop and running get_vpclink() there but I got this error:
    RuntimeError: Cannot run the event loop while another loop is running
  • h

    handsome-rocket-92204

    05/21/2019, 3:22 PM
    Finally got it working. had to import asyncio and use ensure_future. Here's example code:
    import asyncio
    import pulumi
    from pulumi_aws import apigateway
    
    async def get_vpclink(name):
      result = await apigateway.get_vpc_link(name=name)
      return result.id
    
    rest_api = apigateway.RestApi('test-api-jenkins')
    
    api_method = apigateway.Method('post', authorization='NONE', http_method='POST',
                                  resource_id=rest_api.root_resource_id,
                                  rest_api=rest_api.id)
    
    integration = apigateway.Integration('post', connection_id=asyncio.ensure_future(get_vpclink('test-jenkins')),
                                        connection_type='VPC_LINK', http_method='POST',
                                        resource_id=rest_api.root_resource_id,
                                        rest_api=rest_api.id, type='HTTP_PROXY',
                                        uri='<https://test-api-jenkins.example.com/generic-webhook-trigger/invoke>')
    
    pulumi.export('REST API ID', rest_api.id)
  • l

    little-river-49422

    05/21/2019, 4:27 PM
    weird
  • h

    handsome-rocket-92204

    05/21/2019, 5:23 PM
    So now my issue is that I don't seem able to use these coroutines outside of a Pulumi resource. I'd like to have my program reach out and see if a REST API already exists with a given name and skip creating the resources for it if it does but I don't know if that's possible at this point
  • h

    handsome-rocket-92204

    05/21/2019, 5:27 PM
    It also sucks that I can't call get_vpclink() once and get the id into a variable. Now when I implement the for loop it'll be doing that external call every time 😕
    i
    • 2
    • 3
  • h

    handsome-rocket-92204

    05/21/2019, 6:03 PM
    Is there any way to conditionally create resources using the get_x coroutines?
Powered by Linen
Title
h

handsome-rocket-92204

05/21/2019, 6:03 PM
Is there any way to conditionally create resources using the get_x coroutines?
View count: 1