I've looked through the docs, but can't find how t...
# help
j
I've looked through the docs, but can't find how to set default tags for functions. I added datadog and want to set
service
,
env
, and
version
tags, but not finding a good way to default them. Any pointers?
f
Hey @Jonathan Chapman, you can tag all the resources in a stack like this:
Copy code
import * as cdk from "@aws-cdk/core";
  cdk.Tags.of(this).add("service", "my-service");
Or only tag functions:
Copy code
cdk.Tags.of(this).add("service", "my-service", {
    includeResourceTypes: ["AWS:Lambda:Function"]
  });
More details here: https://docs.aws.amazon.com/cdk/latest/guide/tagging.html
s
Oh @Frank beat me to it. haha. I use datadog as well. I just tag the whole app and it tags all the resources including fns. But that's nice tip there from Frank
includeResourceTypes
that I didn't know about.
Copy code
cdk.Tags.of(app).add('env', app.stage)
  cdk.Tags.of(app).add('service', app.name)
f
Haha @Sione is 🎯. You can do
.of(app)
to tag all resources in the app.
j
awesome, tks guys!