@jaypie/constructs 1.2.65 → 1.2.67

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -213,6 +213,19 @@ export interface JaypieDistributionProps extends Omit<cloudfront.DistributionPro
213
213
  * @default CDK.ROLE.HOSTING
214
214
  */
215
215
  roleTag?: string;
216
+ /**
217
+ * Service tag for attributing this distribution to a service (parallel to
218
+ * `roleTag`, matching `JaypieLambda`). When set, the distribution is tagged
219
+ * with `CDK.TAG.SERVICE` (so metrics carry `service:<value>` instead of
220
+ * `service:N/A`) and the created access-log and WAF-log buckets are tagged
221
+ * with the same value, so the Datadog forwarder attributes their forwarded
222
+ * logs to the service instead of the generic `cloudfront`/source default.
223
+ *
224
+ * Omit to preserve current behavior (no service tag). Has no effect on
225
+ * external/imported log buckets, which this construct does not own.
226
+ * @default undefined (no service tag)
227
+ */
228
+ serviceTag?: string;
216
229
  /**
217
230
  * WAF WebACL configuration for the CloudFront distribution.
218
231
  * - true/undefined: create and attach a WebACL with sensible defaults
package/dist/esm/index.js CHANGED
@@ -293,7 +293,7 @@ function addDatadogLayers(lambdaFunction, options = {}) {
293
293
  extensionLayerVersion: CDK$2.DATADOG.LAYER.EXTENSION,
294
294
  env: process.env.PROJECT_ENV,
295
295
  service: resolvedService,
296
- version: process.env.PROJECT_VERSION,
296
+ version: process.env.DD_VERSION || process.env.PROJECT_VERSION,
297
297
  });
298
298
  datadogLambda.addLambdaFunctions([lambdaFunction]);
299
299
  return true;
@@ -740,6 +740,7 @@ function jaypieLambdaEnv(options = {}) {
740
740
  // Default environment variables from process.env if present
741
741
  const defaultEnvVars = [
742
742
  "DATADOG_API_KEY_ARN",
743
+ "DD_VERSION",
743
744
  "LOG_LEVEL",
744
745
  "MODULE_LOGGER",
745
746
  "MODULE_LOG_LEVEL",
@@ -2671,7 +2672,7 @@ const DEFAULT_MANAGED_RULES$1 = [
2671
2672
  class JaypieDistribution extends Construct {
2672
2673
  constructor(scope, id, props) {
2673
2674
  super(scope, id);
2674
- const { certificate: certificateProp = true, defaultBehavior: propsDefaultBehavior, deleteExistingRecord = false, destination: destinationProp = true, handler, host: propsHost, logBucket: logBucketProp, originReadTimeout = Duration.seconds(CDK$2.DURATION.CLOUDFRONT_API), responseHeadersPolicy: responseHeadersPolicyProp, roleTag = CDK$2.ROLE.API, securityHeaders: securityHeadersProp, streaming = false, waf: wafProp = true, zone: propsZone, ...distributionProps } = props;
2675
+ const { certificate: certificateProp = true, defaultBehavior: propsDefaultBehavior, deleteExistingRecord = false, destination: destinationProp = true, handler, host: propsHost, logBucket: logBucketProp, originReadTimeout = Duration.seconds(CDK$2.DURATION.CLOUDFRONT_API), responseHeadersPolicy: responseHeadersPolicyProp, roleTag = CDK$2.ROLE.API, securityHeaders: securityHeadersProp, serviceTag, streaming = false, waf: wafProp = true, zone: propsZone, ...distributionProps } = props;
2675
2676
  // Validate environment variables
2676
2677
  if (process.env.CDK_ENV_API_SUBDOMAIN &&
2677
2678
  !isValidSubdomain(process.env.CDK_ENV_API_SUBDOMAIN)) {
@@ -2880,6 +2881,9 @@ class JaypieDistribution extends Construct {
2880
2881
  removalPolicy: RemovalPolicy.DESTROY,
2881
2882
  });
2882
2883
  Tags.of(createdBucket).add(CDK$2.TAG.ROLE, CDK$2.ROLE.STORAGE);
2884
+ if (serviceTag) {
2885
+ Tags.of(createdBucket).add(CDK$2.TAG.SERVICE, serviceTag);
2886
+ }
2883
2887
  logBucket = createdBucket;
2884
2888
  }
2885
2889
  // Add S3 notifications if we have a bucket and destination is not false
@@ -2910,6 +2914,9 @@ class JaypieDistribution extends Construct {
2910
2914
  ...distributionProps,
2911
2915
  });
2912
2916
  Tags.of(this.distribution).add(CDK$2.TAG.ROLE, roleTag);
2917
+ if (serviceTag) {
2918
+ Tags.of(this.distribution).add(CDK$2.TAG.SERVICE, serviceTag);
2919
+ }
2913
2920
  this.distributionArn = `arn:aws:cloudfront::${Stack.of(this).account}:distribution/${this.distribution.distributionId}`;
2914
2921
  this.distributionDomainName = this.distribution.distributionDomainName;
2915
2922
  this.distributionId = this.distribution.distributionId;
@@ -3114,6 +3121,9 @@ class JaypieDistribution extends Construct {
3114
3121
  removalPolicy: RemovalPolicy.RETAIN,
3115
3122
  });
3116
3123
  Tags.of(createdBucket).add(CDK$2.TAG.ROLE, CDK$2.ROLE.MONITORING);
3124
+ if (serviceTag) {
3125
+ Tags.of(createdBucket).add(CDK$2.TAG.SERVICE, serviceTag);
3126
+ }
3117
3127
  // Add Datadog forwarder notification
3118
3128
  if (destinationProp !== false) {
3119
3129
  const lambdaDestination = destinationProp === true