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
  • d

    dazzling-answer-16144

    07/13/2022, 12:43 AM
    So this may be a dumb question but I'm struggling to understand how to feed the results of
    aws.ec2.get_subnets()
    into the arguments of
    aws.ec2.get_subnet()
    as the former returns an awaitable which is not accepted by the latter, am I missing anything? Sample (broken code):
    subnet_ids = await aws.ec2.get_subnets(
            filters=[
                aws.ec2.GetSubnetsFilterArgs(
                    name="vpc-id",
                    values=[vpc_id],
                )
            ]
        )
        subnet = aws.ec2.get_subnet(id=subnet_ids[0])
    e
    • 2
    • 1
  • r

    rhythmic-branch-12845

    07/13/2022, 9:50 AM
    how are folks dealing with large programs over here? are you splitting your code into multiple files, and then using
    import
    ?
    d
    • 2
    • 1
  • r

    rhythmic-branch-12845

    07/13/2022, 12:01 PM
    has anybody noticed that the python docs are badly broken? e.g. https://www.pulumi.com/docs/reference/pkg/python/pulumi/#pulumi.ResourceOptions. It seems an issue was already raised for this in *Nov 2020*… How are folks surviving over here?
  • q

    quick-wolf-8403

    07/15/2022, 10:44 PM
    Hiya! Is anyone using something besides pip with pulumi? I'm trying to use Poetry, and running into some hiccups during Github Actions.
    e
    c
    • 3
    • 2
  • k

    kind-jelly-61624

    07/18/2022, 5:59 PM
    Hey folks, Need help understanding if this is a bug or a feature: I have a schema very similar to the boilerplate. I’m trying to return the S3 bucket as an output of my Component Resource, but any values I have encrypted in the bucket are returned in plaintext. Here’s an example output:
    {  
            acceleration_status                 : [secret]
            bucket                              : {
                acceleration_status                 : "Suspended"
                acl                                 : "private"
                .......
            }
          }
    When I return the encrypted acceleration_status as it’s own output - it stays encrypted. But when I return it as a field within the bucket object - it gets decrypted.
    • 1
    • 3
  • q

    quiet-plastic-34312

    07/21/2022, 9:01 PM
    anyone know if there any example in python for OCI platform?
    q
    • 2
    • 3
  • n

    nutritious-battery-42762

    07/22/2022, 6:18 PM
    I'm trying to get dynamic resource provider working but i keep getting
    pulumi-python:dynamic:Resource (godaddy-record):
        error: Exception calling application: Program run without the Pulumi engine available; re-run using the `pulumi` CLI
    I found this issue but i still get the error even if the dynamic resource is defined inside
    __main__
    https://github.com/pulumi/pulumi/issues/7453
    e
    • 2
    • 4
  • b

    bored-vase-40478

    07/25/2022, 6:48 PM
    Hi Guys! I'm trying to extract a resource property (output) and I don't understand what I am doing wrong. 😞 Thanks! here is the code that i'm executing:
    for subnet_id in private_subnets:
        
        subnet = ec2.get_subnet(id=subnet_id)
        az = subnet.availability_zone
    
        ### ENI
        eni_name=...
        eni=ec2.NetworkInterface(
            resource_name=eni_name,
            subnet_id=subnet_id,
            ...
        )
    
        my_ip=eni.private_ip.apply(lambda private_ip: f"my-{private_ip}")
        print(my_ip)
    b
    • 2
    • 3
  • b

    bored-vase-40478

    07/25/2022, 6:48 PM
    error 😞
    Calling __str__ on an Output[T] is not supported.
        To get the value of an Output[T] as an Output[str] consider:
        1. o.apply(lambda v => f"prefix{v}suffix")
        See <https://pulumi.io/help/outputs> for more details.
        This function may throw in a future version of Pulumi.
  • s

    straight-restaurant-537

    07/27/2022, 3:24 AM
    Hey guys, I'm new to Pulumi and Python, so please excuse my question, if it is very simplistic. I have a resource component which has a dict of pulumi objects created and I am asserting the outputs in a unit test. This code does work, but I was wondering if there was a better way to do it?
    @pulumi.runtime.test
      def test_policy_assignment_created(self):
          available_assignments = AvailableAssignments(assignments_json=self.object_mother.get_assignments_json())
          
          sut = PolicyAssignmentComponent(self.policy_assignments_model, available_assignments, self.opts)
      
          def check_policy_assignment(args):
              management_group_name, policy_assignment_objects = args
              
              assert management_group_name == self.policy_assignments_model.management_group_name
              assert len(policy_assignment_objects) == self.object_mother.get_assignments_json_count()
    
              def assert_policy_properties(args):
                id, enforcement_mode, location, policy_definition_id  = args
    
                expected_policy_assignment = self.object_mother.get_policy_assignment_by_policy_def_id(
                  policy_def_id=policy_definition_id
                )
                
                expected_id = f"{management_group_name}-{expected_policy_assignment.name}_id"
                
                assert expected_id == id
                assert enforcement_mode == expected_policy_assignment.enforcementMode
                assert location == expected_policy_assignment.location
                assert policy_definition_id == expected_policy_assignment.policy_definition_id
              
              for policy_assignment_object in policy_assignment_objects:
                pulumi.Output.all(
                  policy_assignment_object.id,
                  policy_assignment_object.enforcement_mode,
                  policy_assignment_object.location,
                  policy_assignment_object.policy_definition_id,
                ).apply(assert_policy_properties)
    
          return pulumi.Output.all(sut.management_group_name, sut.policy_assignment_objects).apply(check_policy_assignment)
  • w

    white-terabyte-21934

    07/27/2022, 9:36 AM
    Hi , I am looking for a way to pulumi login via automation api in python , any sample ?
    b
    • 2
    • 2
  • k

    kind-france-51068

    07/27/2022, 8:12 PM
    Hey everyone, this may or may not be a dumb question but I'm working on a project right now where I have to use pulumi to grab a list of all of the snapshots in a project and find the most recently created to build a new host instance. Seems pretty simple but I'm having a hard time with grabbing a list of snapshots. I'm using the "google-native" provider with the 'getSnapshot' function. The documentation says "Returns the specified Snapshot resource. Gets a list of available snapshots by making a list() request." and for the life of me I can't figure out how to send that list request. I'm also seeing the same documentation for 'getDisk' and 'getInstance' and others so I'm feeling like I'm missing something simple. Anyway, this is the documentation I'm talking about: https://www.pulumi.com/registry/packages/google-native/api-docs/compute/v1/getsnapshot/ any help would be appreciated.
  • s

    shy-bird-55689

    07/28/2022, 12:28 AM
    Is there are a resource for AWS Client VPN Endpoints? Cant seem to find one, although i can see other vpn options
    b
    • 2
    • 2
  • f

    full-window-21515

    07/28/2022, 9:48 PM
    How would I do pulumi config set "aws:skipMetadataApiCheck" false In Python?
    e
    • 2
    • 2
  • b

    busy-branch-95201

    08/02/2022, 9:57 AM
    Hi, I want to migrate from one resource (EBS csi driver via Helm chart) to another (eks addon for ebs csi driver). However those two conflict with each other so creating the addon before deleting the helm chart does not work. Is there anything I could do to force pulumi to first delete the resources of the helm chart and after that install the eks addon?
    l
    • 2
    • 2
  • w

    worried-gold-55244

    08/04/2022, 7:42 PM
    Hi Guys, is it possible to catch invoke exceptions ? here is the code
    try:
        key_pair = compute.get_keypair_output(args.region + '_key',
                                              opts=pulumi.ResourceOptions(provider=provider, parent=self))
    except:
        key_pair = compute.Keypair(args.region + '_key',
                                   name=args.region + '_key',
                                   public_key=args.ssh_key_pub,
                                   opts=pulumi.ResourceOptions(provider=provider, parent=self))
    and error:
    error: Program failed with an unhandled exception:
        error: Traceback (most recent call last):
          File "/usr/local/bin/pulumi-language-python-exec", line 107, in <module>
            loop.run_until_complete(coro)
          File "/usr/local/Cellar/python@3.9/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
            return future.result()
          File "/Users/amuntean/Projects/new_netlog/venv/lib/python3.9/site-packages/pulumi/runtime/stack.py", line 126, in run_in_stack
            await run_pulumi_func(lambda: Stack(func))
          File "/Users/amuntean/Projects/new_netlog/venv/lib/python3.9/site-packages/pulumi/runtime/stack.py", line 51, in run_pulumi_func
            await wait_for_rpcs()
          File "/Users/amuntean/Projects/new_netlog/venv/lib/python3.9/site-packages/pulumi/runtime/stack.py", line 110, in wait_for_rpcs
            raise exception
          File "/Users/amuntean/Projects/new_netlog/venv/lib/python3.9/site-packages/pulumi/output.py", line 194, in run
            transformed: Input[U] = func(value)
          File "/Users/amuntean/Projects/new_netlog/venv/lib/python3.9/site-packages/pulumi_openstack/_utilities.py", line 232, in <lambda>
            }).apply(lambda resolved_args: func(*resolved_args['args'],
          File "/Users/amuntean/Projects/new_netlog/venv/lib/python3.9/site-packages/pulumi_openstack/compute/get_keypair.py", line 121, in get_keypair
            __ret__ = pulumi.runtime.invoke('openstack:compute/getKeypair:getKeypair', __args__, opts=opts, typ=GetKeypairResult).value
          File "/Users/amuntean/Projects/new_netlog/venv/lib/python3.9/site-packages/pulumi/runtime/invoke.py", line 144, in invoke
            raise invoke_error
        Exception: invoke of openstack:compute/getKeypair:getKeypair failed: invocation of openstack:compute/getKeypair:getKeypair returned an error: invoking openstack:compute/getKeypair:getKeypair: 1 error occurred:
            * Error retrieving openstack_compute_keypair_v2 iad-private-dev_key: Resource not found
        error: an unhandled error occurred: Program exited with non-zero exit code: 1
  • k

    kind-hamburger-15227

    08/05/2022, 12:17 AM
    import pulumi
    import pulumi_aws as aws
    
    # Create an AWS provider for the us-east-1 region.
    useast1 = aws.Provider("useast1", region="us-east-1")
    
    # Create an ACM certificate in us-east-1.
    cert = aws.acm.Certificate("cert",
        domain_name="<http://foo.com|foo.com>",
        validation_method="EMAIL",
        __opts__=pulumi.ResourceOptions(provider=useast1))
    Trying to create my own provider, but it fails with
    File ~/.local/lib/python3.10/site-packages/pulumi/runtime/settings.py:202, in get_monitor()
        200 monitor = SETTINGS.monitor
        201 if not monitor:
    --> 202     require_test_mode_enabled()
        203 return monitor
    
    File ~/.local/lib/python3.10/site-packages/pulumi/runtime/settings.py:147, in require_test_mode_enabled()
        145 def require_test_mode_enabled():
        146     if not is_test_mode_enabled():
    --> 147         raise RunError(
        148             "Program run without the Pulumi engine available; re-run using the `pulumi` CLI"
        149         )
    
    RunError: Program run without the Pulumi engine available; re-run using the `pulumi` CLI
    The purpose of the provide to set config
    pulumi config set aws:skipCredentialsValidation true
    - I am trying to run flask api example for automation api: https://github.com/pulumi/automation-api-examples/blob/main/python/pulumi_over_http/app.py any hints? Original sample fails with
    Diagnostics:
      aws:s3:Bucket (s3-website-bucket):
        error: 1 error occurred:
        	* error configuring Terraform AWS Provider: AWS account ID not previously found and failed retrieving via all available methods. See <https://www.terraform.io/docs/providers/aws/index.html#skip_requesting_account_id> for workaround and implications. Errors: 2 errors occurred:
  • k

    kind-hamburger-15227

    08/07/2022, 11:02 AM
    How to create default_target_group for load balancer in python?
    listener = awsx.lb.NetworkLoadBalancer("lb",default_target_group=['group',{ 'port' : 80, 'protocol':'TCP'}])
    I am trying to re-create typescript example in python
    const listener = new awsx.lb.NetworkLoadBalancer('lb')
      .createTargetGroup('group', { port: 80, protocol: 'TCP' })
      .createListener('listener', {
        port: 443,
        protocol: 'TLS',
        // ARN of the Amazon Cert Manager certificate for *.<http://mysite.com|mysite.com>
        certificateArn: certCertificate.arn,
      })
  • f

    few-tent-80031

    08/08/2022, 4:02 PM
    Hi guys, my name is Ivan Indjic and I am working as a DevOps engineer in a Serbian based company. I'm learning Pulumi both for work and for my master thesis. I have one problem with my current stack. I created one rds instance and I want to use output of that resource ( rds address ) as an env var in my ecs container definition. So, I have this instance below.
    database = aws.rds.Instance(
        resource_name="master-thesis-rds",
        allocated_storage = 5,
        instance_class='db.t4g.micro',
        allow_major_version_upgrade=False,
        apply_immediately=False,
        auto_minor_version_upgrade=True,
        db_name='master',
        db_subnet_group_name='db-subnet-group',
        deletion_protection=False,
        enabled_cloudwatch_logs_exports=['audit', 'error', 'general', 'slowquery'],
        engine='mysql',
        performance_insights_enabled=True,
        port=5432,
        publicly_accessible=False,
        skip_final_snapshot=True,
        vpc_security_group_ids=[db_sg.id],
        username='',
        password=password.value
    )
    Then, I did this:
    rds_endpoint = database.address.apply(lambda address: f"http://{address}")
    And last, I have ecs container definition with these env vars:
    "environment": [
                    {
                        "name": "user", "value": ""
                    },
                    {
                        "name": "password", "value": f"{password.value}"
                    },
                    {
                        "name": "db_host_replica", "value": rds_endpoint
                    },
                    {
                        "name": "db_host", "value": rds_endpoint
                    }
                ],
    However, when I run this, I get
    TypeError: Object of type Output is not JSON serializable
    Do you guys know where is a mistake? I tried different ways but I cannot get right output converted to string. Thank you
    b
    • 2
    • 2
  • s

    sparse-intern-71089

    08/09/2022, 7:55 AM
    This message was deleted.
    e
    • 2
    • 1
  • p

    prehistoric-book-85014

    08/18/2022, 9:21 PM
    Good afternoon guys, how are you? How can I get all values ​​from export using python?
    b
    a
    • 3
    • 4
  • e

    elegant-smartphone-60282

    08/21/2022, 12:27 PM
    Hey, i have this python script that i want to check if the security group existing or not, if its existing then import it if not create a new one, but i get this error
    error: Program failed with an unhandled exception:
        Traceback (most recent call last):
          File "/opt/homebrew/bin/pulumi-language-python-exec", line 111, in <module>
            loop.run_until_complete(coro)
          File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/base_events.py", line 641, in run_until_complete
            return future.result()
          File "/Users/afeefaz/Downloads/iac/pulumi/venv/lib/python3.10/site-packages/pulumi/runtime/stack.py", line 126, in run_in_stack
            await run_pulumi_func(lambda: Stack(func))
          File "/Users/afeefaz/Downloads/iac/pulumi/venv/lib/python3.10/site-packages/pulumi/runtime/stack.py", line 51, in run_pulumi_func
            await wait_for_rpcs()
          File "/Users/afeefaz/Downloads/iac/pulumi/venv/lib/python3.10/site-packages/pulumi/runtime/stack.py", line 73, in wait_for_rpcs
            await RPC_MANAGER.rpcs.pop()
          File "/Users/afeefaz/Downloads/iac/pulumi/venv/lib/python3.10/site-packages/pulumi/runtime/rpc_manager.py", line 68, in rpc_wrapper
            result = await rpc
          File "/Users/afeefaz/Downloads/iac/pulumi/venv/lib/python3.10/site-packages/pulumi/output.py", line 98, in is_value_known
            return await is_known and not contains_unknowns(await future)
          File "/Users/afeefaz/Downloads/iac/pulumi/venv/lib/python3.10/site-packages/pulumi/output.py", line 98, in is_value_known
            return await is_known and not contains_unknowns(await future)
          File "/Users/afeefaz/Downloads/iac/pulumi/venv/lib/python3.10/site-packages/pulumi/output.py", line 98, in is_value_known
            return await is_known and not contains_unknowns(await future)
          [Previous line repeated 10 more times]
          File "/Users/afeefaz/Downloads/iac/pulumi/venv/lib/python3.10/site-packages/pulumi/runtime/resource.py", line 561, in do_register
            req = resource_pb2.RegisterResourceRequest(
        TypeError: bad argument type for built-in operation
    Here’s the python code :
    # check for SG existence
    try:
        existing_sg = aws.ec2.get_security_group(name="sg_name", vpc_id=vpc_id)
    except:
        print("Creating new SG")
    
        created_sg = aws.ec2.SecurityGroup("sg_name",
            name="sg_name",
            vpc_id=vpc_id,
            egress=[{
                'from_port': 0,
                'to_port': 0,
                'protocol': "-1",
                'cidr_blocks': ['0.0.0.0/0']
            }],
            ingress=[{
                'from_port': 0,
                'to_port': 0,
                'protocol': "-1",
                'cidr_blocks': ['0.0.0.0/0']
            }],
            tags={
                "Name":"sg_name"
            }
        )
        pulumi.export("sg_name", created_sg.id)
    else:
        aws.ec2.SecurityGroup("sg_name",
            opts=pulumi.ResourceOptions(
                import_=[existing_sg.id]
                )
        )
    b
    p
    a
    • 4
    • 3
  • e

    elegant-smartphone-60282

    08/25/2022, 12:07 PM
    Hey i have this code
    public_subnets = dis_stack.get_output("public_subnets")
    
    subnets_list = public_subnets.apply(lambda id: id)
    but it returns an output object, how can i do that i get a list ?
    f
    p
    • 3
    • 18
  • a

    aloof-traffic-97122

    08/25/2022, 6:01 PM
    Cross posting gcp channel question, as this is probably more relevant to the #python channel: https://pulumi-community.slack.com/archives/CRFUR2DGB/p1661450287196499
  • e

    elegant-smartphone-60282

    08/30/2022, 8:24 AM
    Hey, i have this directory tree
    parent_dir:
      file_1.py
      folder_1:
        folder_2:
          file_2.py
    i want to import file_1 to file_2, how to do that?
    h
    • 2
    • 2
  • n

    nutritious-battery-42762

    09/01/2022, 5:33 PM
    Using aws native i'm getting this issue anytime i attempt to update a task definition
    aws-native:ecs:TaskDefinition app-task-definition-staging updating [diff: ~containerDefinitions]; error: operation error CloudControl: UpdateResource, https response error StatusCode: 400, RequestID: c85809ba-1dc5-44ca-be06-ab16f348a1fb, NotUpdatableException: Invalid patch update: createOnlyProperties [/properties/ContainerDefinitions] cannot be updated
     ~  aws-native:ecs:TaskDefinition app-task-definition-staging **updating failed** [diff: ~containerDefinitions]; error: operation error CloudControl: UpdateResource, https response error StatusCode: 400, RequestID: c85809ba-1dc5-44ca-be06-ab16f348a1fb, NotUpdatableException: Invalid patch update: createOnlyProperties [/properties/ContainerDefinitions] cannot be updated
        pulumi:pulumi:Stack frontent-frontend.staging running error: update failed
        glamo:resource:Service frontend-service  
        pulumi:pulumi:Stack frontent-frontend.staging **failed** 1 error
    b
    • 2
    • 1
  • w

    worried-xylophone-86184

    09/01/2022, 6:19 PM
    Hi all ! For the implementation of the our Pulumi stack, we use the stack file heavily to store the configurations the infrastructure should come up with. Incase there is a misconfiguration in the STACK file, we report what the mistake is. Unfortunately, incase there is a mistake and some decides to move forward with the deployment, pulumi destroys the entire stack, which is the intended behaviour given the fact that it will either bring it up or it will tear it down. Is there a way I could exit the pulumi process incase there is misconfiguration.
    b
    • 2
    • 9
  • v

    victorious-continent-984

    09/04/2022, 12:52 PM
    Hi, with new version of pulumi 3.39.1 noticed warnings:
    warning: Error downloading plugin: 403 HTTP error fetching plugin from  <https://get.pulumi.com/releases/plugins/>...
    I’m using several custom python packages generated using crd2pulumi. It seems like plugin resolving mechanism tries to download something from public repo… This is very annoying since int adds a good few minutes for each pulumi up run. Do you know anything about it?
    l
    • 2
    • 3
  • a

    astonishing-branch-30086

    09/06/2022, 9:43 AM
    We are using a dynamic provider written in Python. In one instance, we want to delete a resource using the provider. The delete() method is implemented and has worked before, but we are now running into a problem. Due to refactoring, we now require additional props in the delete() method, that were not present when the resource was created. Thus it is not part of
    outputs
    in the resource's stack entry. How do I solve this cleanly? I'm guessing the correct way is to somehow update the state only, so that for the dynamic resource, the outputs are rewritten with the current inputs?
  • a

    astonishing-branch-30086

    09/06/2022, 9:44 AM
    Thinking more about it now, would
    pulumi refresh
    do this? Admittedly, we were lazy and have skipped the implementation of refresh() for the resource.
Powered by Linen
Title
a

astonishing-branch-30086

09/06/2022, 9:44 AM
Thinking more about it now, would
pulumi refresh
do this? Admittedly, we were lazy and have skipped the implementation of refresh() for the resource.
View count: 1