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

    high-cartoon-83388

    07/09/2021, 10:44 AM
    Hello guys, when using the pulumi python sdk do you know if there is there any way to tell if the CLI was invoked with 
    pulumi up
     
    pulumi destroy
     or 
    pulumi preview
     ? Something like
    pulumi.runtime.command
    perhaps ?
    b
    • 2
    • 1
  • g

    great-sunset-355

    07/12/2021, 8:02 AM
    I'm learning about ComponentResources my code: https://gist.github.com/1oglop1/c563f25b317ecd6149e5465bd9eea597 And I'm trying to understand how
    register_outputs
    should work with secrets
    opts=ResourceOptions(additional_secret_outputs=['password'])
    The result of the code above is this for both the
    First
    and the
    Second
    component. I'm probably doing something wrong that the
    password
    is not marked as a secret value in resource outputs. here is the result of
    pulumi stack export
    {
        "version": 3,
            "resources": [
                {
                    "urn": "urn:pulumi:dev::tests::pulumi:pulumi:Stack::tests-dev",
                    "custom": false,
                    "type": "pulumi:pulumi:Stack"
                },
                {
                    "urn": "urn:pulumi:dev::tests::custom:first::first",
                    "custom": false,
                    "type": "custom:first",
                    "outputs": {
                        "password": "222222",
                        "w2": "222222"
                    },
                    "parent": "urn:pulumi:dev::tests::pulumi:pulumi:Stack::tests-dev",
                    "additionalSecretOutputs": [
                        "password"
                    ]
                },
                {
                    "urn": "urn:pulumi:dev::tests::custom:second::second",
                    "custom": false,
                    "type": "custom:second",
                    "outputs": {
                        "password": "Secret"
                    },
                    "parent": "urn:pulumi:dev::tests::pulumi:pulumi:Stack::tests-dev",
                    "additionalSecretOutputs": [
                        "password"
                    ]
                }
            ]
        }
    }
    b
    • 2
    • 6
  • a

    astonishing-dinner-89046

    07/12/2021, 3:47 PM
    I’m trying to incorporate a certificate validation workflow. I’m trying to use the example below but
    dvo.domainName
    as well as (name, record) parameters in the
    for range in
    loop doesn’t seem to be working. Any ideas?
    g
    • 2
    • 2
  • w

    witty-dentist-91954

    07/13/2021, 4:40 PM
    I'm setting up an gke nodeport service and want to add the new node_port to a firewall rule, so the default health check works. I'm trying to get the port like this:
    my_nodeport = my_svc.spec.apply(lambda p: p.ports[0]['node_port'])
    But this failes with an
    KeyError: 'node_port'
    in outputs.py. It works, if I first create the NodePort and create the firewall in a second run. I would like to avoid setting a fixed node_port in the service. Is there a way to do that?
    w
    • 2
    • 1
  • b

    broad-hairdresser-1495

    07/15/2021, 2:54 PM
    Hi,
    Do you want to perform this update?  [Use arrows to move, enter to select, type to filter]
      yes
    > no
      details
    Is there a Pulumi function that can retrieve user input when running
    pulumi up
    ?
    • 1
    • 1
  • a

    average-school-38756

    07/15/2021, 11:33 PM
    i'd like to create an
    aws.secretsmanager.Secret
    and a corresponding
    SecretVersion
    , but not have the value stored anywhere in state, not even encrypted - i just want Secrets Manager to keep track of the value. Is there a way to write this way?
    b
    • 2
    • 2
  • s

    shy-author-33795

    07/21/2021, 3:59 PM
    I'm following this example of post-provisioning with a dynamic provider here. I have copied the
    provisioners.py
    file without revision and I'm importing it in my
    __main__.py
    with
    import provisioners
    . I am using a dynamic provider to remote exec into a server with network access to an aurora cluster to run a MySQL command,
    show databases
    . However, my program errors:
    └─ pulumi-python:dynamic:Resource  show-dbs                                      1 error
    
    Diagnostics:
      pulumi-python:dynamic:Resource (show-dbs):
        error: Exception calling application: No module named 'provisioners'
    I'm not sure what i'm doing wrong to make this module unavailable.
    b
    r
    g
    • 4
    • 6
  • a

    aloof-jelly-80665

    07/21/2021, 8:36 PM
    Working with Google Artifact Registry, I am having trouble finding an example of initializing a google_beta provider in Python. All the examples I find reference a
    google_beta
    variable, but I can’t find an instantiation of it.
    g
    • 2
    • 4
  • g

    great-alligator-26951

    07/28/2021, 12:48 AM
    I am really having some trouble I was hoping someone would be able to help.  I am trying to feed a Pulumi Python Output to a configuration that expects a string.  For the life of me I cant seem to figure out how to get the output object to a string.  The string I need to feed is to another python module for configuring a SaaS application, but I can imagine I am going to have the same problem if I need to use a pulumi program inline with AWS boto3.  Can someone share a snippet?   This is the only way I have found that somewhat works.  Write to a file and then read it when I need to assign the variable which is horrible
    # define a function to write an arn to a file
    def write_to_file(arn):
        f = open("arn.txt", "a")
        f.write(arn)
        f.close()
    
    json = lb.arn.apply(lambda a: write_to_file(arn=a))
    r
    g
    • 3
    • 11
  • g

    great-sunset-355

    07/29/2021, 7:28 AM
    What's the best way to get a proper type hinting for Outputs? Is there any cast method or anything available? acm certificate has the output of type
    CertificateDomainValidationOptionArgs
    https://www.pulumi.com/docs/reference/pkg/aws/acm/certificate/#outputs I'd like to be able to use it as
    cert_validation_option.domain_name
    , etc...
    e
    • 2
    • 31
  • l

    little-journalist-4778

    08/09/2021, 11:26 AM
    Hi I'm creating a custom ComponentResource in python, and I'm not understanding if I'm supposed to declare my custom arg class like this:
    @pulumi.input_type
    class RoleMappingArgs:
        groups: pulumi.Input[Sequence[pulumi.Input[str]]] = pulumi.property("groups")
        role_arn: pulumi.Input[str] = pulumi.property("role_arn")
        username: pulumi.Input[str] = pulumi.property("username")
    Or is this something I should use only for cross language components? I can just declare nested args classes and the Outputs will be respected correctly?
    g
    b
    • 3
    • 25
  • s

    sparse-state-34229

    08/11/2021, 8:00 PM
    I have a colleague who is experiencing a weird issue with their local Pulumi dev env. when they run
    pulumi up
    on a stack that references other stacks, the stack reference is empty. in this case, it’s a reference to an AWS region. additionally, when they run
    pulumi config
    the output is empty, where as when I run it on the same stack I do see the expected config output
    b
    o
    • 3
    • 10
  • w

    worried-queen-62794

    08/12/2021, 10:20 PM
    Any idea how to diagnose this further:
    Diagnostics:
      pulumi:pulumi:Stack (tlayen-prod):
        error: missing executor /Users/jason/go/bin/pulumi-language-python-exec
    
    error: failed to load language plugin python: could not read plugin [/Users/jason/go/bin/pulumi-language-python] stdout: EOF
    It is the same error as https://github.com/pulumi/pulumi/issues/1956 but I don’t get how to fix it. It was working fine until I upgraded pulumi via brew.
    • 1
    • 2
  • c

    cool-belgium-78445

    08/16/2021, 2:57 PM
    Hi there! I am using Pulumi to create some custom infrastructure and am having trouble accessing the outputs of my resources. On the docs (https://www.pulumi.com/docs/intro/concepts/resources/#dynamic-resource-outputs) it says that what I am doing should be correct, but there is also little mention of how to actually access the outputs, so I could be wrong. This is what my resource and provider look like; am I doing anything wrong?
    class AccountProvider(ResourceProvider):
        def __init__(self, props):
            self.parent_client = Client(props["sid"], props["auth_token"])
        def create(self, props):
            subaccount = self.parent_client.api.accounts.create(friendly_name="{}-{}".format(props["name"], stack))
            return CreateResult(id_=subaccount.sid, outs={'sid':subaccount.sid, 'auth_token':subaccount.auth_token})
        def delete(self, id, props):
            self.parent_client.api.accounts(id).update(status="closed")
    
    class Account(Resource):
        sid: Output[str]
        auth_token: Output[str]
        def __init__(self, name: str, props,  opts: Optional[ResourceOptions] = None):
            super().__init__(AccountProvider(props), name, {"name":name, 'sid':None, 'auth_token':None}, opts)
    
    new_account = Account("new_account1", props=AccountCredentials(sid=account_sid, auth_token=auth_token))
    g
    • 2
    • 3
  • a

    adamant-france-50503

    08/17/2021, 10:16 PM
    does anyone know how to properly setup IntelliSense/autocomplete/code hint for pulumi python on VS Code? the built in Python Intellisense isn't giving me any code suggestion specific on pulumi or pulumi_aws
    g
    g
    • 3
    • 5
  • g

    gorgeous-minister-41131

    08/19/2021, 8:56 PM
    Had a quick Q about auto-casing/argument passing into resource constructors. I notice many of Pulumi's args are auto-snake-cased as a dict of args that can be passed into a constructor, for example,
    ProbeArgs(
                        http_get=HTTPGetActionArgs(
                            path="/healthz",
                            port=DEFAULT_SERVICE_PORTS_SPEC["http"]["port"],
                            scheme="HTTP",
                        ),
                        failure_threshold=2,
                        initial_delay_seconds=60,
                        period_seconds=30,
                        success_threshold=1,
                        timeout_seconds=5,
                    ),
    is it acceptable practice to skip using the verbose class & arg and go straight to constructing things like this?
    liveness_probe={"http_get": {"path": "/healthz", "port": DEFAULT_SERVICE_PORTS_SPEC["http"]["port"], "scheme": "http"}, "failure_threshold": 2, "initial_delay_sections": 60, "period_seconds": 30, "success_threshold": 1, "timeout_seconds": 5}
  • g

    gorgeous-minister-41131

    08/19/2021, 8:57 PM
    the reason I'm asking is, from a javascripter/typescripter perspective, the second is much more "obvious" what is going on, at least with respect to kubernetes, since the object structure appears to match the meta schema structure of a kubernetes' JSON/YAML API [I forgot the technical term for this]
  • g

    gorgeous-minister-41131

    08/19/2021, 8:58 PM
    it's just that python prefers "snake case" so all of the fields of objects in the k8s API struct are 'translated' anyway...
  • g

    gorgeous-minister-41131

    08/19/2021, 8:59 PM
    Plus, and maybe this is actually by design, it lets a more common system "generate" the various Args for different things, irrespective of the underlying language dialect chosen for a particular set of resources managed with pulumi. E.g. mix and matching typescript, golang, python etc, and using a common return map for generating :allthethings:
    g
    f
    • 3
    • 4
  • f

    freezing-van-87649

    08/20/2021, 12:14 PM
    FYI latest pulumi release includes this which allows you to customize the type names for dynamic resources
    f
    • 2
    • 2
  • a

    adorable-noon-15528

    08/23/2021, 2:02 PM
    I'm creating multiple instances (via for loop) of a ManagedNodeGroup. Is there some way of parallelizing it? Current behaviour is linear (expected) but takes long to deploy many of them.
    c
    g
    • 3
    • 3
  • b

    best-nest-62071

    08/24/2021, 6:43 PM
    Has anyone here been able to create an ec2 instance resource using the aws.ec2 module and increase the drive using the root_block_device variable? Im getting the following error:
    AssertionError: Unexpected type. Expected 'list' got '<class 'pulumi_aws.ec2._inputs.InstanceRootBlockDeviceArgs'>'
        error: an unhandled error occurred: Program exited with non-zero exit code: 1
    In pulumi I cant figure out how to convert the class to a list, Or even if I should be doing that. Im sure there's a pulumi way of doing this. Please point me in the right direction. Code:
    for i in range(5):
        server = aws.ec2.Instance(f"webserver-{i:03}",
            ami=ami.id,
            iam_instance_profile='ec2_role',
            instance_type=size,
            key_name=sshKey,
            root_block_device=[aws.ec2.InstanceRootBlockDeviceArgs(
                device_name='/dev/sda1',
                volume_size=100,
                volume_type='gp3',
                )],
            subnet_id=['subnet-xxxxxxxxxxxxxxxx'],
            tags={
                "Name": f"webserver-{i:03}",
                "Purpose": "webapp"
            },
            volume_tags={
                "Name": f"webserver-{i:03}",
                "Purpose": "webapp"
            },
            vpc_security_group_ids=[ secgrp.id ]
    
        )
    https://www.pulumi.com/docs/reference/pkg/aws/ec2/instance/#instancerootblockdevice
    a
    • 2
    • 2
  • g

    glamorous-cpu-85849

    08/25/2021, 10:01 AM
    Is there a away to make Pulumi wait for an ECS deploy to fully complete after updating a container+task definition instead of just saying its successful right away after the task definition is updated?
    b
    b
    • 3
    • 2
  • a

    alert-mechanic-59024

    08/29/2021, 11:50 AM
    Hey guys! Any chance of being able to debug ‘pulumi up’ of python runtime stack in vscode?
    g
    • 2
    • 2
  • a

    alert-lock-34522

    08/30/2021, 4:58 PM
    Morning, I am having an issue with the vpc_endpoint module of pulumi. How can I add multiple subnets to the endpoint. When I tired with the assocaition module it just overrode the existing subnet instead of adding another one?
    🦗 1
    b
    • 2
    • 2
  • b

    breezy-piano-61073

    08/31/2021, 9:22 PM
    Hello Pulumi/python people! Trying to create an AlertCondition using some of the example code on this page There is some code in the Example Usage section, under the python tab that contains the following:
    import pulumi
    import pulumi_newrelic as newrelic
    
    foo_monitor = newrelic.synthetics.get_monitor(name="foo")
    foo_alert_condition = newrelic.synthetics.AlertCondition("fooAlertCondition",
        policy_id=newrelic_alert_policy["foo"]["id"],
        monitor_id=foo_monitor.id,
        runbook_url="<https://www.example.com>")
    I was wondering what “newrelic_alert_policy” is. A function, variable? It isn’t defined in the example. All I’m trying to do is create a simple alert for some simple synthetic monitors I’ve put together.
  • e

    enough-butcher-66045

    09/01/2021, 6:22 AM
    hi peeps! I'm trying to create a web app, and then use listWebAppPublishingCredentials to get the scm_uri value, much like this person is trying to do here: https://stackoverflow.com/questions/64557665/pulumi-add-azure-web-app-service-web-hook-to-azure-container-registry-for-conti The proposed solution makes sense (it's JS):
    const webhook = pulumi.all([resourceGroup.name, webApp.name])
        .apply(([resourceGroupName, name]) => 
            web.listWebAppPublishingCredentials({ resourceGroupName, name }))
        .apply(creds => creds.scmUri + "/docker/hook");
    But when trying to run the same in python, it's basically saying "The web app resource was not found", which makes sense... because I'm trying to create it right before. What would be the right way to solve this? One option is to create a different stack and have them run one after the other but that's something I'd really, really like to avoid.
  • e

    enough-butcher-66045

    09/02/2021, 6:05 AM
    so, after hitting my head against the wall a couple of times: The name is deterministically generated by pulumi (i.e. doesn't need the resource to exist to get a name), it doesn't know to wait to fetch the web app publishing credentials, the trick is to include the
    webApp.id
    in the output interpolation like
    pulumi.all([resourceGroup.name, webApp.name, webApp.id])
    even if it's not used, so it's forced to wait
    🙌 2
  • c

    crooked-pillow-11944

    09/13/2021, 1:33 AM
    I'm trying to handle output in the form of a list/dict:
    + subnets: [
    +     [0]: "10.2.0.0/22"
    +     [1]: "10.4.0.0/22"
    +     [2]: "10.6.0.0/22"
    +     [3]: "10.8.0.0/22"
    +     [4]: "10.10.0.0/22"
    +     [5]: "10.12.0.0/22"
    +     [6]: "10.14.0.0/22"
    ]
    I can set a value by using the index (i.e.
    ['subnets'][0]
    ) I want to iterate over the subnets to create them but I can't use a for loop because
    'Output' object is not iterable
    How can I use these values in the output?
    b
    • 2
    • 6
  • c

    crooked-pillow-11944

    09/13/2021, 2:59 PM
    Does somebody have an example of using
    Output.all
    with a list? The documentation says that you would use it's
    Output
    with an
    .apply
    but I'm uncertain of a practical application for this
    f
    • 2
    • 2
Powered by Linen
Title
c

crooked-pillow-11944

09/13/2021, 2:59 PM
Does somebody have an example of using
Output.all
with a list? The documentation says that you would use it's
Output
with an
.apply
but I'm uncertain of a practical application for this
f

full-artist-27215

09/13/2021, 3:06 PM
From our codebase:
policy=pulumi.Output.all(*[t.arn for t in tables]).apply(
            lambda arns: json.dumps(
                {
                    "Version": "2012-10-17",
                    "Statement": [
                        {
                            "Effect": "Allow",
                            "Action": [
                                # Read
                                "dynamodb:BatchGetItem",
                                "dynamodb:GetRecords",
                                "dynamodb:GetShardIterator",
                                "dynamodb:Query",
                                "dynamodb:GetItem",
                                "dynamodb:Scan",
                                # Write
                                "dynamodb:BatchWriteItem",
                                "dynamodb:PutItem",
                                "dynamodb:UpdateItem",
                                "dynamodb:DeleteItem",
                            ],
                            "Resource": [a for a in arns],
                        }
                    ],
                }
            )
        ),
Though I suspect that final
[a for a in arns]
is a holdover from a prior refactoring... could probably just be
arns
at this point 😅
View count: 2