@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
@@ -329,7 +329,7 @@ function addDatadogLayers(lambdaFunction, options = {}) {
329
329
  extensionLayerVersion: CDK$2.DATADOG.LAYER.EXTENSION,
330
330
  env: process.env.PROJECT_ENV,
331
331
  service: resolvedService,
332
- version: process.env.PROJECT_VERSION,
332
+ version: process.env.DD_VERSION || process.env.PROJECT_VERSION,
333
333
  });
334
334
  datadogLambda.addLambdaFunctions([lambdaFunction]);
335
335
  return true;
@@ -776,6 +776,7 @@ function jaypieLambdaEnv(options = {}) {
776
776
  // Default environment variables from process.env if present
777
777
  const defaultEnvVars = [
778
778
  "DATADOG_API_KEY_ARN",
779
+ "DD_VERSION",
779
780
  "LOG_LEVEL",
780
781
  "MODULE_LOGGER",
781
782
  "MODULE_LOG_LEVEL",
@@ -2707,7 +2708,7 @@ const DEFAULT_MANAGED_RULES$1 = [
2707
2708
  class JaypieDistribution extends constructs.Construct {
2708
2709
  constructor(scope, id, props) {
2709
2710
  super(scope, id);
2710
- const { certificate: certificateProp = true, defaultBehavior: propsDefaultBehavior, deleteExistingRecord = false, destination: destinationProp = true, handler, host: propsHost, logBucket: logBucketProp, originReadTimeout = cdk.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;
2711
+ const { certificate: certificateProp = true, defaultBehavior: propsDefaultBehavior, deleteExistingRecord = false, destination: destinationProp = true, handler, host: propsHost, logBucket: logBucketProp, originReadTimeout = cdk.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;
2711
2712
  // Validate environment variables
2712
2713
  if (process.env.CDK_ENV_API_SUBDOMAIN &&
2713
2714
  !isValidSubdomain(process.env.CDK_ENV_API_SUBDOMAIN)) {
@@ -2916,6 +2917,9 @@ class JaypieDistribution extends constructs.Construct {
2916
2917
  removalPolicy: cdk.RemovalPolicy.DESTROY,
2917
2918
  });
2918
2919
  cdk.Tags.of(createdBucket).add(CDK$2.TAG.ROLE, CDK$2.ROLE.STORAGE);
2920
+ if (serviceTag) {
2921
+ cdk.Tags.of(createdBucket).add(CDK$2.TAG.SERVICE, serviceTag);
2922
+ }
2919
2923
  logBucket = createdBucket;
2920
2924
  }
2921
2925
  // Add S3 notifications if we have a bucket and destination is not false
@@ -2946,6 +2950,9 @@ class JaypieDistribution extends constructs.Construct {
2946
2950
  ...distributionProps,
2947
2951
  });
2948
2952
  cdk.Tags.of(this.distribution).add(CDK$2.TAG.ROLE, roleTag);
2953
+ if (serviceTag) {
2954
+ cdk.Tags.of(this.distribution).add(CDK$2.TAG.SERVICE, serviceTag);
2955
+ }
2949
2956
  this.distributionArn = `arn:aws:cloudfront::${cdk.Stack.of(this).account}:distribution/${this.distribution.distributionId}`;
2950
2957
  this.distributionDomainName = this.distribution.distributionDomainName;
2951
2958
  this.distributionId = this.distribution.distributionId;
@@ -3150,6 +3157,9 @@ class JaypieDistribution extends constructs.Construct {
3150
3157
  removalPolicy: cdk.RemovalPolicy.RETAIN,
3151
3158
  });
3152
3159
  cdk.Tags.of(createdBucket).add(CDK$2.TAG.ROLE, CDK$2.ROLE.MONITORING);
3160
+ if (serviceTag) {
3161
+ cdk.Tags.of(createdBucket).add(CDK$2.TAG.SERVICE, serviceTag);
3162
+ }
3153
3163
  // Add Datadog forwarder notification
3154
3164
  if (destinationProp !== false) {
3155
3165
  const lambdaDestination = destinationProp === true