Hey everyone, I'm experimenting with Pulumi. I'm u...
# getting-started
g
Hey everyone, I'm experimenting with Pulumi. I'm using Kotlin (which is interoperable with Java) and Gradle setup. Are there any examples of using Java for a mono-repo-multiple-project-multi-account setup? I cannot find good examples of how to do this in Java.
My current setup defines the
pulumi.yaml
file in the root and the execution is driven by the top
build.gradle
file. How can I set this up so that each project has its own entry point to deploy the resources in multiple accounts?
Any help is appreciated.
l
Pulumi.yaml goes in the project directory, not the root directory. You need one directory (or directory tree) per project.
The multi-account configuration is unrelated to project configuration. One project can access any number of accounts. And any number of projects can access the same account.
g
This is the default setup I got when I initialized my project for the first time.
Screenshot 2024-06-26 at 5.33.59 PM.png
l
It looks like "app" is the Pulumi project directory, and pulkt is the root directory.
That would work. If you prefer to share all your code without building jars, you could have directories under app/src/main/pulumi contain your Pulumi projects
That follows the JVM convention, I think?
g
My goal is simple for my experiment. Create an abstraction for a resource - an S3 bucket with Versioning, Expiration, etc, enabled. The developer to deploy this resource for multiple projects (let's say - only in one AWS account)
I'm testing this out in my local now - to see if it actually works the way I want it
I ran the command from the root and I get this.
Screenshot 2024-06-26 at 5.41.02 PM.png
Now when I run this command by moving the
pulumi.yaml
file to the project directory - it's broken.
l
The developer to deploy this resource for multiple projects (let's say - only in one AWS account)
You may need to define what "projects" means in this context. It's not a Pulumi project: a single resource can managed (deployed) only from a single stack of a single project.
g
Hence the ask - do you have any sample projects that the team has created using Java to manage a mono-repo-multiple project setup - so I can mimic that and see if it meets the requirement.
l
Now when I run this command by moving the pulumi.yaml file to the project directory - it's broken.
That's likely to be because of how or where you're running
pulumi up
.
You might check #java: the topic has never come up before in this channel, as far as I know.
I'm happy to work through the issues with you, but it's likely you'll be the first in this community to try most of the things you talk about.
g
I'm surprised because I could achieve this easily using Typescript but not Java.
I'm not particularly fond of TS because I can build really simple DSLs using Kotlin, and static-type checks are far more reliable with Kotlin than with TS.
Anyway - thank you for the input @little-cartoon-10569. I will post this topic to the #java channel and see if anyone can help me.
l
Yes, I'm sure it'll be easy, I just don't know if you'll find any existing examples.