# general


01/25/2019, 7:59 PM
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: 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()}-<|>`
👍 1


01/25/2019, 8:03 PM
This looks pretty nice!