https://pulumi.com logo
#general
Title
# general
p

prehistoric-shoe-5168

03/11/2022, 6:35 PM
my pulumi code file is starting to get quite large. can someone point me to best practices here? 🧵
i can provide some examples: i have already used pulling json files in… i’ll give you one in python where that isnt setup to work:
Copy code
scopes=[
        auth0.ResourceServerScopeArgs(
            description="Create foos",
            value="create:foo",
        ),
        auth0.ResourceServerScopeArgs(
            description="Create bars",
            value="create:bar",
        ),
etc…. i have ~100 lines of json that will need to be converted to this format
i found importing from other modules to be hinky
b

bored-oyster-3147

03/11/2022, 10:04 PM
This is what component resources are for, so you can logically group your resources. Or since the entry point to your Pulumi project is a method you could just break your long code file into methods in other files that are invoked at the entry point.
p

prehistoric-shoe-5168

03/11/2022, 10:33 PM
is there a nice example of either of these in use? the documentation only points to a TS example that is pretty opaque in terms of how it’d be used in a real project
re: the entry point - that’s what i mean as being “hinky”. and i could be Doing It Wrong (TM)
b

bored-oyster-3147

03/11/2022, 11:14 PM
There should be examples of component resources for a few of the different languages in the docs. As for code organization like splitting into methods, you would just use whatever means of organization makes sense for your language of choice. How your organize your code in your Pulumi project isn't really a question of Pulumi so much as it is a question of how it is done with that language. Maybe provide more info on what you mean by hinky? What's going wrong? Can you share code?
g

great-sunset-355

03/14/2022, 7:30 AM
p

prehistoric-shoe-5168

03/14/2022, 4:35 PM
@bored-oyster-3147 - let me dig some up. this has been extremely helpful already.
@great-sunset-355 - this is epic. exactly what i needed to get started here. i really like the data classes https://github.com/mitodl/ol-infrastructure/blob/main/src/ol_infrastructure/components/aws/cache.py
3 Views