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

    hallowed-animal-47023

    09/06/2022, 7:53 PM
    Is there any cleaner documentation for the Python SDK? I'm hoping I'm missing something - https://www.pulumi.com/docs/reference/pkg/python/pulumi/
    r
    p
    • 3
    • 2
  • a

    able-thailand-87943

    09/12/2022, 8:29 AM
    Hello, Does anyone know if the field
    updateInProgress
    as a part of the output from
    pulumi stack ls --json
    really shows "true", if there is a pulumi up running in the background when not using pulumi service backend? In the short tests we have run, we see that it always returns
    false
  • s

    steep-lamp-20408

    09/12/2022, 1:09 PM
    Hey there, Is anyone using Localstack with Pulumi in Python, and/or pulumi-local? I read this doc which got me pretty excited before I tried since it looked simple enough.: https://docs.localstack.cloud/integrations/pulumi/ However, when running the command
    pulumilocal up
    , I get this non explicit error:
    Do you want to perform this update? yes
    Updating (localstack)
    
    View Live: <https://app.pulumi.com/my-user/myproject-backend/localstack/updates/5>
    
         Type                       Name                             Status                  Info
         pulumi:pulumi:Stack        myproject-backend-localstack     **failed**              1 error; 2 warnings
     +   └─ aws:appsync:GraphQLApi  myproject-localstack-graphqlapi  **creating failed**     1 error 
    
    Diagnostics:
      aws:appsync:GraphQLApi (myproject-localstack-graphqlapi):
        error: 1 error occurred:
            * error creating AppSync GraphQL API: InternalFailure:
            status code: 501, request id: 2DNPS6TTA6YNSW2F783MVI1V6DJZEJ8GJ61G1F4F
    
    pulumi:pulumi:Stack (myproject-backend-localstack):
        warning: provider config warning: Use s3_use_path_style instead.
        warning: provider config warning: Use s3_use_path_style instead.
        error: update failed
    Notes: • The stack works well when
    pulumi up
    on non-local. • The stack consists of AWS resources, including a Appsync GraphQL API • Side question: what are those warnings?
    m
    • 2
    • 24
  • k

    kind-jelly-61624

    09/13/2022, 8:56 PM
    Does anyone have experience writing unit tests for Component Resources? I’m wondering if it’s possible to mock the call as it would come via the sdk
    l
    • 2
    • 3
  • f

    fresh-scientist-11672

    09/14/2022, 8:35 PM
    Hi, we have built an internal service using pulumi under the hood but we're using old python libs 😅. We are considering upgrade lib versions, does anyone have made it or know any breaking change? Currently we are using:
    $ pip freeze | grep pulumi
    pulumi==2.19.0
    pulumi-gcp==4.12.0
    s
    • 2
    • 2
  • q

    quaint-tailor-52411

    09/15/2022, 8:50 PM
    for ComponentResources, what does
    self.register_outputs()
    actually do? when I register some child resources there and then later try to access them as a property of component object i get
    object no attribute my_outputted_resource
    s
    • 2
    • 28
  • q

    quaint-tailor-52411

    09/15/2022, 8:51 PM
    i was expecting to be able to access all registered outputs as outputs like a standard resource
  • b

    bland-thailand-60821

    09/15/2022, 10:14 PM
    import pulumi
    import pulumi_equinix_metal as equinix_metal
    
    test = equinix_metal.Connection("test",
        organization_id=local["my_organization_id"],
        project_id=local["my_project_id"],
        metro="sv",
        redundancy="redundant",
        type="shared")
    __ERROR-----------------------
    Diagnostics:
      pulumi:pulumi:Stack (mosk-auto-test):
        error: Program failed with an unhandled exception:
        Traceback (most recent call last):
          File "./__main__.py", line 4, in <module>
            test = equinix_metal.Connection("test",
        AttributeError: module 'pulumi_equinix_metal' has no attribute 'Connection'
    s
    • 2
    • 14
  • l

    limited-continent-1382

    09/16/2022, 9:19 AM
    Hello there, We know we can export values programmatically by using
    pulumi.export("ip", "0.0.0.0")
    , but is there a way to get that exported value from that key using Python?
    m
    s
    • 3
    • 31
  • b

    breezy-knife-24305

    09/20/2022, 6:49 PM
    I'm trying to perform introspection of the AWS resources (
    pulumi_aws
    ) so that we can dynamically define configuration templates. I'm running into the following issue:
    Traceback (most recent call last):
      File "~/Documents/workspace/ops/pulumi/pulumi-config.py", line 17, in <module>
        import pulumi_aws as aws
      File "~/.virtualenvs/pulumi/lib/python3.9/site-packages/pulumi_aws/__init__.py", line 5, in <module>
        from . import _utilities
      File "~/.virtualenvs/pulumi/lib/python3.9/site-packages/pulumi_aws/_utilities.py", line 15, in <module>
        import pulumi.runtime
    ModuleNotFoundError: No module named 'pulumi.runtime'; 'pulumi' is not a package
    Any ideas on how I can get
    pulumi.runtime
    recognized?
    s
    • 2
    • 6
  • l

    limited-continent-1382

    09/21/2022, 10:04 AM
    Hi guys, I am going to use dynamic data masking feature in bigquery. In order to use dynamic masking feature we need to follow bellow steps. 1. Create a taxonomy of policy tags using data catalog - ( was able to automate using gcp pulumi provider) ✅ https://www.pulumi.com/registry/packages/gcp/api-docs/datacatalog/policytag/ 2. Attach data policies for created policy tags in above step - ( couldn't find a support functionality from pulumi) ❓ here I want to configure masking rules and principals. Is it possible to automate this as well using pulumi?
    s
    • 2
    • 10
  • f

    future-france-34957

    09/21/2022, 6:36 PM
    Hey all Have a Pulumi Output array of objects (route53 hosted_zones) that looks like this:
    ~ hosted_zones: [
          ~ [0]: {
                    arn              : "arn:aws:route53:::hostedzone/Z06813069DDF4BVP5B49"
                    comment          : "Hosted Zone for <http://env.example.com|env.example.com>"
                    force_destroy    : false
                    id               : "Z06813069DDF4BVP5B49"
                    name             : "<http://env.example.com|env.example.com>"
                    name_servers     : [
                        [0]: "<http://ns-1074.awsdns-09.org|ns-1074.awsdns-09.org>"
                        [1]: "<http://ns-1944.awsdns-52.co.uk|ns-1944.awsdns-52.co.uk>"
                        [2]: "<http://ns-475.awsdns-53.com|ns-475.awsdns-53.com>"
                        [3]: "<http://ns-948.awsdns-52.net|ns-948.awsdns-52.net>"
                    ]
                    tags_all         : {
                        provisioner: "pulumi"
                    }
                    urn              : "urn:pulumi:all::shared::aws:route53/zone:Zone::<http://env.example.com|env.example.com>"
                    zone_id          : "Z06813069DDF4BVP5B49"
                }
          ~ [1]: {
                    arn              : "arn:aws:route53:::hostedzone/Z05663573HLFBZ66YBFM2"
                    comment          : "Hosted Zone for env.example.link"
                    force_destroy    : false
                    id               : "Z05663573HLFBZ66YBFM2"
                    name             : "env.example.link"
                    name_servers     : [
                        [0]: "<http://ns-1311.awsdns-33.org|ns-1311.awsdns-33.org>"
                        [1]: "<http://ns-1733.awsdns-22.co.uk|ns-1733.awsdns-22.co.uk>"
                        [2]: "<http://ns-191.awsdns-21.com|ns-191.awsdns-21.com>"
                        [3]: "<http://ns-786.awsdns-36.net|ns-786.awsdns-36.net>"
                    ]
                    tags_all         : {
                        provisioner: "pulumi"
                    }
                    urn              : "urn:pulumi:all::shared::aws:route53/zone:Zone::env.example.link"
                    zone_id          : "Z05663573HLFBZ66YBFM2"
                }
        ]
    I want to get, for example, the
    zone_id
    where
    name
    =
    <http://env.example.com|env.example.com>
    My thought was to search the array for the index, for example, where
    name
    =
    <http://env.example.com|env.example.com>
    , in this case
    [0]
    and then get the the value of
    zone_id
    at that index (similar to this https://stackoverflow.com/a/19868472) However, since this is a Pulumi Output object, I can’t iterate it like that:
    TypeError: 'Output' object is not iterable, consider iterating the underlying value inside an 'apply'
    So I attempted to first convert the object to json, using a render function (which has worked for me when needing a Pulumi Output object as a string, like this https://stackoverflow.com/a/73558276/18101704) but that doesn’t work either:
    def get_shared_hosted_zones_to_string(shared_hosted_zones):
                return json.dumps(shared_hosted_zones)
    
            def get_zone_index(shared_hosted_zones_string, name):
                return next(index for index, element in enumerate(shared_hosted_zones_string)
                            if element["name"] == name)
    
            # For each domain, create Hosted Zone
            # i.e. (<http://uat.env.example.com|uat.env.example.com>, uat.env.example.link)
            for domain, name in domains.items():
                hosted_zone = route53.Zone(
                    resource_name=f"{env_stack}.{domain_prefix}.{name}",
                    name=f"{env_stack}.{domain_prefix}.{name}",
                    comment=f"Hosted Zone for {env_stack}.{domain_prefix}.{name}",
                    tags=TAGS,
                    opts=ResourceOptions(protect=True)
                )
    
                shared_hosted_zones_string = Output.all(shared_hosted_zones).apply(
                    lambda shared_hosted_zones: get_shared_hosted_zones_to_string(shared_hosted_zones))
    
                # select the hosted zone id where shared_hosted_zones.[].name == domain name
                # i.e. which object in the hosted_zones array has name : "<http://env.example.com|env.example.com>",
                #      because need to get that zone_id
                shared_hosted_zone = shared_hosted_zones_string[get_zone_index(
                    shared_hosted_zones_string, domain_prefix + name)]
    shared_hosted_zones_string
    is of type Output though. I don’t fully understand how this works here, but not in this case? Any ideas?
    b
    • 2
    • 5
  • s

    steep-lamp-20408

    09/21/2022, 11:32 PM
    Hi all, I have a Pulumi script
    __main__.py
    working fine, executed with
    pulumi up
    CLI command. In that script I need to use the Python
    toml
    module, so I installed it the project dependencies and venv. Now, when I do
    pulumi up
    , I get the error:
    import toml
    ModuleNotFoundError: No module named 'toml'
    (needless to say everything is done in a venv where I double checked that
    toml
    was actually installed, with
    pip list
    ). It would seem that it’s not supported by Pulumi to use third-party Python modules in a Pulumi script? Or did I miss something?
    b
    • 2
    • 10
  • a

    alert-monitor-28534

    09/22/2022, 6:23 AM
    Hi, I'm trying to create RKE cluster to instances in Oracle Cloud, but because the RKE provider is too old it doesn't work for ARM cluster I have. I'm trying to run RKE CLI manually, using Jinja2 templating to create the cluster configuration YAML - the problem is that I just cannot get the IP addresses of the instances to the YAML as I get this when trying to render the template:
    - address: 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.
    This is what I've tried to do:
    vm1_public_ip_str = vm1.public_ip.apply(lambda public_ip: f"{public_ip}")
    And this is how the cluster YAML should be generated:
    output = cluster_template.render(
        user="ubuntu",
        master_public_ip=vm1_public_ip_str,
        master_int_ip=vm1_private_ip_str,
        worker_public_ip=vm2_public_ip_str,
        worker_int_ip=vm2_private_ip_str,
        ssh_key_path=ssh_key_path,
    )
    What to try next? Thanks in advance for the help!
    s
    • 2
    • 3
  • s

    stocky-father-68249

    09/24/2022, 9:03 AM
    Hey guys. Is there a way how I can turn on canary deployments in ecs using pulumi python?
  • m

    mammoth-camera-90962

    09/27/2022, 11:54 PM
    Is there a way I can have logs (
    pulumi.error
    ,
    pulumi.warn
    etc) for a dynamic resource appear attached to the dynamic resource in the console output? Calling
    pulumi.error(msg, self)
    doesn't work.
  • b

    brash-restaurant-84207

    09/28/2022, 11:36 AM
    hi, I'm a complete pulumi noob. my initial goal is to create just a vpc using a specific aws profile from my aws credentials file. I have so far: - created a new directory - run 'pulumi new' , and chosen aws-python - taken the following code from the 'setting up a new vpc' part of the pulumi getting started section of their website: import pulumi import pulumi_awsx as awsx vpc = awsx.ec2.Vpc("custom") pulumi.export("vpcId", vpc.vpc_id) pulumi.export("publicSubnetIds", vpc.public_subnet_ids) pulumi.export("privateSubnetIds", vpc.private_subnet_ids) - replaced the default code in the '__main__.py' file with the above code - added the following line to Pulumi.<stackname>.yaml: aws😛rofile: dev-account When I try to run: 'pulumi up' I'm getting the error: ModuleNotFoundError: No module named 'pulumi_awsx' I then executed: 'pip install pulumi_awsx' This installed the module. When I tried to run 'pulumi up' again I experienced the same error What am I missing? (doing this on a windows machine btw)
    k
    • 2
    • 3
  • s

    steep-lamp-20408

    09/29/2022, 10:07 AM
    Hi there, I’m trying to do Python string interpolation within AWS policies JSON string defined in Pulumi object:
    import pulumi_aws as aws
    
    iam_role = aws.iam.Role(
            "my-role",
            name="my-role",
            assume_role_policy="""{
                    ...
                }
            """,
            inline_policies=[
                aws.iam.RoleInlinePolicyArgs(
                    name=f"my-policy-{stack_name}",
                    policy=f"""{
                                "Version": "2012-10-17",
                                "Statement": [
                                    {
                                        "Effect": "Allow",
                                        "Action": [
                                            "dynamodb:BatchGetItem",
                                            "dynamodb:GetItem",
                                            "dynamodb:Query",
                                            "dynamodb:Scan",
                                        ],
                                        "Resource": "arn:aws:dynamodb:ap-northeast-1:123456:table/myTablesPrefix-{stack_name}-*"
                                    }
                                ]
                            }
                        """
                ),
            ],
        )
    ...but I get the following error:
    SyntaxError: f-string: expressions nested too deeply
    However, it does not look like I’m trying to do nested string interpolation: I’m just doing string interpolation in a triple quoted string. Right? So maybe it’s Pulumi is doing some string interpolation on top of it? Any idea on how to solve that?
    s
    • 2
    • 2
  • q

    quick-wolf-8403

    09/29/2022, 6:03 PM
    Hi folks! I'm using poetry to manage the deps of my pulumi deployment script. When I use the Pulumi Github action, I have to install the deps via pip, though, and a generated
    requirements.txt
    file. A workflow like this runs: https://github.com/pulumi/actions/blob/master/examples/python-pulumi.yaml But I would like to do something like this:
    - id: "setup-python-pulumi"
            name: "Install Pulumi Python environment"
            uses: actions/setup-python@v3
            with:
              python-version: '3.10'
          
          - id: "get-deployment-deps"
            name: "Get deployment script deps"
            working-directory: iac
            run: |
              pipx install poetry
              poetry install
    
          - id: 'pulumi-deploy'
            name: 'Deploy from Pulumi IaC'
            uses: pulumi/actions@v3
            with:
              command: up
              stack-name: nocap/dev
              work-dir: iac
              refresh: true
    However, the Pulumi action fails, saying it can't import pulumi. It doesn't use the environment Poetry created. Is there a way to specify your environment to the action?
    ➕ 1
    k
    l
    • 3
    • 5
  • k

    kind-jelly-61624

    10/03/2022, 12:56 AM
    Does anyone have experience creating functions? I added the function to my schema.json but when I try to run it I get
    Unexpected <class 'NotImplementedError'>: Method not implemented!
    I’m trying to make a top level function that is not dependent on a resource
    e
    • 2
    • 11
  • k

    kind-jelly-61624

    10/03/2022, 6:10 PM
    Has anyone created IAM policies with pulumi - how did you substitute aws regions / resource arns within the policy document? I’m using python - do I need to make my own jinja magic or is there something built into pulumi that can handle this sort of thing? I see in the docs a reference to {{aws::username}} but that only works if I substitute the value myself. Something like the !Sub ${AWS::Region} function that cloudformation has
    s
    b
    p
    • 4
    • 20
  • b

    billions-journalist-44569

    10/04/2022, 1:39 PM
    Hi, is there a way to do a
    pulumi state delete <urn>
    programmatically in Python or via REST API?
  • s

    shy-bird-55689

    10/04/2022, 4:27 PM
    hey ya, i'm using crosswalk to generate a vpc, with a s3 gateway endpoint. Having issues accessing the prefix list ids to then pass in when creating a security group. Any ideas?
    g
    • 2
    • 2
  • c

    creamy-window-21036

    10/04/2022, 4:50 PM
    Hi everyone, I need help to understand to use resource which is like already present in aws.
    import pulumi
    import pulumi_aws as aws
    import pulumi_eks as eks
    
    role1 = aws.iam.Role("ways to retrieve it if it is already present in aws")
    role2 = aws.iam.Role("ways to retrieve it if it is already present in aws")
    
    cluster = eks.Cluster(...,instance_roles=[role1, role2],...)
    I tried to 1. aws.iam.Role.get() 2. aws.iam.getRole() 3. aws.iam.Role("some_role", opt=pulumi.ResourceOption(import_="some_role")) But nothing worked for me Thanks in advance 🙂
    b
    • 2
    • 5
  • h

    helpful-baker-38839

    10/04/2022, 9:32 PM
    Hello all. Is it possible to use Pulumi in a REPL like iPython? For example to do something like
    bucket = aws.s3.BucketV2.get("bucket", "bucket")
    so I can then look at the
    bucket
    object interactively?
    b
    g
    • 3
    • 5
  • s

    shy-bird-55689

    10/05/2022, 1:47 PM
    Pulumi up is throwing:
    error: could not validate provider configuration: 1 error occurred:
            * Invalid or unknown key
    Not sure what this is referring to, this project has been working ok on a dev stack. This is now trying to deploy into my prod stack (for the first time)
    s
    • 2
    • 7
  • f

    full-analyst-32960

    10/05/2022, 5:28 PM
    aws.iam.Policy("policy",
        description="Description",
        policy = json.dumps({ ... })
    )
    AWS shows this as a “Customer managed” “Permission policy” but the name is “policy-8964f2d”. Pulumi add the stuff after the dash? Is there a way to prevent that? Is the info random or does it represent something?
    s
    b
    • 3
    • 4
  • f

    full-analyst-32960

    10/06/2022, 1:28 AM
    brew upgrade pulumi throws an Error: invalid attribute for formula ‘pulumi/tap/pulumi’: version, I opened a bug report at brew, https://github.com/Homebrew/homebrew-core/issues/112439, but they said it’s a 3rd party tap and open a bug here.
    e
    • 2
    • 3
  • f

    full-analyst-32960

    10/06/2022, 1:35 AM
    If not the right channel or place, let me know, I’ll do the leg work to get the information into the correct spot.
  • r

    rhythmic-branch-12845

    10/06/2022, 3:10 PM
    you’re in #python
Powered by Linen
Title
r

rhythmic-branch-12845

10/06/2022, 3:10 PM
you’re in #python
View count: 1