Hey all, just wanted to share a pattern I discover...
# general
b
Hey all, just wanted to share a pattern I discovered that I think is pretty cool. I asked earlier this week if it were possible to iterate over resources (e.g, to make sure they all had a specific tag defined.) It turns out that’s not really possible, but I actually like this approach even better. First, you define a little helper class called PulumiContext, like the one in this gist: https://gist.github.com/levand/0b77a9dec11b46bb9e3b71d77204d7ca Then, we create all of our Pulumi resources using that context:
Copy code
var ctx = new util.PulumiContext().withProps( { tags: { Environment: pulumi.getStack() } });

// This bucket automatically has an Environment tag because it was created using the context defined above
let logs = ctx.r(aws.s3.Bucket, "logs", {
    bucket: `logs-${pulumi.getStack()}-<http://.myapp.com|.myapp.com>`
});
👍 1
s
This looks pretty nice!