@jaypie/constructs 1.1.62-rc.2 → 1.1.62
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.
- package/LICENSE.txt +21 -0
- package/dist/cjs/JaypieDistribution.d.ts +11 -0
- package/dist/cjs/index.cjs +37 -2
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/JaypieDistribution.d.ts +11 -0
- package/dist/esm/index.js +37 -2
- package/dist/esm/index.js.map +1 -1
- package/package.json +3 -2
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Finlayson Studio, LLC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -3,6 +3,8 @@ import * as acm from "aws-cdk-lib/aws-certificatemanager";
|
|
|
3
3
|
import * as cloudfront from "aws-cdk-lib/aws-cloudfront";
|
|
4
4
|
import * as lambda from "aws-cdk-lib/aws-lambda";
|
|
5
5
|
import * as route53 from "aws-cdk-lib/aws-route53";
|
|
6
|
+
import * as s3 from "aws-cdk-lib/aws-s3";
|
|
7
|
+
import { LambdaDestination } from "aws-cdk-lib/aws-s3-notifications";
|
|
6
8
|
import { Construct } from "constructs";
|
|
7
9
|
export interface JaypieDistributionProps extends Omit<cloudfront.DistributionProps, "certificate" | "defaultBehavior"> {
|
|
8
10
|
/**
|
|
@@ -14,6 +16,14 @@ export interface JaypieDistributionProps extends Omit<cloudfront.DistributionPro
|
|
|
14
16
|
* Override default behavior (optional if handler is provided)
|
|
15
17
|
*/
|
|
16
18
|
defaultBehavior?: cloudfront.BehaviorOptions;
|
|
19
|
+
/**
|
|
20
|
+
* Log destination configuration for CloudFront access logs
|
|
21
|
+
* - LambdaDestination: Use a specific Lambda destination for S3 notifications
|
|
22
|
+
* - true: Use Datadog forwarder for S3 notifications (default)
|
|
23
|
+
* - false: Disable logging entirely
|
|
24
|
+
* @default true
|
|
25
|
+
*/
|
|
26
|
+
destination?: LambdaDestination | boolean;
|
|
17
27
|
/**
|
|
18
28
|
* The origin handler - can be an IOrigin, IFunctionUrl, or IFunction
|
|
19
29
|
* If IFunction, a FunctionUrl will be created with auth NONE
|
|
@@ -49,6 +59,7 @@ export declare class JaypieDistribution extends Construct implements cloudfront.
|
|
|
49
59
|
readonly domainName: string;
|
|
50
60
|
readonly functionUrl?: lambda.FunctionUrl;
|
|
51
61
|
readonly host?: string;
|
|
62
|
+
readonly logBucket?: s3.IBucket;
|
|
52
63
|
constructor(scope: Construct, id: string, props: JaypieDistributionProps);
|
|
53
64
|
private isIOrigin;
|
|
54
65
|
private isIFunctionUrl;
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1666,7 +1666,7 @@ class JaypieDatadogForwarder extends constructs.Construct {
|
|
|
1666
1666
|
class JaypieDistribution extends constructs.Construct {
|
|
1667
1667
|
constructor(scope, id, props) {
|
|
1668
1668
|
super(scope, id);
|
|
1669
|
-
const { certificate: certificateProp = true, handler, host: propsHost, invokeMode = lambda__namespace.InvokeMode.BUFFERED, roleTag = CDK$2.ROLE.API, zone: propsZone,
|
|
1669
|
+
const { certificate: certificateProp = true, defaultBehavior: propsDefaultBehavior, destination: destinationProp = true, handler, host: propsHost, invokeMode = lambda__namespace.InvokeMode.BUFFERED, roleTag = CDK$2.ROLE.API, zone: propsZone, ...distributionProps } = props;
|
|
1670
1670
|
// Validate environment variables
|
|
1671
1671
|
if (process.env.CDK_ENV_API_SUBDOMAIN &&
|
|
1672
1672
|
!isValidSubdomain(process.env.CDK_ENV_API_SUBDOMAIN)) {
|
|
@@ -1732,9 +1732,10 @@ class JaypieDistribution extends constructs.Construct {
|
|
|
1732
1732
|
}
|
|
1733
1733
|
else if (origin) {
|
|
1734
1734
|
defaultBehavior = {
|
|
1735
|
+
allowedMethods: cloudfront__namespace.AllowedMethods.ALLOW_ALL,
|
|
1735
1736
|
cachePolicy: cloudfront__namespace.CachePolicy.CACHING_DISABLED,
|
|
1736
1737
|
origin,
|
|
1737
|
-
originRequestPolicy: cloudfront__namespace.OriginRequestPolicy.
|
|
1738
|
+
originRequestPolicy: cloudfront__namespace.OriginRequestPolicy.ALL_VIEWER_EXCEPT_HOST_HEADER,
|
|
1738
1739
|
viewerProtocolPolicy: cloudfront__namespace.ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
|
|
1739
1740
|
};
|
|
1740
1741
|
}
|
|
@@ -1759,6 +1760,33 @@ class JaypieDistribution extends constructs.Construct {
|
|
|
1759
1760
|
}
|
|
1760
1761
|
this.certificate = certificateToUse;
|
|
1761
1762
|
}
|
|
1763
|
+
// Create log bucket if logging is enabled
|
|
1764
|
+
let logBucket;
|
|
1765
|
+
if (destinationProp !== false) {
|
|
1766
|
+
logBucket = new s3__namespace.Bucket(this, constructEnvName("LogBucket"), {
|
|
1767
|
+
objectOwnership: s3__namespace.ObjectOwnership.OBJECT_WRITER,
|
|
1768
|
+
removalPolicy: cdk.RemovalPolicy.DESTROY,
|
|
1769
|
+
autoDeleteObjects: true,
|
|
1770
|
+
lifecycleRules: [
|
|
1771
|
+
{
|
|
1772
|
+
expiration: cdk.Duration.days(90),
|
|
1773
|
+
transitions: [
|
|
1774
|
+
{
|
|
1775
|
+
storageClass: s3__namespace.StorageClass.INFREQUENT_ACCESS,
|
|
1776
|
+
transitionAfter: cdk.Duration.days(30),
|
|
1777
|
+
},
|
|
1778
|
+
],
|
|
1779
|
+
},
|
|
1780
|
+
],
|
|
1781
|
+
});
|
|
1782
|
+
cdk.Tags.of(logBucket).add(CDK$2.TAG.ROLE, CDK$2.ROLE.STORAGE);
|
|
1783
|
+
// Add S3 notification to Datadog forwarder
|
|
1784
|
+
const lambdaDestination = destinationProp === true
|
|
1785
|
+
? new s3n.LambdaDestination(resolveDatadogForwarderFunction(this))
|
|
1786
|
+
: destinationProp;
|
|
1787
|
+
logBucket.addEventNotification(s3__namespace.EventType.OBJECT_CREATED, lambdaDestination);
|
|
1788
|
+
this.logBucket = logBucket;
|
|
1789
|
+
}
|
|
1762
1790
|
// Create the CloudFront distribution
|
|
1763
1791
|
this.distribution = new cloudfront__namespace.Distribution(this, constructEnvName("Distribution"), {
|
|
1764
1792
|
defaultBehavior,
|
|
@@ -1768,6 +1796,13 @@ class JaypieDistribution extends constructs.Construct {
|
|
|
1768
1796
|
domainNames: [host],
|
|
1769
1797
|
}
|
|
1770
1798
|
: {}),
|
|
1799
|
+
...(logBucket
|
|
1800
|
+
? {
|
|
1801
|
+
enableLogging: true,
|
|
1802
|
+
logBucket,
|
|
1803
|
+
logFilePrefix: "cloudfront-logs/",
|
|
1804
|
+
}
|
|
1805
|
+
: {}),
|
|
1771
1806
|
...distributionProps,
|
|
1772
1807
|
});
|
|
1773
1808
|
cdk.Tags.of(this.distribution).add(CDK$2.TAG.ROLE, roleTag);
|