Search code examples
pythonpulumi-python

Pulumi error: key: massage(attr[key], seen) for key in attr if not key.startswith("_")


I'm trying to build a simple bucket with intelligent tiering configuration, but I'm getting an error from pulumi code. The code message isn't intuitive and it seems to be a bug on the project or some config that I'm missing. Here follows my code:

import pulumi
from pulumi_aws import s3

# logging bucket

logging = s3.Bucket("my-bucket-name", bucket="my-bucket-name", tags={"Owner": "me"})
logging_intelligent_tiering = s3.BucketIntelligentTieringConfiguration(
    "my-bucket-name" + "-intelligent-tiering",
    bucket=logging.id,
    tierings=[
        s3.BucketIntelligentTieringConfigurationTieringArgs(
            access_tier="ARCHIVE_ACCESS", days=90
        ),
        s3.BucketIntelligentTieringConfigurationTieringArgs(
            access_tier="DEEP_ARCHIVE_ACCESS", days=180
        ),
    ],
)

pulumi.export(logging.id, logging)
pulumi.export(logging_intelligent_tiering.id, logging_intelligent_tiering)

Then the error I'm getting (If needed I have the full log):

    error: Program failed with an unhandled exception:
    Traceback (most recent call last):
      File "C:\Program Files (x86)\Pulumi\pulumi-language-python-exec", line 197, in <module>
        loop.run_until_complete(coro)
      File "C:\Users\guilherme.francis\.pyenv\pyenv-win\versions\3.11.6\Lib\asyncio\base_events.py", line 653, in run_until_complete    
        return future.result()
               ^^^^^^^^^^^^^^^
      File "C:\Users\guilherme.francis\Github\cda_iac\.venv\Lib\site-packages\pulumi\runtime\stack.py", line 137, in run_in_stack       
        await run_pulumi_func(lambda: Stack(func))
      File "C:\Users\guilherme.francis\Github\cda_iac\.venv\Lib\site-packages\pulumi\runtime\stack.py", line 49, in run_pulumi_func     
        func()
      File "C:\Users\guilherme.francis\Github\cda_iac\.venv\Lib\site-packages\pulumi\runtime\stack.py", line 137, in <lambda>
        await run_pulumi_func(lambda: Stack(func))
                                      ^^^^^^^^^^^
      File "C:\Users\guilherme.francis\Github\cda_iac\.venv\Lib\site-packages\pulumi\runtime\stack.py", line 162, in __init__
        self.register_outputs(massage(self.outputs, []))
                              ^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Users\guilherme.francis\Github\cda_iac\.venv\Lib\site-packages\pulumi\runtime\stack.py", line 206, in massage
        return massage_complex(attr, seen)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Users\guilherme.francis\Github\cda_iac\.venv\Lib\site-packages\pulumi\runtime\stack.py", line 241, in massage_complex    
        return {
               ^
      File "C:\Users\guilherme.francis\Github\cda_iac\.venv\Lib\site-packages\pulumi\runtime\stack.py", line 242, in <dictcomp>
        key: massage(attr[key], seen) for key in attr if not key.startswith("_")
                                                             ^^^^^^^^^^^^^^^^^^^
    TypeError: 'Output' object is not callable

Any suggestion on why is this happening?


Solution

  • The problem was in the params I used to export the resources. Instead of:

    pulumi.export(logging.id, logging)
    pulumi.export(logging_intelligent_tiering.id, logging_intelligent_tiering)
    

    The correct is:

    pulumi.export("logging-bucket", logging.id)
    pulumi.export("logging-bucket-intelligent-tiering", logging_intelligent_tiering.id)
    

    The first param must be a unique string to represent the URN, and it can't contain any "_". Well, this is what I understand about my error code. Feel free to add a more understandable answer.