@jaypie/constructs 1.2.52 → 1.2.53
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/JaypieWebDeploymentBucket.d.ts +18 -1
- package/dist/cjs/helpers/__tests__/constructWafLogBucketName.spec.d.ts +1 -0
- package/dist/cjs/helpers/constructWafLogBucketName.d.ts +8 -0
- package/dist/cjs/helpers/index.d.ts +1 -0
- package/dist/cjs/index.cjs +61 -4
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/JaypieWebDeploymentBucket.d.ts +18 -1
- package/dist/esm/helpers/__tests__/constructWafLogBucketName.spec.d.ts +1 -0
- package/dist/esm/helpers/constructWafLogBucketName.d.ts +8 -0
- package/dist/esm/helpers/index.d.ts +1 -0
- package/dist/esm/index.js +61 -5
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RemovalPolicy } from "aws-cdk-lib";
|
|
1
|
+
import { CfnOutput, RemovalPolicy } from "aws-cdk-lib";
|
|
2
2
|
import * as acm from "aws-cdk-lib/aws-certificatemanager";
|
|
3
3
|
import * as cloudfront from "aws-cdk-lib/aws-cloudfront";
|
|
4
4
|
import { AddToResourcePolicyResult, PolicyStatement } from "aws-cdk-lib/aws-iam";
|
|
@@ -123,6 +123,23 @@ export declare class JaypieWebDeploymentBucket extends Construct implements s3.I
|
|
|
123
123
|
readonly wafLogBucket?: s3.IBucket;
|
|
124
124
|
readonly webAcl?: wafv2.CfnWebACL;
|
|
125
125
|
constructor(scope: Construct, id: string, props?: JaypieWebDeploymentBucketProps);
|
|
126
|
+
/**
|
|
127
|
+
* Emit stack-level CfnOutputs with stable, hash-free logical IDs so they can
|
|
128
|
+
* be read directly from `cdk-outputs.json` without prefix-matching. Skips
|
|
129
|
+
* outputs whose underlying resource is absent.
|
|
130
|
+
*
|
|
131
|
+
* Logical IDs (with optional `prefix`):
|
|
132
|
+
* - `${prefix}DestinationBucketName`
|
|
133
|
+
* - `${prefix}DestinationBucketDeployRoleArn` (when a deploy role exists)
|
|
134
|
+
* - `${prefix}DistributionId` (when a distribution exists)
|
|
135
|
+
* - `${prefix}CertificateArn` (when a certificate exists)
|
|
136
|
+
*
|
|
137
|
+
* @returns map of created outputs keyed by their logical ID
|
|
138
|
+
*/
|
|
139
|
+
exportOutputs(options?: {
|
|
140
|
+
prefix?: string;
|
|
141
|
+
scope?: Construct;
|
|
142
|
+
}): Record<string, CfnOutput>;
|
|
126
143
|
private resolveWafConfig;
|
|
127
144
|
private isExportNameObject;
|
|
128
145
|
private resolveLogBucket;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build a WAF log bucket name shaped like
|
|
3
|
+
* `aws-waf-logs-${env}-${key}-${name}-waf-${nonce}` (or `-waf-` only when
|
|
4
|
+
* `name` is empty). The `aws-waf-logs-` prefix is required by AWS WAF, and
|
|
5
|
+
* `-${PROJECT_NONCE}` is preserved verbatim for uniqueness; the middle is
|
|
6
|
+
* truncated when needed to fit S3's 63-char limit.
|
|
7
|
+
*/
|
|
8
|
+
export declare function constructWafLogBucketName(name?: string): string;
|
|
@@ -2,6 +2,7 @@ export { addDatadogLayers } from "./addDatadogLayers";
|
|
|
2
2
|
export { constructEnvName } from "./constructEnvName";
|
|
3
3
|
export { constructStackName } from "./constructStackName";
|
|
4
4
|
export { constructTagger } from "./constructTagger";
|
|
5
|
+
export { constructWafLogBucketName } from "./constructWafLogBucketName";
|
|
5
6
|
export { envHostname, HostConfig } from "./envHostname";
|
|
6
7
|
export { extendDatadogRole, ExtendDatadogRoleOptions, } from "./extendDatadogRole";
|
|
7
8
|
export { clearAllCertificateCaches, clearCertificateCache, resolveCertificate, ResolveCertificateOptions, } from "./resolveCertificate";
|
package/dist/esm/index.js
CHANGED
|
@@ -365,6 +365,29 @@ function constructTagger(construct, { name } = {}) {
|
|
|
365
365
|
return true;
|
|
366
366
|
}
|
|
367
367
|
|
|
368
|
+
const AWS_WAF_LOGS_PREFIX = "aws-waf-logs-";
|
|
369
|
+
const S3_BUCKET_NAME_MAX_LENGTH = 63;
|
|
370
|
+
/**
|
|
371
|
+
* Build a WAF log bucket name shaped like
|
|
372
|
+
* `aws-waf-logs-${env}-${key}-${name}-waf-${nonce}` (or `-waf-` only when
|
|
373
|
+
* `name` is empty). The `aws-waf-logs-` prefix is required by AWS WAF, and
|
|
374
|
+
* `-${PROJECT_NONCE}` is preserved verbatim for uniqueness; the middle is
|
|
375
|
+
* truncated when needed to fit S3's 63-char limit.
|
|
376
|
+
*/
|
|
377
|
+
function constructWafLogBucketName(name) {
|
|
378
|
+
const nonce = (process.env.PROJECT_NONCE ?? "cfe2").toLowerCase();
|
|
379
|
+
const nonceSuffix = `-${nonce}`;
|
|
380
|
+
const innerName = name ? `${name}-waf` : "waf";
|
|
381
|
+
const middle = constructEnvName(innerName)
|
|
382
|
+
.toLowerCase()
|
|
383
|
+
.slice(0, -nonceSuffix.length);
|
|
384
|
+
const maxMiddleLength = S3_BUCKET_NAME_MAX_LENGTH - AWS_WAF_LOGS_PREFIX.length - nonceSuffix.length;
|
|
385
|
+
const truncated = middle.length > maxMiddleLength
|
|
386
|
+
? middle.slice(0, maxMiddleLength).replace(/-+$/, "")
|
|
387
|
+
: middle;
|
|
388
|
+
return `${AWS_WAF_LOGS_PREFIX}${truncated}${nonceSuffix}`;
|
|
389
|
+
}
|
|
390
|
+
|
|
368
391
|
function envHostname({ component, domain, env, subdomain, } = {}) {
|
|
369
392
|
const resolvedDomain = domain || process.env.CDK_ENV_DOMAIN || process.env.CDK_ENV_HOSTED_ZONE;
|
|
370
393
|
if (!resolvedDomain) {
|
|
@@ -2729,9 +2752,7 @@ class JaypieDistribution extends Construct {
|
|
|
2729
2752
|
const wafLogBucketId = wafConfig.name
|
|
2730
2753
|
? constructEnvName(`${wafConfig.name}-WafLogBucket`)
|
|
2731
2754
|
: constructEnvName("WafLogBucket");
|
|
2732
|
-
const wafLogBucketName = wafConfig.name
|
|
2733
|
-
? `aws-waf-logs-${constructEnvName(`${wafConfig.name}-waf`).toLowerCase()}`
|
|
2734
|
-
: `aws-waf-logs-${constructEnvName("waf").toLowerCase()}`;
|
|
2755
|
+
const wafLogBucketName = constructWafLogBucketName(wafConfig.name);
|
|
2735
2756
|
const createdBucket = new s3.Bucket(this, wafLogBucketId, {
|
|
2736
2757
|
bucketName: wafLogBucketName,
|
|
2737
2758
|
lifecycleRules: [
|
|
@@ -4586,7 +4607,7 @@ class JaypieWebDeploymentBucket extends Construct {
|
|
|
4586
4607
|
let wafLogBucket;
|
|
4587
4608
|
if (wafLogBucketProp === true) {
|
|
4588
4609
|
const wafLogBucketId = constructEnvName(`${wafConfig.name}-WafLogBucket`);
|
|
4589
|
-
const wafLogBucketName =
|
|
4610
|
+
const wafLogBucketName = constructWafLogBucketName(wafConfig.name);
|
|
4590
4611
|
const createdBucket = new s3.Bucket(this, wafLogBucketId, {
|
|
4591
4612
|
bucketName: wafLogBucketName,
|
|
4592
4613
|
lifecycleRules: [
|
|
@@ -4625,6 +4646,41 @@ class JaypieWebDeploymentBucket extends Construct {
|
|
|
4625
4646
|
}
|
|
4626
4647
|
}
|
|
4627
4648
|
}
|
|
4649
|
+
/**
|
|
4650
|
+
* Emit stack-level CfnOutputs with stable, hash-free logical IDs so they can
|
|
4651
|
+
* be read directly from `cdk-outputs.json` without prefix-matching. Skips
|
|
4652
|
+
* outputs whose underlying resource is absent.
|
|
4653
|
+
*
|
|
4654
|
+
* Logical IDs (with optional `prefix`):
|
|
4655
|
+
* - `${prefix}DestinationBucketName`
|
|
4656
|
+
* - `${prefix}DestinationBucketDeployRoleArn` (when a deploy role exists)
|
|
4657
|
+
* - `${prefix}DistributionId` (when a distribution exists)
|
|
4658
|
+
* - `${prefix}CertificateArn` (when a certificate exists)
|
|
4659
|
+
*
|
|
4660
|
+
* @returns map of created outputs keyed by their logical ID
|
|
4661
|
+
*/
|
|
4662
|
+
exportOutputs(options = {}) {
|
|
4663
|
+
const { prefix = "", scope = Stack.of(this) } = options;
|
|
4664
|
+
const outputs = {};
|
|
4665
|
+
const create = (id, value) => {
|
|
4666
|
+
const logicalId = `${prefix}${id}`;
|
|
4667
|
+
const output = new CfnOutput(scope, `${logicalId}Export`, { value });
|
|
4668
|
+
output.overrideLogicalId(logicalId);
|
|
4669
|
+
outputs[logicalId] = output;
|
|
4670
|
+
return output;
|
|
4671
|
+
};
|
|
4672
|
+
create("DestinationBucketName", this.bucket.bucketName);
|
|
4673
|
+
if (this.deployRoleArn) {
|
|
4674
|
+
create("DestinationBucketDeployRoleArn", this.deployRoleArn);
|
|
4675
|
+
}
|
|
4676
|
+
if (this.distribution) {
|
|
4677
|
+
create("DistributionId", this.distribution.distributionId);
|
|
4678
|
+
}
|
|
4679
|
+
if (this.certificate) {
|
|
4680
|
+
create("CertificateArn", this.certificate.certificateArn);
|
|
4681
|
+
}
|
|
4682
|
+
return outputs;
|
|
4683
|
+
}
|
|
4628
4684
|
resolveWafConfig(wafProp, defaultName) {
|
|
4629
4685
|
if (wafProp === false)
|
|
4630
4686
|
return undefined;
|
|
@@ -5160,5 +5216,5 @@ class JaypieWebSocketTable extends Construct {
|
|
|
5160
5216
|
}
|
|
5161
5217
|
}
|
|
5162
5218
|
|
|
5163
|
-
export { CDK$2 as CDK, JaypieAccountLoggingBucket, JaypieApiGateway, JaypieAppStack, JaypieBucketQueuedLambda, JaypieCertificate, JaypieDatadogBucket, JaypieDatadogForwarder, JaypieDatadogSecret, JaypieDistribution, JaypieDnsRecord, JaypieDynamoDb, JaypieEnvSecret, JaypieEventsRule, JaypieExpressLambda, JaypieGitHubDeployRole, JaypieHostedZone, JaypieInfrastructureStack, JaypieLambda, JaypieMigration, JaypieMongoDbSecret, JaypieNextJs, JaypieOpenAiSecret, JaypieOrganizationTrail, JaypieQueuedLambda, JaypieSsoPermissions, JaypieSsoSyncApplication, JaypieStack, JaypieStaticWebBucket, JaypieTraceSigningKeySecret, JaypieWebDeploymentBucket, JaypieWebSocket, JaypieWebSocketLambda, JaypieWebSocketTable, addDatadogLayers, clearAllCertificateCaches, clearAllSecretsCaches, clearCertificateCache, clearSecretsCache, constructEnvName, constructStackName, constructTagger, ensureRoute53QueryLoggingPolicy, envHostname, extendDatadogRole, isEnv, isProductionEnv, isSandboxEnv, isValidHostname$1 as isValidHostname, isValidSubdomain, jaypieLambdaEnv, mergeDomain, resolveCertificate, resolveDatadogForwarderFunction, resolveDatadogLayers, resolveDatadogLoggingDestination, resolveEnvironment, resolveHostedZone, resolveParamsAndSecrets, resolveSecrets };
|
|
5219
|
+
export { CDK$2 as CDK, JaypieAccountLoggingBucket, JaypieApiGateway, JaypieAppStack, JaypieBucketQueuedLambda, JaypieCertificate, JaypieDatadogBucket, JaypieDatadogForwarder, JaypieDatadogSecret, JaypieDistribution, JaypieDnsRecord, JaypieDynamoDb, JaypieEnvSecret, JaypieEventsRule, JaypieExpressLambda, JaypieGitHubDeployRole, JaypieHostedZone, JaypieInfrastructureStack, JaypieLambda, JaypieMigration, JaypieMongoDbSecret, JaypieNextJs, JaypieOpenAiSecret, JaypieOrganizationTrail, JaypieQueuedLambda, JaypieSsoPermissions, JaypieSsoSyncApplication, JaypieStack, JaypieStaticWebBucket, JaypieTraceSigningKeySecret, JaypieWebDeploymentBucket, JaypieWebSocket, JaypieWebSocketLambda, JaypieWebSocketTable, addDatadogLayers, clearAllCertificateCaches, clearAllSecretsCaches, clearCertificateCache, clearSecretsCache, constructEnvName, constructStackName, constructTagger, constructWafLogBucketName, ensureRoute53QueryLoggingPolicy, envHostname, extendDatadogRole, isEnv, isProductionEnv, isSandboxEnv, isValidHostname$1 as isValidHostname, isValidSubdomain, jaypieLambdaEnv, mergeDomain, resolveCertificate, resolveDatadogForwarderFunction, resolveDatadogLayers, resolveDatadogLoggingDestination, resolveEnvironment, resolveHostedZone, resolveParamsAndSecrets, resolveSecrets };
|
|
5164
5220
|
//# sourceMappingURL=index.js.map
|