@jaypie/constructs 1.1.62-rc.0 → 1.1.62-rc.1
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/dist/cjs/JaypieLambda.d.ts +4 -4
- package/dist/cjs/index.cjs +26 -21
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/JaypieLambda.d.ts +4 -4
- package/dist/esm/index.js +23 -18
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/cjs/JaypieSsoGroups.d.ts +0 -121
- package/dist/cjs/__tests__/JaypieSsoGroups.spec.d.ts +0 -1
- package/dist/cjs/helpers/addDatadogLayer.d.ts +0 -5
- package/dist/cjs/helpers/addParamsAndSecrets.d.ts +0 -12
- package/dist/cjs/helpers/projectEnvName.d.ts +0 -5
- package/dist/cjs/helpers/stackTagger.d.ts +0 -4
- package/dist/esm/JaypieSsoGroups.d.ts +0 -121
- package/dist/esm/__tests__/JaypieSsoGroups.spec.d.ts +0 -1
- package/dist/esm/helpers/addDatadogLayer.d.ts +0 -5
- package/dist/esm/helpers/addParamsAndSecrets.d.ts +0 -12
- package/dist/esm/helpers/projectEnvName.d.ts +0 -5
- package/dist/esm/helpers/stackTagger.d.ts +0 -4
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Construct } from "constructs";
|
|
2
2
|
import { Duration, Stack, RemovalPolicy } from "aws-cdk-lib";
|
|
3
3
|
import * as lambda from "aws-cdk-lib/aws-lambda";
|
|
4
|
-
import * as iam from "aws-cdk-lib/aws-iam";
|
|
5
4
|
import * as cloudwatch from "aws-cdk-lib/aws-cloudwatch";
|
|
6
5
|
import * as ec2 from "aws-cdk-lib/aws-ec2";
|
|
6
|
+
import * as iam from "aws-cdk-lib/aws-iam";
|
|
7
|
+
import * as logs from "aws-cdk-lib/aws-logs";
|
|
7
8
|
import * as secretsmanager from "aws-cdk-lib/aws-secretsmanager";
|
|
8
9
|
import { JaypieEnvSecret } from "./JaypieEnvSecret.js";
|
|
9
10
|
export interface JaypieLambdaProps {
|
|
@@ -27,9 +28,8 @@ export interface JaypieLambdaProps {
|
|
|
27
28
|
handler: string;
|
|
28
29
|
initialPolicy?: iam.PolicyStatement[];
|
|
29
30
|
layers?: lambda.ILayerVersion[];
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
logRetentionRetryOptions?: lambda.LogRetentionRetryOptions;
|
|
31
|
+
logGroup?: logs.ILogGroup;
|
|
32
|
+
logRetention?: logs.RetentionDays | number;
|
|
33
33
|
maxEventAge?: Duration;
|
|
34
34
|
memorySize?: number;
|
|
35
35
|
paramsAndSecrets?: lambda.ParamsAndSecretsLayerVersion | boolean;
|
package/dist/esm/index.js
CHANGED
|
@@ -18,11 +18,12 @@ import * as s3n from 'aws-cdk-lib/aws-s3-notifications';
|
|
|
18
18
|
import { LambdaDestination } from 'aws-cdk-lib/aws-s3-notifications';
|
|
19
19
|
import * as sqs from 'aws-cdk-lib/aws-sqs';
|
|
20
20
|
import * as lambdaEventSources from 'aws-cdk-lib/aws-lambda-event-sources';
|
|
21
|
+
import * as logs from 'aws-cdk-lib/aws-logs';
|
|
22
|
+
import { LogGroup, RetentionDays, FilterPattern } from 'aws-cdk-lib/aws-logs';
|
|
21
23
|
import { Rule, RuleTargetInput } from 'aws-cdk-lib/aws-events';
|
|
22
24
|
import { LambdaFunction } from 'aws-cdk-lib/aws-events-targets';
|
|
23
25
|
import * as cloudfront from 'aws-cdk-lib/aws-cloudfront';
|
|
24
26
|
import * as origins from 'aws-cdk-lib/aws-cloudfront-origins';
|
|
25
|
-
import { LogGroup, RetentionDays, FilterPattern } from 'aws-cdk-lib/aws-logs';
|
|
26
27
|
import { Nextjs } from 'cdk-nextjs-standalone';
|
|
27
28
|
import * as path from 'path';
|
|
28
29
|
import { Trail, ReadWriteType } from 'aws-cdk-lib/aws-cloudtrail';
|
|
@@ -869,7 +870,7 @@ class JaypieAppStack extends JaypieStack {
|
|
|
869
870
|
class JaypieLambda extends Construct {
|
|
870
871
|
constructor(scope, id, props) {
|
|
871
872
|
super(scope, id);
|
|
872
|
-
const { allowAllOutbound, allowPublicSubnet, architecture = lambda.Architecture.X86_64, code, datadogApiKeyArn, deadLetterQueue, deadLetterQueueEnabled, deadLetterTopic, description, environment: initialEnvironment = {}, envSecrets = {}, ephemeralStorageSize, filesystem, handler = "index.handler", initialPolicy, layers = [], logRetention = CDK$2.LAMBDA.LOG_RETENTION,
|
|
873
|
+
const { allowAllOutbound, allowPublicSubnet, architecture = lambda.Architecture.X86_64, code, datadogApiKeyArn, deadLetterQueue, deadLetterQueueEnabled, deadLetterTopic, description, environment: initialEnvironment = {}, envSecrets = {}, ephemeralStorageSize, filesystem, handler = "index.handler", initialPolicy, layers = [], logGroup, logRetention = CDK$2.LAMBDA.LOG_RETENTION, maxEventAge, memorySize = CDK$2.LAMBDA.MEMORY_SIZE, paramsAndSecrets, paramsAndSecretsOptions, profiling, profilingGroup, provisionedConcurrentExecutions, reservedConcurrentExecutions, retryAttempts, roleTag = CDK$2.ROLE.PROCESSING, runtime = lambda.Runtime.NODEJS_22_X, runtimeManagementMode, secrets = [], securityGroups, timeout = Duration.seconds(CDK$2.DURATION.LAMBDA_WORKER), tracing, vendorTag, vpc, vpcSubnets, } = props;
|
|
873
874
|
// Get base environment with defaults
|
|
874
875
|
const environment = jaypieLambdaEnv({ initialEnvironment });
|
|
875
876
|
const codeAsset = typeof code === "string" ? lambda.Code.fromAsset(code) : code;
|
|
@@ -895,6 +896,12 @@ class JaypieLambda extends Construct {
|
|
|
895
896
|
paramsAndSecrets,
|
|
896
897
|
options: paramsAndSecretsOptions,
|
|
897
898
|
});
|
|
899
|
+
// Create LogGroup if not provided
|
|
900
|
+
const resolvedLogGroup = logGroup ??
|
|
901
|
+
new logs.LogGroup(this, "LogGroup", {
|
|
902
|
+
retention: logRetention,
|
|
903
|
+
removalPolicy: RemovalPolicy.DESTROY,
|
|
904
|
+
});
|
|
898
905
|
// Create Lambda Function
|
|
899
906
|
this._lambda = new lambda.Function(this, "Function", {
|
|
900
907
|
allowAllOutbound,
|
|
@@ -915,9 +922,7 @@ class JaypieLambda extends Construct {
|
|
|
915
922
|
handler,
|
|
916
923
|
initialPolicy,
|
|
917
924
|
layers: resolvedLayers,
|
|
918
|
-
|
|
919
|
-
logRetentionRole,
|
|
920
|
-
logRetentionRetryOptions,
|
|
925
|
+
logGroup: resolvedLogGroup,
|
|
921
926
|
maxEventAge,
|
|
922
927
|
memorySize,
|
|
923
928
|
paramsAndSecrets: resolvedParamsAndSecrets,
|
|
@@ -1088,7 +1093,7 @@ class JaypieLambda extends Construct {
|
|
|
1088
1093
|
class JaypieQueuedLambda extends Construct {
|
|
1089
1094
|
constructor(scope, id, props) {
|
|
1090
1095
|
super(scope, id);
|
|
1091
|
-
const { allowAllOutbound, allowPublicSubnet, architecture, batchSize = 1, code, datadogApiKeyArn, deadLetterQueue, deadLetterQueueEnabled, deadLetterTopic, description, environment = {}, envSecrets = {}, ephemeralStorageSize, fifo = true, filesystem, handler = "index.handler", initialPolicy, layers = [], logRetention = CDK$2.LAMBDA.LOG_RETENTION,
|
|
1096
|
+
const { allowAllOutbound, allowPublicSubnet, architecture, batchSize = 1, code, datadogApiKeyArn, deadLetterQueue, deadLetterQueueEnabled, deadLetterTopic, description, environment = {}, envSecrets = {}, ephemeralStorageSize, fifo = true, filesystem, handler = "index.handler", initialPolicy, layers = [], logGroup, logRetention = CDK$2.LAMBDA.LOG_RETENTION, maxEventAge, memorySize = CDK$2.LAMBDA.MEMORY_SIZE, paramsAndSecrets, paramsAndSecretsOptions, profiling, profilingGroup, provisionedConcurrentExecutions, reservedConcurrentExecutions, retryAttempts, roleTag, runtime = lambda.Runtime.NODEJS_22_X, runtimeManagementMode, secrets = [], securityGroups, timeout = Duration.seconds(CDK$2.DURATION.LAMBDA_WORKER), tracing, vendorTag, visibilityTimeout = Duration.seconds(CDK$2.DURATION.LAMBDA_WORKER), vpc, vpcSubnets, } = props;
|
|
1092
1097
|
// Create SQS Queue
|
|
1093
1098
|
this._queue = new sqs.Queue(this, "Queue", {
|
|
1094
1099
|
fifo,
|
|
@@ -1123,9 +1128,8 @@ class JaypieQueuedLambda extends Construct {
|
|
|
1123
1128
|
handler,
|
|
1124
1129
|
initialPolicy,
|
|
1125
1130
|
layers,
|
|
1131
|
+
logGroup,
|
|
1126
1132
|
logRetention,
|
|
1127
|
-
logRetentionRole,
|
|
1128
|
-
logRetentionRetryOptions,
|
|
1129
1133
|
maxEventAge,
|
|
1130
1134
|
memorySize,
|
|
1131
1135
|
paramsAndSecrets,
|
|
@@ -1631,7 +1635,7 @@ class JaypieDatadogForwarder extends Construct {
|
|
|
1631
1635
|
class JaypieDistribution extends Construct {
|
|
1632
1636
|
constructor(scope, id, props) {
|
|
1633
1637
|
super(scope, id);
|
|
1634
|
-
const { certificate: certificateProp = true, handler, host: propsHost, invokeMode = lambda.InvokeMode.BUFFERED, roleTag = CDK$2.ROLE.
|
|
1638
|
+
const { certificate: certificateProp = true, handler, host: propsHost, invokeMode = lambda.InvokeMode.BUFFERED, roleTag = CDK$2.ROLE.API, zone: propsZone, defaultBehavior: propsDefaultBehavior, ...distributionProps } = props;
|
|
1635
1639
|
// Validate environment variables
|
|
1636
1640
|
if (process.env.CDK_ENV_API_SUBDOMAIN &&
|
|
1637
1641
|
!isValidSubdomain(process.env.CDK_ENV_API_SUBDOMAIN)) {
|
|
@@ -1667,9 +1671,7 @@ class JaypieDistribution extends Construct {
|
|
|
1667
1671
|
}
|
|
1668
1672
|
this.host = host;
|
|
1669
1673
|
// Determine zone from props or environment
|
|
1670
|
-
const zone = propsZone ||
|
|
1671
|
-
process.env.CDK_ENV_API_HOSTED_ZONE ||
|
|
1672
|
-
process.env.CDK_ENV_HOSTED_ZONE;
|
|
1674
|
+
const zone = propsZone || process.env.CDK_ENV_HOSTED_ZONE;
|
|
1673
1675
|
// Resolve the origin from handler
|
|
1674
1676
|
// Check order matters: IFunctionUrl before IOrigin (FunctionUrl also has bind method)
|
|
1675
1677
|
// IFunction before IFunctionUrl (IFunction doesn't have functionUrlId)
|
|
@@ -1701,7 +1703,7 @@ class JaypieDistribution extends Construct {
|
|
|
1701
1703
|
defaultBehavior = {
|
|
1702
1704
|
cachePolicy: cloudfront.CachePolicy.CACHING_DISABLED,
|
|
1703
1705
|
origin,
|
|
1704
|
-
originRequestPolicy: cloudfront.OriginRequestPolicy.
|
|
1706
|
+
originRequestPolicy: cloudfront.OriginRequestPolicy.ALL_VIEWER,
|
|
1705
1707
|
viewerProtocolPolicy: cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
|
|
1706
1708
|
};
|
|
1707
1709
|
}
|
|
@@ -2943,7 +2945,7 @@ class JaypieWebDeploymentBucket extends Construct {
|
|
|
2943
2945
|
this.bucket = new s3.Bucket(this, "DestinationBucket", {
|
|
2944
2946
|
accessControl: s3.BucketAccessControl.BUCKET_OWNER_FULL_CONTROL,
|
|
2945
2947
|
autoDeleteObjects: true,
|
|
2946
|
-
blockPublicAccess: s3.BlockPublicAccess.
|
|
2948
|
+
blockPublicAccess: s3.BlockPublicAccess.BLOCK_ACLS_ONLY,
|
|
2947
2949
|
bucketName: props.name || constructEnvName("web"),
|
|
2948
2950
|
publicReadAccess: true,
|
|
2949
2951
|
removalPolicy: RemovalPolicy.DESTROY,
|
|
@@ -2996,11 +2998,14 @@ class JaypieWebDeploymentBucket extends Construct {
|
|
|
2996
2998
|
actions: ["s3:ListBucket"],
|
|
2997
2999
|
resources: [this.bucket.bucketArn],
|
|
2998
3000
|
}));
|
|
2999
|
-
// Allow the role to
|
|
3001
|
+
// Allow the role to describe the current stack
|
|
3002
|
+
const stack = Stack.of(this);
|
|
3000
3003
|
bucketDeployRole.addToPolicy(new PolicyStatement({
|
|
3001
3004
|
actions: ["cloudformation:DescribeStacks"],
|
|
3002
3005
|
effect: Effect.ALLOW,
|
|
3003
|
-
resources: [
|
|
3006
|
+
resources: [
|
|
3007
|
+
`arn:aws:cloudformation:${stack.region}:${stack.account}:stack/${stack.stackName}/*`,
|
|
3008
|
+
],
|
|
3004
3009
|
}));
|
|
3005
3010
|
this.deployRoleArn = bucketDeployRole.roleArn;
|
|
3006
3011
|
// Output the deploy role ARN
|
|
@@ -3033,7 +3038,7 @@ class JaypieWebDeploymentBucket extends Construct {
|
|
|
3033
3038
|
this.distribution = new cloudfront.Distribution(this, "Distribution", {
|
|
3034
3039
|
defaultBehavior: {
|
|
3035
3040
|
cachePolicy: cloudfront.CachePolicy.CACHING_DISABLED,
|
|
3036
|
-
origin: new origins.
|
|
3041
|
+
origin: new origins.S3StaticWebsiteOrigin(this.bucket),
|
|
3037
3042
|
viewerProtocolPolicy: cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
|
|
3038
3043
|
},
|
|
3039
3044
|
certificate: this.certificate,
|
|
@@ -3042,7 +3047,7 @@ class JaypieWebDeploymentBucket extends Construct {
|
|
|
3042
3047
|
Tags.of(this.distribution).add(CDK$2.TAG.ROLE, roleTag);
|
|
3043
3048
|
// If this is production, enable caching on everything but index.html
|
|
3044
3049
|
if (isProductionEnv()) {
|
|
3045
|
-
this.distribution.addBehavior("/*", new origins.
|
|
3050
|
+
this.distribution.addBehavior("/*", new origins.S3StaticWebsiteOrigin(this.bucket), {
|
|
3046
3051
|
viewerProtocolPolicy: cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
|
|
3047
3052
|
cachePolicy: cloudfront.CachePolicy.CACHING_OPTIMIZED,
|
|
3048
3053
|
});
|