https://pulumi.com logo
Title
e

early-keyboard-41388

10/19/2021, 9:19 AM
Hi, I’m having some issues with the
StackReference
(trying to understand it). I’m using S3 as backend (everything in one bucket), ideally a folder for each project (micro services setup: infra, app, services, etc). With this I saw two options: 1. Every pulumi project in same folder -> each stack needs to have project name in it (eg,
infra.dev
), or they will collide (dev, in two different projects, in same folder in S3). 2. Every project in different folders -> stack can be named with just the environment (
dev
,
stg
,
prod
) In case 1, I did
new StackReference('infra.dev')
, and it ends with error:
aws:lambda:Function (lambda_name):
    error: 1 error occurred:
    	* error creating Lambda Function (1): ValidationException:
    	status code: 400, request id: 6dab7a4b-c6cc-4ebc-8a46-cb14060d50f2
Apparently it gets the stack_reference but it fails to deploy. My assumption is because it’s empty data or failing in some level with those refs. Also tried
new StackReference('project_name/infra.dev')
, but got the error:
error: Preview failed: unknown stack "project_name/infra.dev"
If I wanted to use the case 2, everything in different folders, how do you reference to the other stack? Any help is more than welcome.
g

great-sunset-355

10/19/2021, 12:57 PM
each project should have its own directory then stack reference path is
org/project/stack
e

early-keyboard-41388

10/19/2021, 2:13 PM
@great-sunset-355 thanks for the response. But, I read that with S3 as backend,
org
is not defined. Or do you know how to get it? Also, with different paths (folders within the same bucket), tried to reference as
project/stack
. But got
unknown stack
, or something of the sort.
g

great-sunset-355

10/19/2021, 2:16 PM
hmm I see, check out the structure of this project, it's pretty big and complex it may give you an answer https://github.com/mitodl/ol-infrastructure/blob/f42b329df70b4ec7c59295e0e011100a61775472/src/ol_infrastructure/infrastructure/mongodb/__main__.py#L28
It looks like you just use only the
stack_name
regardless of the project with S3 Here is a reference to the same stack but from a completely different directory https://github.com/mitodl/ol-infrastructure/blob/f42b329df70b4ec7c59295e0e011100a61775472/src/ol_infrastructure/applications/concourse/__main__.py#L40
e

early-keyboard-41388

10/19/2021, 2:39 PM
Thanks! I’ll check that
l

little-cartoon-10569

10/19/2021, 8:11 PM
I thought it wasn't possible to use StackReferences to stacks in a different file? That is, if you're using an S3 backend, everything has to have the same
backend
URL?
e

early-keyboard-41388

10/20/2021, 5:44 AM
@little-cartoon-10569 are those questions, they sound like affirmations. From my limited testing, I couldn’t find a way for a given project to get a StackReference on a stack on a different folder. The only working model I could make, was with all the stacks on the same folder.