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

    clever-painter-96148

    10/09/2022, 8:20 PM
    I wrote a lot of Pulumi code in TypeScript and got used to its extensive type definition, which is very convenient when working with VSCode. I recently started a Python-based Pulumi project. I am surprised that it looks like typing support is inferior in Python. Am I wrong? Am I missing something?
    e
    f
    g
    • 4
    • 41
  • s

    stocky-father-68249

    10/12/2022, 10:38 AM
    Hey guys, is there a way to create multiple (3-4) databases in an rds postgres instance using pulumi python?
    • 1
    • 1
  • l

    limited-rainbow-51650

    10/13/2022, 6:58 PM
    For people struggling with a monorepo containing Pulumi code in Python, with Poetry as the dependency manager, I have good news: here is a working setup! https://github.com/ringods/pulumi-python-poetry-monorepo
    g
    • 2
    • 3
  • b

    broad-noon-76535

    10/14/2022, 3:20 PM
    I can't seem to figure out how to read these config values starting with "azure*":
    config:
      azure-native:location: northeu
      azure:subscriptionId: 1234-abcd
      my-project:context:
        some-key: some-value
    I am only able to fetch the config values under "my-project", for some reason. Can anyone enlighten me? 🕯️
    m
    • 2
    • 2
  • b

    broad-noon-76535

    10/17/2022, 8:21 AM
    Hi - I am building a dynamic provider in Python and would like to write unit tests for it. Can anyone provide an example of how this can be done? The async nature of the Pulumi API makes it a bit tricky, so it's likely I need to look into how to properly use asyncio and pytest together. But if you have any suggestions on what and how to mock, that would be appreciated.
  • p

    polite-ocean-13631

    10/19/2022, 4:42 PM
    Has anyone been able to run
    pulumi_aws.iam.get_policy_document
    under Pytest? It works when running normally with Pulumi, but when run under Pytest with a test decorated by
    pulumi.runtime.test
    it fails with the error in the thread.
    • 1
    • 2
  • g

    gorgeous-minister-41131

    10/19/2022, 11:29 PM
    'Ello all, back to using Pulumi here and ran into this weirdness when trying to update my Pipenv/lock/virtualenv. Did something change with the
    pulumi
    python package behavior where it goes off and tries to install a provider automatically?
    [pipenv.exceptions.InstallError]:           check_call(['pulumi', 'plugin', 'install', 'resource', 'aws', PLUGIN_VERSION])
    [pipenv.exceptions.InstallError]:         File "/opt/homebrew/Cellar/python@3.9/3.9.15/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 373, in check_call
    [pipenv.exceptions.InstallError]:           raise CalledProcessError(retcode, cmd)
    [pipenv.exceptions.InstallError]:       subprocess.CalledProcessError: Command '['pulumi', 'plugin', 'install', 'resource', 'aws', '5.16.0']' returned non-zero exit status 126.
    [pipenv.exceptions.InstallError]:       [end of output]
    [pipenv.exceptions.InstallError]:
    [pipenv.exceptions.InstallError]:   note: This error originates from a subprocess, and is likely not a problem with pip.
    [pipenv.exceptions.InstallError]: error: legacy-install-failure
    [pipenv.exceptions.InstallError]:
    [pipenv.exceptions.InstallError]: × Encountered error while trying to install package.
    [pipenv.exceptions.InstallError]: ╰─> pulumi-aws
    • 1
    • 1
  • g

    gorgeous-minister-41131

    10/20/2022, 12:34 AM
    @billowy-army-68599 random, hopefully it doesn't derail the topic from general, but is related, does pulumi automatically activate the venv when using the options->virtualenv directive in Pulumi.yaml? We use Pipfile and a lock, so I have to pre-activate it with
    pipenv shell
    before running Pulumi.
    b
    • 2
    • 3
  • f

    full-analyst-32960

    10/20/2022, 7:51 PM
    I am looking for examples for create an Elastic Beanstalk environment and attaching an ALB. The default via web UI and cli creates and attached a classic load balancer. I am looking to how to attach the ALB to my Beanstalk environment. Thanks.
  • l

    lemon-intern-77136

    10/20/2022, 10:51 PM
    Anyone have any ideas how to debug a duplicate resource URN? I keep getting the error, but I have no idea why… the provider is only created once.
    f
    b
    • 3
    • 4
  • l

    lemon-intern-77136

    10/21/2022, 7:51 PM
    I’m trying to create a YAML file that is made of regular python and Output objects. I’m currently doing it like this:
    d = {}
    d['user'] = ['default'] + [aDictWithAnOutputInstance] + [anotherDictWithOutputInstances]
    d['other_stuff'] = ...
    d['more_things'] = {'more_things_1': againAnOutputInstance, 'more_things_2': 'regular string'}
    y = yaml.dump(d, Dumper=yaml.Dumper)
    Any ideas how to make this work? The
    .apply
    and
    .concat
    idioms don’t seem to work here…
    b
    • 2
    • 13
  • f

    full-analyst-32960

    10/24/2022, 5:27 PM
    I see reference to
    DockerBuild
    at https://www.pulumi.com/registry/packages/docker/api-docs/image/ but I cannot find the documentation for the API online, I do see it in
    site-packages/pulumi_docker/docker.py
    where can I find the online docs?
  • f

    full-analyst-32960

    10/24/2022, 5:38 PM
    The Input details are missing at https://www.pulumi.com/registry/packages/docker/api-docs/image/#image_name_python
    r
    • 2
    • 2
  • n

    nutritious-battery-42762

    10/29/2022, 12:09 PM
    Hi, I see the use register-outputs in examples but I can't recall seeing how to read said outputs. Examples I see always access the property on the class instance. So how should it be used?
    b
    • 2
    • 1
  • c

    curved-kitchen-23422

    10/29/2022, 3:41 PM
    Hi team, We have deployed elastic search in AWS using pulumi(python). Later we have upgraded with OpenSearch 1.3 engine version and working fine. We are trying to migrate data node EBS volume from gp2 to gp3. But got the error like below
    error: Domain resource has a problem: expected ebs_ options
    .
    0.volume _type to be one of [stamdard gp2 io1], got gp3. Examine
    values at
    ‘`Domain`.
    EbsOptions
    .`VolumeType`’. Based on AWS docs, r6g.large.search instance type is support to gp3 volume and using console we can able to view the gp3 option, but using pulumi got the error. Can any one help to resolve this issue and thanks for advance.
    b
    • 2
    • 4
  • f

    full-analyst-32960

    10/31/2022, 2:38 PM
    Could I get an assist in how to specify TaskDefinitionLogConfigurationArgs log_drive=“awslog” options?
    fargate_task = awsx.ecs.FargateTaskDefinition("portal-fargate-task",
        containers={
            "nginx": awsx.ecs.TaskDefinitionContainerDefinitionArgs(
                image="nginx",
                essential=True,
                memory=128,
                log_configuration=awsx.ecs.TaskDefinitionLogConfigurationArgs(
                    log_driver="awslogs",
                    options=[
                        "awslogs_group:nginx-container",
                        "awslogs_region:us-west-1",
                        "awslogs_stream-prefix:nginx",
                    ],
                ),
            ),
        },
        tags={
            "Testing": "Testing",
        },
    )
  • f

    full-analyst-32960

    10/31/2022, 2:40 PM
    _inputs.py:TaskDefinitionLogConfigurationArgs says
    options: Optional[Any] = None
    and I don’t know how to fill in a list of [Any] to keep “pulumi up” happy
  • f

    full-analyst-32960

    10/31/2022, 2:42 PM
    Error
    cannot unmarshal array into Go struct field LogConfiguration.LogConfiguration.Options of type map[string]*string
    would hint that the options is a dict() (aka map) but I cannot get that to work either
    b
    • 2
    • 1
  • o

    orange-airport-64592

    11/01/2022, 1:58 AM
    How to fix this waring ,
    Argument of type "dict[str, str | int]" cannot be assigned to parameter "variables" of type "Input[Mapping[str, Input[str]]] | None" in function "__init__"
      Type "dict[str, str | int]" cannot be assigned to type "Input[Mapping[str, Input[str]]] | None"
        "dict[str, str | int]" is incompatible with "Mapping[str, Input[str]]"
          TypeVar "_VT_co@Mapping" is covariant
            Type "str | int" cannot be assigned to type "Input[str]"
              Type "int" cannot be assigned to type "Input[str]"
        "dict[str, str | int]" is incompatible with protocol "Awaitable[Mapping[str, Input[str]]]"
          "__await__" is not present
        "dict[str, str | int]" is incompatible with "Output[Mapping[str, Input[str]]]"
      ...PylancereportGeneralTypeIssues
    This is my code :
    
    
    aws.lambda_.FunctionEnvironmentArgs(
                variables={
                    "DESTN_BUCKET": s3_zip_log_bucket_name,
                    "RDS_HOSTNAME": "<http://xxxx.ap-east-1.rds.amazonaws.com|xxxx.ap-east-1.rds.amazonaws.com>",
                    "RDS_USERNAME": "admin",
                    "RDS_PASSWORD": db_password,
                    "RDS_PORT": "3306",
                    "TTL": 172800,
                },
            ),
    
    I think is need to do that to make dict convert to Input, But I don't know to do
    m
    f
    • 3
    • 12
  • o

    orange-airport-64592

    11/01/2022, 2:00 AM
  • f

    full-analyst-32960

    11/02/2022, 7:20 PM
    https://www.pulumi.com/docs/guides/testing/unit/, “Write the Tests” section test_ec2.py has
    import infra
    is the infra this project, https://pypi.org/project/infra/? Or is that typo(?) for the testinfra package, https://testinfra.readthedocs.io/en/latest/ ?
    e
    • 2
    • 2
  • f

    full-analyst-32960

    11/03/2022, 1:23 AM
    Following the unit testing at https://www.pulumi.com/docs/guides/testing/unit/ and I am failing to understand how to Mock simple API calls. My IaC has
    region = aws.get_region()
    as one of the first API calls.
    class PulumiMocks(pulumi.runtime.Mocks):
        def new_resource(self, args: pulumi.runtime.MockResourceArgs):
            print("new_resource")
            return [args.name + '_id', args.inputs]
    
        def call(self, args: pulumi.runtime.MockCallArgs):
            print(f"XXXXX call:")
            return {}
    Narrowed down
    aws.get_region()
    invokes the Mocks
    call(self, args: pulumi.runtime.MockCallArgs):
    how do I extract that I am calling get_region() and return my Mock values? Maybe I’m missing something? I thought I would be able to add
    get_region()
    method to the PulumiMocks() class? Any help would be appreciated.
    e
    • 2
    • 1
  • a

    agreeable-businessperson-73427

    11/03/2022, 11:40 PM
    Hello Team, I have a simple question. I am trying to set a random generated password on a newly created aws secrets manager object using pulumi. The API allows me to set the name of the object but I do not see a way to set the password on it. I have tried looking through the sources in Pulumi but have not encountered a way to set the password using API. any help appreciated https://www.pulumi.com/registry/packages/aws/api-docs/secretsmanager/secret/
    b
    • 2
    • 1
  • a

    agreeable-businessperson-73427

    11/04/2022, 1:52 PM
    I have a follow up for the above question. I am able to save a secret on AWS , I am trying to retrieve the newly saved secret using pulumi's get_secret() function. Now the function expects either arn or name in string and I am not able to convert to the arn to string , here is my code
    pwd = aws.secretsmanager.get_secret(arn=secret_obj.arn.apply(lambda arn: arn))
    saw online that Output<T> would need to be converted using .apply() which is what I am trying to do with a lambda that returns the arn but that doesnt seem to be doing it
    b
    • 2
    • 3
  • a

    agreeable-businessperson-73427

    11/04/2022, 9:55 PM
    is there a way to enforce order in pulumi execution ? like I want to provision a set of base resources before provisioning databases and want to enforce an order instead of asynchronous execution , is there a way for that ?
    b
    • 2
    • 9
  • a

    agreeable-businessperson-73427

    11/05/2022, 7:51 PM
    Is there a way to check if a resource exists before proceeding with a code snippet ? like say for example if I've ran a script that creates a 3 tier arch, 1 DB and a secrets manager, I now have to add a change and run the script , if the resource exists then I want to omit updating the secrets obj as that contains current DB password
    b
    • 2
    • 1
  • a

    agreeable-businessperson-73427

    11/05/2022, 7:55 PM
  • a

    agreeable-businessperson-73427

    11/05/2022, 7:55 PM
    is there a pythonic way for doing that ?
    f
    g
    • 3
    • 4
  • t

    thankful-stone-34269

    11/10/2022, 12:11 AM
    I'm confused how to create an IAM role for an ec2 machine and then use it. The error message is super confusing. First I create an IAM role:
    machine_role = aws.iam.Role("dockerbuilder-role", ...)
    and then I try to create an EC2 instance that uses this role:
    server = aws.ec2.Instance('dockerbuilder-pulumi',
        iam_instance_profile=machine_role,
    ...)
    The error message (which annoyingly takes 2 minutes to resolve annoyingly) is
    InvalidParameterValue: Value (dockerbuilder-role-908245c) for parameter iamInstanceProfile.name is invalid. Invalid IAM Instance Profile name
    . Now if I instantiate the Instance with `
    iam_instance_profile="dockerbuilder-role-908245c",
    it works. How do I get the name out of the role object to pass into the instance?
    • 1
    • 2
  • c

    careful-apartment-69053

    11/14/2022, 3:25 PM
    hey folks! I am struggling to get my first Pulumi POC off the ground. I have tried on a brand new windows machine and my developer machine and I get stuck at what seems to be the same step when launching the project. Our company is a msft house, using another OS is not an option:
    Building wheel for pulumi-azure-native (setup.py): started
      Building wheel for pulumi-azure-native (setup.py): finished with status 'error'
    the above is where i get stuck. the program literally does not return from this:
    pulumi new azure-python
    being new here, I don't even know where to go to find logs or anything to help. Its unfortunately making me consider bypassing pulumi as an option for our future IaC since I can't even put together the first step of the POC for my developers.
    b
    b
    e
    • 4
    • 21
Powered by Linen
Title
c

careful-apartment-69053

11/14/2022, 3:25 PM
hey folks! I am struggling to get my first Pulumi POC off the ground. I have tried on a brand new windows machine and my developer machine and I get stuck at what seems to be the same step when launching the project. Our company is a msft house, using another OS is not an option:
Building wheel for pulumi-azure-native (setup.py): started
  Building wheel for pulumi-azure-native (setup.py): finished with status 'error'
the above is where i get stuck. the program literally does not return from this:
pulumi new azure-python
being new here, I don't even know where to go to find logs or anything to help. Its unfortunately making me consider bypassing pulumi as an option for our future IaC since I can't even put together the first step of the POC for my developers.
b

billowy-army-68599

11/14/2022, 4:01 PM
can you try this again after running
pip install wheel
it looks like because you don’t have the
wheel
package installed locally, the package isn’t able to build
c

careful-apartment-69053

11/14/2022, 4:38 PM
thanks Ill give this a try. as far as documentation goes this is the third package having to be installed ( msft visual c++, grpcio , wheel ) and there is no mention anywhere in the getting started guides.
b

billowy-army-68599

11/14/2022, 4:44 PM
that’s totally fair feedback. Could you file an issue in github.com/pulumi/docs ?
c

careful-apartment-69053

11/14/2022, 4:46 PM
will do. Seems I might still be having issues with grpcio even though I installed it using pip: could this be a versioning issue or something?
id send more but I have thousands of lines of errors
i am able to install version 1.50 no issue. this version just wont install.
b

billowy-army-68599

11/14/2022, 4:55 PM
which version of grpcio is it trying to install?
c

careful-apartment-69053

11/14/2022, 4:56 PM
what i have installeD vs. it wants 1.47
very odd that this is failing on my personal laptop and a brand new windows 11 vm in azure. same issue on both.
b

billowy-army-68599

11/14/2022, 4:57 PM
what’s the first line of the error message?
c

careful-apartment-69053

11/14/2022, 4:58 PM
note: This error originates from a subprocess, and is likely not a problem with pip.
  Rolling back uninstall of grpcio
  Moving to c:\python311\lib\site-packages\grpc\
   from C:\Python311\Lib\site-packages\~rpc
  Moving to c:\python311\lib\site-packages\grpcio-1.50.0.dist-info\
   from C:\Python311\Lib\site-packages\~rpcio-1.50.0.dist-info
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> grpcio

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -D_WIN32_WINNT=1536 -DGRPC_XDS_USER_AGENT_NAME_SUFFIX=\"\\\"Python\\\"\" -DGRPC_XDS_USER_AGENT_VERSION_SUFFIX=\"\\\"1.47.0\\\"\" -DOPENSSL_NO_ASM=1 -DGPR_BACKWARDS_COMPATIBILITY_MODE=1 -DWIN32_LEAN_AND_MEAN=1 -DCARES_STATICLIB=1 -DGRPC_ARES=0 -DNTDDI_VERSION=100663296 -DNOMINMAX=1 -DMS_WIN64=1 -Isrc\python\grpcio -Iinclude -I. -Ithird_party\abseil-cpp -Ithird_party\address_sorting\include -Ithird_party\cares\cares\include -Ithird_party\cares -Ithird_party\cares\cares -Ithird_party\re2 -Ithird_party\boringssl-with-bazel\src\include -Ithird_party\upb -Isrc\core\ext\upb-generated -Isrc\core\ext\upbdefs-generated -Ithird_party\xxhash -Ithird_party\zlib -IC:\Python311\include -IC:\Python311\Include "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt" /EHsc /Tpsrc/core/ext/filters/census/grpc_context.cc /Fopython_build\temp.win-amd64-cpython-311\Release\src/core/ext/filters/census/grpc_context.obj -std=c++14 /MT
      cl : Command line warning D9025 : overriding '/MD' with '/MT'
      cl : Command line warning D9002 : ignoring unknown option '-std=c++14'
      <http://grpc_context.cc|grpc_context.cc>
b

billowy-army-68599

11/14/2022, 4:58 PM
and which version of python are you using?
c

careful-apartment-69053

11/14/2022, 5:02 PM
chughes 12:02:14> python --version Python 3.11.0
going to look into updating visualstudio buiild tools seems its a 2017 version right now
b

billowy-army-68599

11/14/2022, 5:03 PM
can you try downgrading python to
3.10.x
? maybe with
pyenv
?
@careful-apartment-69053 fot confirmation from the team that python 3.11 is affected by this, sorry this wasn’t documented well https://github.com/pulumi/pulumi/pull/11238 if you downgrade to python
3.10.x
it should work
c

careful-apartment-69053

11/14/2022, 5:08 PM
ok thank you!
this all works. still one error in a file copy but its not impacting usability. thanks for the help @billowy-army-68599
b

bored-airline-35946

11/16/2022, 6:49 PM
Just found this thread, was struggling with same issue. Will try a Python downgrade as well.
e

eager-wire-36257

12/18/2022, 7:30 PM
Thanks so much for this thread! I'm running into the exact same issue on macOS Catalina 10.15.7 and Python 3.11. I'll also try downgrading to Python 3.10.
View count: 1