Hi everybody. Does anybody have any examples of ho...
# general
f
Hi everybody. Does anybody have any examples of how you organize your Java code for your infrastructure? For instance, in AWS, I have a couple of VPCs, EKS, RDS, s3 buckets, Cloudfront, SES, SNS, and so on; how do I split this config into packages or modules?
l
There are blog posts on this topic on the Pulumi site. And you can use the ComponentResource class to use OO principles for separation. Given how you phrased your question, my advice is: ignore resource types. Consider only update frequency and functionality. Your VPC will get updated a lot less frequently than your serverless application code, so you don't want your lambdas in the same project as your VPC. And your backup logic isn't related to your firewall logic, so don't put snapshot and WAF code in the same file.
And security groups for your application and security groups for your bastion probably won't be in the same project either.
f
Thank you for your answer. As I understand it, ComponentResource is for grouping resources. Currently, I'm using Pulumi Crosswalk to configure my resources. For example, for VPC, I'm using this package - com.pulumi.awsx.ec2.Vpc. Shall I group VPC with something else? To me, VPC looks like a self-sufficient package, and I don't need to create a ComponentResource for VPC or anything else. What do you think?
l
VPC might not be one you group. I do, as my VPC component resource handles peering and NACLs too. But other resources might be more suitable for grouping for you. RDS, along with the related security groups, AWS Backup vault and cleanup lambdas? ALB, with WAFv2, security groups, and some CloudWatch event rules? Etc.