@jaypie/constructs 1.2.44 → 1.2.45

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.
@@ -9,6 +9,15 @@ import * as wafv2 from "aws-cdk-lib/aws-wafv2";
9
9
  import { Construct } from "constructs";
10
10
  import { HostConfig } from "./helpers";
11
11
  export interface JaypieWafConfig {
12
+ /**
13
+ * Unique name for this distribution's WAF resources. Required when passing a
14
+ * WAF config object. Injected into the WebACL name and WAF log bucket name
15
+ * so multiple JaypieDistribution instances can coexist in the same
16
+ * account/env without S3/WAFv2 name collisions.
17
+ *
18
+ * Pass `waf: true` (or omit) to retain the legacy, non-namespaced names.
19
+ */
20
+ name: string;
12
21
  /**
13
22
  * Whether WAF is enabled
14
23
  * @default true
package/dist/esm/index.js CHANGED
@@ -2653,14 +2653,17 @@ class JaypieDistribution extends Construct {
2653
2653
  sampledRequestsEnabled: true,
2654
2654
  },
2655
2655
  });
2656
+ const webAclName = wafConfig.name
2657
+ ? constructEnvName(`${wafConfig.name}-WebAcl`)
2658
+ : constructEnvName("WebAcl");
2656
2659
  const webAcl = new wafv2.CfnWebACL(this, "WebAcl", {
2657
2660
  defaultAction: { allow: {} },
2658
- name: constructEnvName("WebAcl"),
2661
+ name: webAclName,
2659
2662
  rules,
2660
2663
  scope: "CLOUDFRONT",
2661
2664
  visibilityConfig: {
2662
2665
  cloudWatchMetricsEnabled: true,
2663
- metricName: constructEnvName("WebAcl"),
2666
+ metricName: webAclName,
2664
2667
  sampledRequestsEnabled: true,
2665
2668
  },
2666
2669
  });
@@ -2676,8 +2679,14 @@ class JaypieDistribution extends Construct {
2676
2679
  let wafLogBucket;
2677
2680
  if (wafLogBucketProp === true) {
2678
2681
  // Create inline WAF logging bucket with Datadog forwarding
2679
- const createdBucket = new s3.Bucket(this, constructEnvName("WafLogBucket"), {
2680
- bucketName: `aws-waf-logs-${constructEnvName("waf").toLowerCase()}`,
2682
+ const wafLogBucketId = wafConfig.name
2683
+ ? constructEnvName(`${wafConfig.name}-WafLogBucket`)
2684
+ : constructEnvName("WafLogBucket");
2685
+ const wafLogBucketName = wafConfig.name
2686
+ ? `aws-waf-logs-${constructEnvName(`${wafConfig.name}-waf`).toLowerCase()}`
2687
+ : `aws-waf-logs-${constructEnvName("waf").toLowerCase()}`;
2688
+ const createdBucket = new s3.Bucket(this, wafLogBucketId, {
2689
+ bucketName: wafLogBucketName,
2681
2690
  lifecycleRules: [
2682
2691
  {
2683
2692
  expiration: Duration.days(90),