https://pulumi.com logo
Title
m

microscopic-barista-15731

10/11/2022, 12:53 PM
Hi all, I have a structure like :
└── common
    ├── Pulumi.cmn.yaml
    ├── Pulumi.yaml
    ├── __main__.py
    ├── __pycache__
    ├── kubernetes
    │   ├── Pulumi.kubernetes.yaml
    │   ├── Pulumi.yaml
    │   ├── __main__.py
    │   ├── __pycache__
    │   └── requirements.txt
    └── requirements.txt
I would like to have micro stacks and use the GCP bucket as the backend. I’m pointing to the same GCP bucket in both Pulumi.yaml files. Here is stacks list:
pulumi stack ls
NAME        LAST UPDATE     RESOURCE COUNT
cmn         12 minutes ago  3
kubernetes  22 hours ago    0
in kubernetes
__main__.py
file I have this part of code
stack = pulumi.get_stack()
print(stack)
pulumi.stack_reference(f"cmn")
and I’m getting the error:
pulumi:pulumi:Stack (kubernetes-kubernetes):
    error: Program failed with an unhandled exception:
    Traceback (most recent call last):
      File "/Users/irmas/projects/devops-new/infra/common/kubernetes/./__main__.py", line 16, in <module>
        pulumi.stack_reference("cmn")
    TypeError: 'module' object is not callable
 
    kubernetes
So it is possible at all to have micro stacks with GCP bucket as the backend?
b

billowy-army-68599

10/12/2022, 3:33 PM
yes. you need to init your stacks with something like
project.stack
but it’s totally possible
m

microscopic-barista-15731

10/12/2022, 3:34 PM
Do we have somewhere working example?
b

billowy-army-68599

10/12/2022, 3:37 PM
it should be the same as any other backend. can you try removing the
f
string from your stack_reference?
m

microscopic-barista-15731

10/12/2022, 3:38 PM
it is removed, but doesn’t work
with same error
and the reference settings:
pulumi.stack_reference("common.cmn")
tried coomon-cmn, cmn
b

billowy-army-68599

10/12/2022, 3:41 PM
your method name is wrong
stack = pulumi.get_stack()
print(stack)
pulumi.StackReference("stack-1.dev")
m

microscopic-barista-15731

10/12/2022, 4:12 PM
Thanks 🙂 I found this example somewhere and I was using it. pycharm suggested it too
b

billowy-army-68599

10/12/2022, 4:27 PM
if you can tell me where the example is I’ll fix it
m

microscopic-barista-15731

10/13/2022, 2:13 PM
It was in some kind of medium article