@incloodsolutions/devkit 0.0.1 → 0.0.3
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/README.md +42 -16
- package/dist/aws/cdk/constructs/api-gateway-construct.cjs +95 -0
- package/dist/aws/cdk/constructs/api-gateway-construct.cjs.map +1 -0
- package/dist/aws/cdk/constructs/api-gateway-construct.d.cts +80 -0
- package/dist/aws/cdk/constructs/api-gateway-construct.d.ts +80 -0
- package/dist/aws/cdk/constructs/api-gateway-construct.js +93 -0
- package/dist/aws/cdk/constructs/api-gateway-construct.js.map +1 -0
- package/dist/aws/cdk/constructs/api-gateway-v2-construct.cjs +77 -0
- package/dist/aws/cdk/constructs/api-gateway-v2-construct.cjs.map +1 -0
- package/dist/aws/cdk/constructs/api-gateway-v2-construct.d.cts +55 -0
- package/dist/aws/cdk/constructs/api-gateway-v2-construct.d.ts +55 -0
- package/dist/aws/cdk/constructs/api-gateway-v2-construct.js +75 -0
- package/dist/aws/cdk/constructs/api-gateway-v2-construct.js.map +1 -0
- package/dist/aws/cdk/constructs/api-gateway-websocket-construct.cjs +65 -0
- package/dist/aws/cdk/constructs/api-gateway-websocket-construct.cjs.map +1 -0
- package/dist/aws/cdk/constructs/api-gateway-websocket-construct.d.cts +73 -0
- package/dist/aws/cdk/constructs/api-gateway-websocket-construct.d.ts +73 -0
- package/dist/aws/cdk/constructs/api-gateway-websocket-construct.js +63 -0
- package/dist/aws/cdk/constructs/api-gateway-websocket-construct.js.map +1 -0
- package/dist/aws/cdk/constructs/cloudfront-construct.cjs +68 -0
- package/dist/aws/cdk/constructs/cloudfront-construct.cjs.map +1 -0
- package/dist/aws/cdk/constructs/cloudfront-construct.d.cts +36 -0
- package/dist/aws/cdk/constructs/cloudfront-construct.d.ts +36 -0
- package/dist/aws/cdk/constructs/cloudfront-construct.js +66 -0
- package/dist/aws/cdk/constructs/cloudfront-construct.js.map +1 -0
- package/dist/aws/cdk/constructs/cloudwatch-construct.cjs +43 -0
- package/dist/aws/cdk/constructs/cloudwatch-construct.cjs.map +1 -0
- package/dist/aws/cdk/constructs/cloudwatch-construct.d.cts +36 -0
- package/dist/aws/cdk/constructs/cloudwatch-construct.d.ts +36 -0
- package/dist/aws/cdk/constructs/cloudwatch-construct.js +41 -0
- package/dist/aws/cdk/constructs/cloudwatch-construct.js.map +1 -0
- package/dist/aws/cdk/constructs/dynamo-db-construct.cjs +113 -0
- package/dist/aws/cdk/constructs/dynamo-db-construct.cjs.map +1 -0
- package/dist/aws/cdk/constructs/dynamo-db-construct.d.cts +53 -0
- package/dist/aws/cdk/constructs/dynamo-db-construct.d.ts +53 -0
- package/dist/aws/cdk/constructs/dynamo-db-construct.js +111 -0
- package/dist/aws/cdk/constructs/dynamo-db-construct.js.map +1 -0
- package/dist/aws/cdk/constructs/event-bridge-construct.cjs +47 -0
- package/dist/aws/cdk/constructs/event-bridge-construct.cjs.map +1 -0
- package/dist/aws/cdk/constructs/event-bridge-construct.d.cts +41 -0
- package/dist/aws/cdk/constructs/event-bridge-construct.d.ts +41 -0
- package/dist/aws/cdk/constructs/event-bridge-construct.js +45 -0
- package/dist/aws/cdk/constructs/event-bridge-construct.js.map +1 -0
- package/dist/aws/cdk/constructs/index.cjs +881 -0
- package/dist/aws/cdk/constructs/index.cjs.map +1 -0
- package/dist/aws/cdk/constructs/index.d.cts +34 -0
- package/dist/aws/cdk/constructs/index.d.ts +34 -0
- package/dist/aws/cdk/constructs/index.js +863 -0
- package/dist/aws/cdk/constructs/index.js.map +1 -0
- package/dist/aws/cdk/constructs/lambda-authorizer-construct.cjs +37 -0
- package/dist/aws/cdk/constructs/lambda-authorizer-construct.cjs.map +1 -0
- package/dist/aws/cdk/constructs/lambda-authorizer-construct.d.cts +44 -0
- package/dist/aws/cdk/constructs/lambda-authorizer-construct.d.ts +44 -0
- package/dist/aws/cdk/constructs/lambda-authorizer-construct.js +35 -0
- package/dist/aws/cdk/constructs/lambda-authorizer-construct.js.map +1 -0
- package/dist/aws/cdk/constructs/lambda-authorizer-v2-construct.cjs +47 -0
- package/dist/aws/cdk/constructs/lambda-authorizer-v2-construct.cjs.map +1 -0
- package/dist/aws/cdk/constructs/lambda-authorizer-v2-construct.d.cts +45 -0
- package/dist/aws/cdk/constructs/lambda-authorizer-v2-construct.d.ts +45 -0
- package/dist/aws/cdk/constructs/lambda-authorizer-v2-construct.js +45 -0
- package/dist/aws/cdk/constructs/lambda-authorizer-v2-construct.js.map +1 -0
- package/dist/aws/cdk/constructs/lambda-construct.cjs +82 -0
- package/dist/aws/cdk/constructs/lambda-construct.cjs.map +1 -0
- package/dist/aws/cdk/constructs/lambda-construct.d.cts +37 -0
- package/dist/aws/cdk/constructs/lambda-construct.d.ts +37 -0
- package/dist/aws/cdk/constructs/lambda-construct.js +80 -0
- package/dist/aws/cdk/constructs/lambda-construct.js.map +1 -0
- package/dist/aws/cdk/constructs/lambda-layer-construct.cjs +72 -0
- package/dist/aws/cdk/constructs/lambda-layer-construct.cjs.map +1 -0
- package/dist/aws/cdk/constructs/lambda-layer-construct.d.cts +52 -0
- package/dist/aws/cdk/constructs/lambda-layer-construct.d.ts +52 -0
- package/dist/aws/cdk/constructs/lambda-layer-construct.js +70 -0
- package/dist/aws/cdk/constructs/lambda-layer-construct.js.map +1 -0
- package/dist/aws/cdk/constructs/role-policy-construct.cjs +53 -0
- package/dist/aws/cdk/constructs/role-policy-construct.cjs.map +1 -0
- package/dist/aws/cdk/constructs/role-policy-construct.d.cts +44 -0
- package/dist/aws/cdk/constructs/role-policy-construct.d.ts +44 -0
- package/dist/aws/cdk/constructs/role-policy-construct.js +51 -0
- package/dist/aws/cdk/constructs/role-policy-construct.js.map +1 -0
- package/dist/aws/cdk/constructs/s3-construct.cjs +38 -0
- package/dist/aws/cdk/constructs/s3-construct.cjs.map +1 -0
- package/dist/aws/cdk/constructs/s3-construct.d.cts +36 -0
- package/dist/aws/cdk/constructs/s3-construct.d.ts +36 -0
- package/dist/aws/cdk/constructs/s3-construct.js +36 -0
- package/dist/aws/cdk/constructs/s3-construct.js.map +1 -0
- package/dist/aws/cdk/constructs/s3-deployment-construct.cjs +168 -0
- package/dist/aws/cdk/constructs/s3-deployment-construct.cjs.map +1 -0
- package/dist/aws/cdk/constructs/s3-deployment-construct.d.cts +72 -0
- package/dist/aws/cdk/constructs/s3-deployment-construct.d.ts +72 -0
- package/dist/aws/cdk/constructs/s3-deployment-construct.js +166 -0
- package/dist/aws/cdk/constructs/s3-deployment-construct.js.map +1 -0
- package/dist/aws/cdk/constructs/sns-construct.cjs +43 -0
- package/dist/aws/cdk/constructs/sns-construct.cjs.map +1 -0
- package/dist/aws/cdk/constructs/sns-construct.d.cts +45 -0
- package/dist/aws/cdk/constructs/sns-construct.d.ts +45 -0
- package/dist/aws/cdk/constructs/sns-construct.js +41 -0
- package/dist/aws/cdk/constructs/sns-construct.js.map +1 -0
- package/dist/aws/cdk/constructs/sqs-construct.cjs +55 -0
- package/dist/aws/cdk/constructs/sqs-construct.cjs.map +1 -0
- package/dist/aws/cdk/constructs/sqs-construct.d.cts +52 -0
- package/dist/aws/cdk/constructs/sqs-construct.d.ts +52 -0
- package/dist/aws/cdk/constructs/sqs-construct.js +53 -0
- package/dist/aws/cdk/constructs/sqs-construct.js.map +1 -0
- package/dist/aws/cdk/constructs/vpc-construct.cjs +33 -0
- package/dist/aws/cdk/constructs/vpc-construct.cjs.map +1 -0
- package/dist/aws/cdk/constructs/vpc-construct.d.cts +34 -0
- package/dist/aws/cdk/constructs/vpc-construct.d.ts +34 -0
- package/dist/aws/cdk/constructs/vpc-construct.js +31 -0
- package/dist/aws/cdk/constructs/vpc-construct.js.map +1 -0
- package/dist/aws/cdk/index.cjs +881 -0
- package/dist/aws/cdk/index.cjs.map +1 -0
- package/dist/aws/cdk/index.d.cts +34 -0
- package/dist/aws/cdk/index.d.ts +34 -0
- package/dist/aws/cdk/index.js +863 -0
- package/dist/aws/cdk/index.js.map +1 -0
- package/dist/aws/cli/index.cjs +4 -0
- package/dist/aws/cli/index.cjs.map +1 -0
- package/dist/aws/cli/index.d.cts +2 -0
- package/dist/aws/cli/index.d.ts +2 -0
- package/dist/aws/cli/index.js +3 -0
- package/dist/aws/cli/index.js.map +1 -0
- package/dist/aws/index.cjs +881 -0
- package/dist/aws/index.cjs.map +1 -0
- package/dist/aws/index.d.cts +34 -0
- package/dist/aws/index.d.ts +34 -0
- package/dist/aws/index.js +863 -0
- package/dist/aws/index.js.map +1 -0
- package/dist/aws/types/index.cjs +4 -0
- package/dist/aws/types/index.cjs.map +1 -0
- package/dist/aws/types/index.d.cts +18 -0
- package/dist/aws/types/index.d.ts +18 -0
- package/dist/aws/types/index.js +3 -0
- package/dist/aws/types/index.js.map +1 -0
- package/dist/index.d.cts +34 -755
- package/dist/index.d.ts +34 -755
- package/dist/lint/index.cjs +4 -0
- package/dist/lint/index.cjs.map +1 -0
- package/dist/lint/index.d.cts +2 -0
- package/dist/lint/index.d.ts +2 -0
- package/dist/lint/index.js +3 -0
- package/dist/lint/index.js.map +1 -0
- package/dist/prettier/index.cjs +4 -0
- package/dist/prettier/index.cjs.map +1 -0
- package/dist/prettier/index.d.cts +2 -0
- package/dist/prettier/index.d.ts +2 -0
- package/dist/prettier/index.js +3 -0
- package/dist/prettier/index.js.map +1 -0
- package/dist/utility/index.cjs +4 -0
- package/dist/utility/index.cjs.map +1 -0
- package/dist/utility/index.d.cts +2 -0
- package/dist/utility/index.d.ts +2 -0
- package/dist/utility/index.js +3 -0
- package/dist/utility/index.js.map +1 -0
- package/package.json +8 -3
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Construct } from 'constructs';
|
|
2
|
+
import { Role, RoleProps, PolicyStatementProps } from 'aws-cdk-lib/aws-iam';
|
|
3
|
+
import { IBaseCdkConstructProps } from '../../types/index.js';
|
|
4
|
+
import '@incloodsolutions/toolkit';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Props for BaseRolePolicyConstruct
|
|
8
|
+
*
|
|
9
|
+
* Provides configuration for:
|
|
10
|
+
* - IAM role creation
|
|
11
|
+
* - Inline policy statements
|
|
12
|
+
*/
|
|
13
|
+
interface IDynamoDBConstructProps extends Omit<IBaseCdkConstructProps<{
|
|
14
|
+
/** IAM Role configuration options */
|
|
15
|
+
readonly roleOptions: RoleProps;
|
|
16
|
+
}>, 'appName' | 'stage' | 'stackName'> {
|
|
17
|
+
/**
|
|
18
|
+
* Additional inline policies to attach to the role
|
|
19
|
+
*
|
|
20
|
+
* Each entry is converted into a PolicyStatement
|
|
21
|
+
*/
|
|
22
|
+
readonly policies?: PolicyStatementProps[];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* CDK construct for IAM Role with policies
|
|
26
|
+
*
|
|
27
|
+
* Responsibilities:
|
|
28
|
+
* - Creates an IAM role with configurable options
|
|
29
|
+
* - Applies a default AWS managed policy if none is provided
|
|
30
|
+
* - Attaches optional inline policy statements
|
|
31
|
+
* - Exposes the role ARN as a CloudFormation output
|
|
32
|
+
*/
|
|
33
|
+
declare class BaseRolePolicyConstruct extends Construct {
|
|
34
|
+
/** The created IAM Role instance */
|
|
35
|
+
readonly role: Role;
|
|
36
|
+
/**
|
|
37
|
+
* @param scope Parent construct
|
|
38
|
+
* @param id Unique construct identifier
|
|
39
|
+
* @param props Configuration for role and policies
|
|
40
|
+
*/
|
|
41
|
+
constructor(scope: Construct, id: string, props: IDynamoDBConstructProps);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export { BaseRolePolicyConstruct };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Construct } from 'constructs';
|
|
2
|
+
import { RemovalPolicy, CfnOutput } from 'aws-cdk-lib';
|
|
3
|
+
import { Role, ManagedPolicy, PolicyStatement } from 'aws-cdk-lib/aws-iam';
|
|
4
|
+
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
+
var BaseRolePolicyConstruct = class extends Construct {
|
|
8
|
+
static {
|
|
9
|
+
__name(this, "BaseRolePolicyConstruct");
|
|
10
|
+
}
|
|
11
|
+
/** The created IAM Role instance */
|
|
12
|
+
role;
|
|
13
|
+
/**
|
|
14
|
+
* @param scope Parent construct
|
|
15
|
+
* @param id Unique construct identifier
|
|
16
|
+
* @param props Configuration for role and policies
|
|
17
|
+
*/
|
|
18
|
+
constructor(scope, id, props) {
|
|
19
|
+
super(scope, id);
|
|
20
|
+
this.role = new Role(this, id, {
|
|
21
|
+
...props.options?.roleOptions,
|
|
22
|
+
/**
|
|
23
|
+
* Managed policies attached to the role
|
|
24
|
+
* Defaults to AWSLambdaBasicExecutionRole if not provided
|
|
25
|
+
*/
|
|
26
|
+
managedPolicies: props.options?.roleOptions?.managedPolicies ? props.options.roleOptions.managedPolicies : [
|
|
27
|
+
ManagedPolicy.fromAwsManagedPolicyName(
|
|
28
|
+
"service-role/AWSLambdaBasicExecutionRole"
|
|
29
|
+
)
|
|
30
|
+
]
|
|
31
|
+
});
|
|
32
|
+
if (props?.policies?.length) {
|
|
33
|
+
props.policies.forEach((policy) => {
|
|
34
|
+
this.role.addToPolicy(
|
|
35
|
+
/**
|
|
36
|
+
* Inline policy statement
|
|
37
|
+
*/
|
|
38
|
+
new PolicyStatement(policy)
|
|
39
|
+
);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
this.role.applyRemovalPolicy(RemovalPolicy.DESTROY);
|
|
43
|
+
new CfnOutput(this, "RolePolicyArn", {
|
|
44
|
+
value: this.role.roleArn
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export { BaseRolePolicyConstruct };
|
|
50
|
+
//# sourceMappingURL=role-policy-construct.js.map
|
|
51
|
+
//# sourceMappingURL=role-policy-construct.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/aws/cdk/constructs/role-policy-construct.ts"],"names":[],"mappings":";;;;;;AAkCO,IAAM,uBAAA,GAAN,cAAsC,SAAA,CAAU;AAAA,EAlCvD;AAkCuD,IAAA,MAAA,CAAA,IAAA,EAAA,yBAAA,CAAA;AAAA;AAAA;AAAA,EAE7C,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOT,WAAA,CAAY,KAAA,EAAkB,EAAA,EAAY,KAAA,EAAgC;AACzE,IAAA,KAAA,CAAM,OAAO,EAAE,CAAA;AAEf,IAAA,IAAA,CAAK,IAAA,GAAO,IAAI,IAAA,CAAK,IAAA,EAAM,EAAA,EAAI;AAAA,MAC9B,GAAG,MAAM,OAAA,EAAS,WAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAMlB,eAAA,EACC,MAAM,OAAA,EAAS,WAAA,EAAa,kBACzB,KAAA,CAAM,OAAA,CAAQ,YAAY,eAAA,GAC1B;AAAA,QACD,aAAA,CAAc,wBAAA;AAAA,UACb;AAAA;AACD;AACD,KACF,CAAA;AAKD,IAAA,IAAI,KAAA,EAAO,UAAU,MAAA,EAAQ;AAC5B,MAAA,KAAA,CAAM,QAAA,CAAS,OAAA,CAAQ,CAAC,MAAA,KAAW;AAClC,QAAA,IAAA,CAAK,IAAA,CAAK,WAAA;AAAA;AAAA;AAAA;AAAA,UAIT,IAAI,gBAAgB,MAAM;AAAA,SAC3B;AAAA,MACD,CAAC,CAAA;AAAA,IACF;AAKA,IAAA,IAAA,CAAK,IAAA,CAAK,kBAAA,CAAmB,aAAA,CAAc,OAAO,CAAA;AAKlD,IAAA,IAAI,SAAA,CAAU,MAAM,eAAA,EAAiB;AAAA,MACpC,KAAA,EAAO,KAAK,IAAA,CAAK;AAAA,KACjB,CAAA;AAAA,EACF;AACD","file":"role-policy-construct.js","sourcesContent":["import { Construct } from 'constructs';\nimport { CfnOutput, RemovalPolicy } from 'aws-cdk-lib';\nimport { ManagedPolicy, PolicyStatement, PolicyStatementProps, Role, RoleProps } from 'aws-cdk-lib/aws-iam';\n\nimport { IBaseCdkConstructProps } from '../../types';\n\n/**\n * Props for BaseRolePolicyConstruct\n *\n * Provides configuration for:\n * - IAM role creation\n * - Inline policy statements\n */\ninterface IDynamoDBConstructProps extends Omit<IBaseCdkConstructProps<{\n\t/** IAM Role configuration options */\n\treadonly roleOptions: RoleProps\n}>, 'appName' | 'stage' | 'stackName'> {\n\t/**\n\t * Additional inline policies to attach to the role\n\t *\n\t * Each entry is converted into a PolicyStatement\n\t */\n\treadonly policies?: PolicyStatementProps[];\n}\n\n/**\n * CDK construct for IAM Role with policies\n *\n * Responsibilities:\n * - Creates an IAM role with configurable options\n * - Applies a default AWS managed policy if none is provided\n * - Attaches optional inline policy statements\n * - Exposes the role ARN as a CloudFormation output\n */\nexport class BaseRolePolicyConstruct extends Construct {\n\t/** The created IAM Role instance */\n\treadonly role: Role;\n\n\t/**\n\t * @param scope Parent construct\n\t * @param id Unique construct identifier\n\t * @param props Configuration for role and policies\n\t */\n\tconstructor(scope: Construct, id: string, props: IDynamoDBConstructProps) {\n\t\tsuper(scope, id);\n\n\t\tthis.role = new Role(this, id, {\n\t\t\t...props.options?.roleOptions,\n\n\t\t\t/**\n\t\t\t * Managed policies attached to the role\n\t\t\t * Defaults to AWSLambdaBasicExecutionRole if not provided\n\t\t\t */\n\t\t\tmanagedPolicies:\n\t\t\t\tprops.options?.roleOptions?.managedPolicies\n\t\t\t\t\t? props.options.roleOptions.managedPolicies\n\t\t\t\t\t: [\n\t\t\t\t\t\tManagedPolicy.fromAwsManagedPolicyName(\n\t\t\t\t\t\t\t'service-role/AWSLambdaBasicExecutionRole'\n\t\t\t\t\t\t)\n\t\t\t\t\t]\n\t\t});\n\n\t\t/**\n\t\t * Attach inline policy statements to the role\n\t\t */\n\t\tif (props?.policies?.length) {\n\t\t\tprops.policies.forEach((policy) => {\n\t\t\t\tthis.role.addToPolicy(\n\t\t\t\t\t/**\n\t\t\t\t\t * Inline policy statement\n\t\t\t\t\t */\n\t\t\t\t\tnew PolicyStatement(policy)\n\t\t\t\t);\n\t\t\t});\n\t\t}\n\n\t\t/**\n\t\t * Apply removal policy (useful for non-production environments)\n\t\t */\n\t\tthis.role.applyRemovalPolicy(RemovalPolicy.DESTROY);\n\n\t\t/**\n\t\t * CloudFormation output exposing the role ARN\n\t\t */\n\t\tnew CfnOutput(this, 'RolePolicyArn', {\n\t\t\tvalue: this.role.roleArn\n\t\t});\n\t}\n}"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var constructs = require('constructs');
|
|
4
|
+
var awsCdkLib = require('aws-cdk-lib');
|
|
5
|
+
var awsS3 = require('aws-cdk-lib/aws-s3');
|
|
6
|
+
|
|
7
|
+
var __defProp = Object.defineProperty;
|
|
8
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
+
var BaseS3Construct = class extends constructs.Construct {
|
|
10
|
+
static {
|
|
11
|
+
__name(this, "BaseS3Construct");
|
|
12
|
+
}
|
|
13
|
+
/** The created S3 bucket instance */
|
|
14
|
+
bucket;
|
|
15
|
+
/**
|
|
16
|
+
* @param scope Parent construct
|
|
17
|
+
* @param id Unique construct identifier
|
|
18
|
+
* @param props Configuration for S3 bucket
|
|
19
|
+
*/
|
|
20
|
+
constructor(scope, id, props) {
|
|
21
|
+
super(scope, id);
|
|
22
|
+
this.bucket = new awsS3.Bucket(this, id, {
|
|
23
|
+
...props.options?.bucketOptions,
|
|
24
|
+
/**
|
|
25
|
+
* Removal policy applied to the bucket
|
|
26
|
+
* Defaults to DESTROY if not explicitly defined
|
|
27
|
+
*/
|
|
28
|
+
removalPolicy: props.options?.bucketOptions?.removalPolicy || awsCdkLib.RemovalPolicy.DESTROY
|
|
29
|
+
});
|
|
30
|
+
new awsCdkLib.CfnOutput(this, "S3BucketArn", {
|
|
31
|
+
value: this.bucket.bucketArn
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
exports.BaseS3Construct = BaseS3Construct;
|
|
37
|
+
//# sourceMappingURL=s3-construct.cjs.map
|
|
38
|
+
//# sourceMappingURL=s3-construct.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/aws/cdk/constructs/s3-construct.ts"],"names":["Construct","Bucket","RemovalPolicy","CfnOutput"],"mappings":";;;;;;;;AAyBO,IAAM,eAAA,GAAN,cAA8BA,oBAAA,CAAU;AAAA,EAzB/C;AAyB+C,IAAA,MAAA,CAAA,IAAA,EAAA,iBAAA,CAAA;AAAA;AAAA;AAAA,EAErC,MAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOT,WAAA,CAAY,KAAA,EAAkB,EAAA,EAAY,KAAA,EAAoC;AAC7E,IAAA,KAAA,CAAM,OAAO,EAAE,CAAA;AAEf,IAAA,IAAA,CAAK,MAAA,GAAS,IAAIC,YAAA,CAAO,IAAA,EAAM,EAAA,EAAI;AAAA,MAClC,GAAG,MAAM,OAAA,EAAS,aAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAMlB,aAAA,EACC,KAAA,CAAM,OAAA,EAAS,aAAA,EAAe,iBAC3BC,uBAAA,CAAc;AAAA,KAClB,CAAA;AAKD,IAAA,IAAIC,mBAAA,CAAU,MAAM,aAAA,EAAe;AAAA,MAClC,KAAA,EAAO,KAAK,MAAA,CAAO;AAAA,KACnB,CAAA;AAAA,EACF;AACD","file":"s3-construct.cjs","sourcesContent":["import { Construct } from 'constructs';\nimport { CfnOutput, RemovalPolicy } from 'aws-cdk-lib';\nimport { Bucket, BucketProps } from 'aws-cdk-lib/aws-s3';\n\nimport { IBaseCdkConstructProps } from '../../types';\n\n/**\n * Props for BaseS3Construct\n *\n * Provides configuration for creating an S3 bucket\n * with optional overrides for bucket properties.\n */\ninterface IS3DeploymentConstructProps extends Omit<IBaseCdkConstructProps<{\n\t/** Configuration options for the S3 bucket */\n\treadonly bucketOptions?: BucketProps;\n}>, 'appName' | 'stackName'> { }\n\n/**\n * CDK construct for S3 bucket\n *\n * Responsibilities:\n * - Creates an S3 bucket with configurable options\n * - Applies a default removal policy if not provided\n * - Exposes the bucket ARN as a CloudFormation output\n */\nexport class BaseS3Construct extends Construct {\n\t/** The created S3 bucket instance */\n\treadonly bucket: Bucket;\n\n\t/**\n\t * @param scope Parent construct\n\t * @param id Unique construct identifier\n\t * @param props Configuration for S3 bucket\n\t */\n\tconstructor(scope: Construct, id: string, props: IS3DeploymentConstructProps) {\n\t\tsuper(scope, id);\n\n\t\tthis.bucket = new Bucket(this, id, {\n\t\t\t...props.options?.bucketOptions,\n\n\t\t\t/**\n\t\t\t * Removal policy applied to the bucket\n\t\t\t * Defaults to DESTROY if not explicitly defined\n\t\t\t */\n\t\t\tremovalPolicy:\n\t\t\t\tprops.options?.bucketOptions?.removalPolicy\n\t\t\t\t|| RemovalPolicy.DESTROY\n\t\t});\n\n\t\t/**\n\t\t * CloudFormation output exposing the S3 bucket ARN\n\t\t */\n\t\tnew CfnOutput(this, 'S3BucketArn', {\n\t\t\tvalue: this.bucket.bucketArn\n\t\t});\n\t}\n}"]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Construct } from 'constructs';
|
|
2
|
+
import { Bucket, BucketProps } from 'aws-cdk-lib/aws-s3';
|
|
3
|
+
import { IBaseCdkConstructProps } from '../../types/index.cjs';
|
|
4
|
+
import '@incloodsolutions/toolkit';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Props for BaseS3Construct
|
|
8
|
+
*
|
|
9
|
+
* Provides configuration for creating an S3 bucket
|
|
10
|
+
* with optional overrides for bucket properties.
|
|
11
|
+
*/
|
|
12
|
+
interface IS3DeploymentConstructProps extends Omit<IBaseCdkConstructProps<{
|
|
13
|
+
/** Configuration options for the S3 bucket */
|
|
14
|
+
readonly bucketOptions?: BucketProps;
|
|
15
|
+
}>, 'appName' | 'stackName'> {
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* CDK construct for S3 bucket
|
|
19
|
+
*
|
|
20
|
+
* Responsibilities:
|
|
21
|
+
* - Creates an S3 bucket with configurable options
|
|
22
|
+
* - Applies a default removal policy if not provided
|
|
23
|
+
* - Exposes the bucket ARN as a CloudFormation output
|
|
24
|
+
*/
|
|
25
|
+
declare class BaseS3Construct extends Construct {
|
|
26
|
+
/** The created S3 bucket instance */
|
|
27
|
+
readonly bucket: Bucket;
|
|
28
|
+
/**
|
|
29
|
+
* @param scope Parent construct
|
|
30
|
+
* @param id Unique construct identifier
|
|
31
|
+
* @param props Configuration for S3 bucket
|
|
32
|
+
*/
|
|
33
|
+
constructor(scope: Construct, id: string, props: IS3DeploymentConstructProps);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export { BaseS3Construct };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Construct } from 'constructs';
|
|
2
|
+
import { Bucket, BucketProps } from 'aws-cdk-lib/aws-s3';
|
|
3
|
+
import { IBaseCdkConstructProps } from '../../types/index.js';
|
|
4
|
+
import '@incloodsolutions/toolkit';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Props for BaseS3Construct
|
|
8
|
+
*
|
|
9
|
+
* Provides configuration for creating an S3 bucket
|
|
10
|
+
* with optional overrides for bucket properties.
|
|
11
|
+
*/
|
|
12
|
+
interface IS3DeploymentConstructProps extends Omit<IBaseCdkConstructProps<{
|
|
13
|
+
/** Configuration options for the S3 bucket */
|
|
14
|
+
readonly bucketOptions?: BucketProps;
|
|
15
|
+
}>, 'appName' | 'stackName'> {
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* CDK construct for S3 bucket
|
|
19
|
+
*
|
|
20
|
+
* Responsibilities:
|
|
21
|
+
* - Creates an S3 bucket with configurable options
|
|
22
|
+
* - Applies a default removal policy if not provided
|
|
23
|
+
* - Exposes the bucket ARN as a CloudFormation output
|
|
24
|
+
*/
|
|
25
|
+
declare class BaseS3Construct extends Construct {
|
|
26
|
+
/** The created S3 bucket instance */
|
|
27
|
+
readonly bucket: Bucket;
|
|
28
|
+
/**
|
|
29
|
+
* @param scope Parent construct
|
|
30
|
+
* @param id Unique construct identifier
|
|
31
|
+
* @param props Configuration for S3 bucket
|
|
32
|
+
*/
|
|
33
|
+
constructor(scope: Construct, id: string, props: IS3DeploymentConstructProps);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export { BaseS3Construct };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Construct } from 'constructs';
|
|
2
|
+
import { RemovalPolicy, CfnOutput } from 'aws-cdk-lib';
|
|
3
|
+
import { Bucket } from 'aws-cdk-lib/aws-s3';
|
|
4
|
+
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
+
var BaseS3Construct = class extends Construct {
|
|
8
|
+
static {
|
|
9
|
+
__name(this, "BaseS3Construct");
|
|
10
|
+
}
|
|
11
|
+
/** The created S3 bucket instance */
|
|
12
|
+
bucket;
|
|
13
|
+
/**
|
|
14
|
+
* @param scope Parent construct
|
|
15
|
+
* @param id Unique construct identifier
|
|
16
|
+
* @param props Configuration for S3 bucket
|
|
17
|
+
*/
|
|
18
|
+
constructor(scope, id, props) {
|
|
19
|
+
super(scope, id);
|
|
20
|
+
this.bucket = new Bucket(this, id, {
|
|
21
|
+
...props.options?.bucketOptions,
|
|
22
|
+
/**
|
|
23
|
+
* Removal policy applied to the bucket
|
|
24
|
+
* Defaults to DESTROY if not explicitly defined
|
|
25
|
+
*/
|
|
26
|
+
removalPolicy: props.options?.bucketOptions?.removalPolicy || RemovalPolicy.DESTROY
|
|
27
|
+
});
|
|
28
|
+
new CfnOutput(this, "S3BucketArn", {
|
|
29
|
+
value: this.bucket.bucketArn
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export { BaseS3Construct };
|
|
35
|
+
//# sourceMappingURL=s3-construct.js.map
|
|
36
|
+
//# sourceMappingURL=s3-construct.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/aws/cdk/constructs/s3-construct.ts"],"names":[],"mappings":";;;;;;AAyBO,IAAM,eAAA,GAAN,cAA8B,SAAA,CAAU;AAAA,EAzB/C;AAyB+C,IAAA,MAAA,CAAA,IAAA,EAAA,iBAAA,CAAA;AAAA;AAAA;AAAA,EAErC,MAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOT,WAAA,CAAY,KAAA,EAAkB,EAAA,EAAY,KAAA,EAAoC;AAC7E,IAAA,KAAA,CAAM,OAAO,EAAE,CAAA;AAEf,IAAA,IAAA,CAAK,MAAA,GAAS,IAAI,MAAA,CAAO,IAAA,EAAM,EAAA,EAAI;AAAA,MAClC,GAAG,MAAM,OAAA,EAAS,aAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAMlB,aAAA,EACC,KAAA,CAAM,OAAA,EAAS,aAAA,EAAe,iBAC3B,aAAA,CAAc;AAAA,KAClB,CAAA;AAKD,IAAA,IAAI,SAAA,CAAU,MAAM,aAAA,EAAe;AAAA,MAClC,KAAA,EAAO,KAAK,MAAA,CAAO;AAAA,KACnB,CAAA;AAAA,EACF;AACD","file":"s3-construct.js","sourcesContent":["import { Construct } from 'constructs';\nimport { CfnOutput, RemovalPolicy } from 'aws-cdk-lib';\nimport { Bucket, BucketProps } from 'aws-cdk-lib/aws-s3';\n\nimport { IBaseCdkConstructProps } from '../../types';\n\n/**\n * Props for BaseS3Construct\n *\n * Provides configuration for creating an S3 bucket\n * with optional overrides for bucket properties.\n */\ninterface IS3DeploymentConstructProps extends Omit<IBaseCdkConstructProps<{\n\t/** Configuration options for the S3 bucket */\n\treadonly bucketOptions?: BucketProps;\n}>, 'appName' | 'stackName'> { }\n\n/**\n * CDK construct for S3 bucket\n *\n * Responsibilities:\n * - Creates an S3 bucket with configurable options\n * - Applies a default removal policy if not provided\n * - Exposes the bucket ARN as a CloudFormation output\n */\nexport class BaseS3Construct extends Construct {\n\t/** The created S3 bucket instance */\n\treadonly bucket: Bucket;\n\n\t/**\n\t * @param scope Parent construct\n\t * @param id Unique construct identifier\n\t * @param props Configuration for S3 bucket\n\t */\n\tconstructor(scope: Construct, id: string, props: IS3DeploymentConstructProps) {\n\t\tsuper(scope, id);\n\n\t\tthis.bucket = new Bucket(this, id, {\n\t\t\t...props.options?.bucketOptions,\n\n\t\t\t/**\n\t\t\t * Removal policy applied to the bucket\n\t\t\t * Defaults to DESTROY if not explicitly defined\n\t\t\t */\n\t\t\tremovalPolicy:\n\t\t\t\tprops.options?.bucketOptions?.removalPolicy\n\t\t\t\t|| RemovalPolicy.DESTROY\n\t\t});\n\n\t\t/**\n\t\t * CloudFormation output exposing the S3 bucket ARN\n\t\t */\n\t\tnew CfnOutput(this, 'S3BucketArn', {\n\t\t\tvalue: this.bucket.bucketArn\n\t\t});\n\t}\n}"]}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var constructs = require('constructs');
|
|
4
|
+
var awsCloudfrontOrigins = require('aws-cdk-lib/aws-cloudfront-origins');
|
|
5
|
+
var awsS3Deployment = require('aws-cdk-lib/aws-s3-deployment');
|
|
6
|
+
var toolkit = require('@incloodsolutions/toolkit');
|
|
7
|
+
var awsCdkLib = require('aws-cdk-lib');
|
|
8
|
+
var awsS3 = require('aws-cdk-lib/aws-s3');
|
|
9
|
+
var awsCloudfront = require('aws-cdk-lib/aws-cloudfront');
|
|
10
|
+
|
|
11
|
+
var __defProp = Object.defineProperty;
|
|
12
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
13
|
+
var BaseS3Construct = class extends constructs.Construct {
|
|
14
|
+
static {
|
|
15
|
+
__name(this, "BaseS3Construct");
|
|
16
|
+
}
|
|
17
|
+
/** The created S3 bucket instance */
|
|
18
|
+
bucket;
|
|
19
|
+
/**
|
|
20
|
+
* @param scope Parent construct
|
|
21
|
+
* @param id Unique construct identifier
|
|
22
|
+
* @param props Configuration for S3 bucket
|
|
23
|
+
*/
|
|
24
|
+
constructor(scope, id, props) {
|
|
25
|
+
super(scope, id);
|
|
26
|
+
this.bucket = new awsS3.Bucket(this, id, {
|
|
27
|
+
...props.options?.bucketOptions,
|
|
28
|
+
/**
|
|
29
|
+
* Removal policy applied to the bucket
|
|
30
|
+
* Defaults to DESTROY if not explicitly defined
|
|
31
|
+
*/
|
|
32
|
+
removalPolicy: props.options?.bucketOptions?.removalPolicy || awsCdkLib.RemovalPolicy.DESTROY
|
|
33
|
+
});
|
|
34
|
+
new awsCdkLib.CfnOutput(this, "S3BucketArn", {
|
|
35
|
+
value: this.bucket.bucketArn
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
var BaseCloudfrontConstruct = class extends constructs.Construct {
|
|
40
|
+
static {
|
|
41
|
+
__name(this, "BaseCloudfrontConstruct");
|
|
42
|
+
}
|
|
43
|
+
/** The created CloudFront distribution instance */
|
|
44
|
+
distribution;
|
|
45
|
+
/**
|
|
46
|
+
* @param scope Parent construct
|
|
47
|
+
* @param id Unique construct identifier
|
|
48
|
+
* @param props Configuration for CloudFront distribution
|
|
49
|
+
*/
|
|
50
|
+
constructor(scope, id, props) {
|
|
51
|
+
super(scope, id);
|
|
52
|
+
this.distribution = new awsCloudfront.Distribution(this, id, {
|
|
53
|
+
...props.options?.cloudfrontOptions,
|
|
54
|
+
/**
|
|
55
|
+
* Default behaviour configuration
|
|
56
|
+
* Enforces HTTPS if not explicitly defined
|
|
57
|
+
*/
|
|
58
|
+
defaultBehavior: {
|
|
59
|
+
...props.options?.cloudfrontOptions?.defaultBehavior,
|
|
60
|
+
viewerProtocolPolicy: props.options?.cloudfrontOptions?.defaultBehavior?.viewerProtocolPolicy || awsCloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS
|
|
61
|
+
},
|
|
62
|
+
/**
|
|
63
|
+
* Error response configuration
|
|
64
|
+
*
|
|
65
|
+
* Adds SPA-friendly fallbacks:
|
|
66
|
+
* - 400, 403, 404 responses are redirected to index.html
|
|
67
|
+
*/
|
|
68
|
+
errorResponses: [
|
|
69
|
+
...props.options?.cloudfrontOptions?.errorResponses || [],
|
|
70
|
+
/** Handle 400 errors */
|
|
71
|
+
{
|
|
72
|
+
httpStatus: 400,
|
|
73
|
+
responseHttpStatus: 200,
|
|
74
|
+
responsePagePath: "/index.html",
|
|
75
|
+
ttl: awsCdkLib.Duration.days(1)
|
|
76
|
+
},
|
|
77
|
+
/** Handle 403 errors */
|
|
78
|
+
{
|
|
79
|
+
httpStatus: 403,
|
|
80
|
+
responseHttpStatus: 200,
|
|
81
|
+
responsePagePath: "/index.html",
|
|
82
|
+
ttl: awsCdkLib.Duration.days(1)
|
|
83
|
+
},
|
|
84
|
+
/** Handle 404 errors */
|
|
85
|
+
{
|
|
86
|
+
httpStatus: 404,
|
|
87
|
+
responseHttpStatus: 200,
|
|
88
|
+
responsePagePath: "/index.html",
|
|
89
|
+
ttl: awsCdkLib.Duration.days(1)
|
|
90
|
+
}
|
|
91
|
+
]
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
// src/aws/cdk/constructs/s3-deployment-construct.ts
|
|
97
|
+
var BaseS3DeploymentConstruct = class extends constructs.Construct {
|
|
98
|
+
static {
|
|
99
|
+
__name(this, "BaseS3DeploymentConstruct");
|
|
100
|
+
}
|
|
101
|
+
/** The created or provided S3 bucket */
|
|
102
|
+
bucket;
|
|
103
|
+
/** The created CloudFront distribution */
|
|
104
|
+
distribution;
|
|
105
|
+
/** S3 bucket deployment instance */
|
|
106
|
+
bucketDeployment;
|
|
107
|
+
/**
|
|
108
|
+
* @param scope Parent construct
|
|
109
|
+
* @param id Unique construct identifier
|
|
110
|
+
* @param props Configuration for bucket, distribution, and deployment
|
|
111
|
+
*/
|
|
112
|
+
constructor(scope, id, props) {
|
|
113
|
+
super(scope, id);
|
|
114
|
+
if (!props.options?.cloudfrontOptions?.defaultBehavior?.origin && !props?.withS3Bucket && props.withCloudfront) {
|
|
115
|
+
throw new toolkit.CustomException("Cloudfront distribution S3_Bucket origins must be defined!");
|
|
116
|
+
}
|
|
117
|
+
if (!props.options?.bucketDeploymentOptions?.destinationBucket && !props?.withS3Bucket) {
|
|
118
|
+
throw new toolkit.CustomException("Deployment S3_Bucket destination must be defined!");
|
|
119
|
+
}
|
|
120
|
+
if (props?.withS3Bucket) {
|
|
121
|
+
this.bucket = new BaseS3Construct(this, "bucket", {
|
|
122
|
+
enableDebug: props.enableDebug,
|
|
123
|
+
options: { bucketOptions: props.options?.bucketOptions }
|
|
124
|
+
}).bucket;
|
|
125
|
+
}
|
|
126
|
+
if (props?.withCloudfront) {
|
|
127
|
+
const s3Origin = props.options?.cloudfrontOptions?.defaultBehavior?.origin || awsCloudfrontOrigins.S3BucketOrigin.withOriginAccessControl(this.bucket);
|
|
128
|
+
this.distribution = new BaseCloudfrontConstruct(this, "distribution", {
|
|
129
|
+
enableDebug: props.enableDebug,
|
|
130
|
+
options: {
|
|
131
|
+
cloudfrontOptions: {
|
|
132
|
+
...props.options?.cloudfrontOptions,
|
|
133
|
+
/**
|
|
134
|
+
* Map additional behaviors and ensure origin is assigned
|
|
135
|
+
*/
|
|
136
|
+
additionalBehaviors: Object.entries(props.options?.cloudfrontOptions?.additionalBehaviors || {}).reduce((behavior, [pattern, behaviorOptions]) => {
|
|
137
|
+
behavior[pattern] = {
|
|
138
|
+
...behaviorOptions,
|
|
139
|
+
origin: behaviorOptions.origin || s3Origin
|
|
140
|
+
};
|
|
141
|
+
return behavior;
|
|
142
|
+
}, {}),
|
|
143
|
+
/**
|
|
144
|
+
* Default behavior configuration
|
|
145
|
+
*/
|
|
146
|
+
defaultBehavior: {
|
|
147
|
+
...props.options?.cloudfrontOptions?.defaultBehavior,
|
|
148
|
+
origin: s3Origin
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}).distribution;
|
|
153
|
+
}
|
|
154
|
+
this.bucketDeployment = new awsS3Deployment.BucketDeployment(this, "deployment", {
|
|
155
|
+
...props.options?.bucketDeploymentOptions,
|
|
156
|
+
/** Target distribution for cache invalidation */
|
|
157
|
+
distribution: props.options?.bucketDeploymentOptions?.distribution || this.distribution,
|
|
158
|
+
/** Paths to invalidate after deployment */
|
|
159
|
+
distributionPaths: props.options?.bucketDeploymentOptions?.distributionPaths || ["/*"],
|
|
160
|
+
/** Destination S3 bucket */
|
|
161
|
+
destinationBucket: props.options?.bucketDeploymentOptions?.destinationBucket || this.bucket
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
exports.BaseS3DeploymentConstruct = BaseS3DeploymentConstruct;
|
|
167
|
+
//# sourceMappingURL=s3-deployment-construct.cjs.map
|
|
168
|
+
//# sourceMappingURL=s3-deployment-construct.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/aws/cdk/constructs/s3-construct.ts","../../../../src/aws/cdk/constructs/cloudfront-construct.ts","../../../../src/aws/cdk/constructs/s3-deployment-construct.ts"],"names":["Construct","Bucket","RemovalPolicy","CfnOutput","Distribution","ViewerProtocolPolicy","Duration","CustomException","S3BucketOrigin","BucketDeployment"],"mappings":"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","file":"s3-deployment-construct.cjs","sourcesContent":["import { Construct } from 'constructs';\nimport { CfnOutput, RemovalPolicy } from 'aws-cdk-lib';\nimport { Bucket, BucketProps } from 'aws-cdk-lib/aws-s3';\n\nimport { IBaseCdkConstructProps } from '../../types';\n\n/**\n * Props for BaseS3Construct\n *\n * Provides configuration for creating an S3 bucket\n * with optional overrides for bucket properties.\n */\ninterface IS3DeploymentConstructProps extends Omit<IBaseCdkConstructProps<{\n\t/** Configuration options for the S3 bucket */\n\treadonly bucketOptions?: BucketProps;\n}>, 'appName' | 'stackName'> { }\n\n/**\n * CDK construct for S3 bucket\n *\n * Responsibilities:\n * - Creates an S3 bucket with configurable options\n * - Applies a default removal policy if not provided\n * - Exposes the bucket ARN as a CloudFormation output\n */\nexport class BaseS3Construct extends Construct {\n\t/** The created S3 bucket instance */\n\treadonly bucket: Bucket;\n\n\t/**\n\t * @param scope Parent construct\n\t * @param id Unique construct identifier\n\t * @param props Configuration for S3 bucket\n\t */\n\tconstructor(scope: Construct, id: string, props: IS3DeploymentConstructProps) {\n\t\tsuper(scope, id);\n\n\t\tthis.bucket = new Bucket(this, id, {\n\t\t\t...props.options?.bucketOptions,\n\n\t\t\t/**\n\t\t\t * Removal policy applied to the bucket\n\t\t\t * Defaults to DESTROY if not explicitly defined\n\t\t\t */\n\t\t\tremovalPolicy:\n\t\t\t\tprops.options?.bucketOptions?.removalPolicy\n\t\t\t\t|| RemovalPolicy.DESTROY\n\t\t});\n\n\t\t/**\n\t\t * CloudFormation output exposing the S3 bucket ARN\n\t\t */\n\t\tnew CfnOutput(this, 'S3BucketArn', {\n\t\t\tvalue: this.bucket.bucketArn\n\t\t});\n\t}\n}","import { Construct } from 'constructs';\nimport { Duration } from 'aws-cdk-lib';\nimport { Distribution, DistributionProps, ViewerProtocolPolicy } from 'aws-cdk-lib/aws-cloudfront';\n\nimport { IBaseCdkConstructProps } from '../../types';\n\n/**\n * Props for BaseCloudfrontConstruct\n *\n * Provides configuration for creating a CloudFront distribution\n * with optional overrides for default behaviour and error handling.\n */\ninterface ICloudfrontConstructProps extends Omit<IBaseCdkConstructProps<{\n\t/** Partial configuration for the CloudFront distribution */\n\treadonly cloudfrontOptions: Partial<DistributionProps>;\n}>, 'appName' | 'stage' | 'stackName'> { }\n\n/**\n * CDK construct for CloudFront distribution\n *\n * Responsibilities:\n * - Creates a CloudFront distribution with configurable options\n * - Enforces HTTPS redirection by default\n * - Adds fallback error responses for SPA routing (400, 403, 404 → index.html)\n */\nexport class BaseCloudfrontConstruct extends Construct {\n\t/** The created CloudFront distribution instance */\n\treadonly distribution: Distribution;\n\n\t/**\n\t * @param scope Parent construct\n\t * @param id Unique construct identifier\n\t * @param props Configuration for CloudFront distribution\n\t */\n\tconstructor(scope: Construct, id: string, props: ICloudfrontConstructProps) {\n\t\tsuper(scope, id);\n\n\t\tthis.distribution = new Distribution(this, id, {\n\t\t\t...props.options?.cloudfrontOptions,\n\n\t\t\t/**\n\t\t\t * Default behaviour configuration\n\t\t\t * Enforces HTTPS if not explicitly defined\n\t\t\t */\n\t\t\tdefaultBehavior: {\n\t\t\t\t...props.options?.cloudfrontOptions?.defaultBehavior,\n\t\t\t\tviewerProtocolPolicy:\n\t\t\t\t\tprops.options?.cloudfrontOptions?.defaultBehavior?.viewerProtocolPolicy\n\t\t\t\t\t|| ViewerProtocolPolicy.REDIRECT_TO_HTTPS\n\t\t\t},\n\n\t\t\t/**\n\t\t\t * Error response configuration\n\t\t\t *\n\t\t\t * Adds SPA-friendly fallbacks:\n\t\t\t * - 400, 403, 404 responses are redirected to index.html\n\t\t\t */\n\t\t\terrorResponses: [\n\t\t\t\t...props.options?.cloudfrontOptions?.errorResponses || [],\n\n\t\t\t\t/** Handle 400 errors */\n\t\t\t\t{\n\t\t\t\t\thttpStatus: 400,\n\t\t\t\t\tresponseHttpStatus: 200,\n\t\t\t\t\tresponsePagePath: '/index.html',\n\t\t\t\t\tttl: Duration.days(1)\n\t\t\t\t},\n\n\t\t\t\t/** Handle 403 errors */\n\t\t\t\t{\n\t\t\t\t\thttpStatus: 403,\n\t\t\t\t\tresponseHttpStatus: 200,\n\t\t\t\t\tresponsePagePath: '/index.html',\n\t\t\t\t\tttl: Duration.days(1)\n\t\t\t\t},\n\n\t\t\t\t/** Handle 404 errors */\n\t\t\t\t{\n\t\t\t\t\thttpStatus: 404,\n\t\t\t\t\tresponseHttpStatus: 200,\n\t\t\t\t\tresponsePagePath: '/index.html',\n\t\t\t\t\tttl: Duration.days(1)\n\t\t\t\t},\n\t\t\t],\n\t\t});\n\t}\n}","import { Construct } from 'constructs';\nimport { Bucket, BucketProps } from 'aws-cdk-lib/aws-s3';\nimport { S3BucketOrigin } from 'aws-cdk-lib/aws-cloudfront-origins';\nimport { BucketDeployment, BucketDeploymentProps } from 'aws-cdk-lib/aws-s3-deployment';\nimport { BehaviorOptions, Distribution, DistributionProps } from 'aws-cdk-lib/aws-cloudfront';\n\nimport { ObjectType, CustomException } from '@incloodsolutions/toolkit';\n\nimport { BaseS3Construct } from './s3-construct';\nimport { BaseCloudfrontConstruct } from './cloudfront-construct';\n\nimport { IBaseCdkConstructProps } from '../../types';\n\n/**\n * Props for BaseS3DeploymentConstruct\n *\n * Provides configuration for:\n * - Optional S3 bucket creation\n * - Optional CloudFront distribution\n * - S3 bucket deployment\n */\ninterface IS3DeploymentConstructProps extends Omit<IBaseCdkConstructProps<{\n\t/** Configuration options for S3 bucket */\n\treadonly bucketOptions?: BucketProps;\n\n\t/**\n\t * Configuration options for CloudFront distribution\n\t *\n\t * Note:\n\t * - `additionalBehaviors` supports dynamic route mappings\n\t * - Origins are automatically resolved if not provided\n\t */\n\treadonly cloudfrontOptions?: Partial<Omit<DistributionProps, 'additionalBehaviors'>> & {\n\t\treadonly additionalBehaviors?: ObjectType<Partial<BehaviorOptions>, string>;\n\t};\n\n\t/**\n\t * Configuration for S3 bucket deployment\n\t *\n\t * Note:\n\t * - `sources` is required\n\t * - `destinationBucket` can be auto-resolved\n\t */\n\treadonly bucketDeploymentOptions: Omit<Partial<BucketDeploymentProps>, 'sources'> & Pick<BucketDeploymentProps, 'sources'>;\n}>, 'appName' | 'stackName'> {\n\t/** Whether to create a new S3 bucket */\n\treadonly withS3Bucket?: boolean;\n\n\t/** Whether to create a CloudFront distribution */\n\treadonly withCloudfront?: boolean;\n}\n\n/**\n * CDK construct for S3 deployment with optional CloudFront integration\n *\n * Responsibilities:\n * - Optionally creates an S3 bucket\n * - Optionally creates a CloudFront distribution with S3 origin\n * - Deploys assets to S3 bucket\n * - Configures CloudFront invalidation paths\n *\n * Behaviour:\n * - Automatically links S3 bucket as CloudFront origin when enabled\n * - Resolves destination bucket and distribution if not explicitly provided\n * - Throws when required dependencies are missing\n */\nexport class BaseS3DeploymentConstruct extends Construct {\n\t/** The created or provided S3 bucket */\n\treadonly bucket: Bucket;\n\n\t/** The created CloudFront distribution */\n\treadonly distribution: Distribution;\n\n\t/** S3 bucket deployment instance */\n\treadonly bucketDeployment: BucketDeployment;\n\n\t/**\n\t * @param scope Parent construct\n\t * @param id Unique construct identifier\n\t * @param props Configuration for bucket, distribution, and deployment\n\t */\n\tconstructor(scope: Construct, id: string, props: IS3DeploymentConstructProps) {\n\t\tsuper(scope, id);\n\n\t\t/**\n\t\t * Validate CloudFront origin requirements\n\t\t */\n\t\tif ((!props.options?.cloudfrontOptions?.defaultBehavior?.origin && !props?.withS3Bucket) && props.withCloudfront) {\n\t\t\tthrow new CustomException('Cloudfront distribution S3_Bucket origins must be defined!');\n\t\t}\n\n\t\t/**\n\t\t * Validate deployment destination requirements\n\t\t */\n\t\tif (!props.options?.bucketDeploymentOptions?.destinationBucket && !props?.withS3Bucket) {\n\t\t\tthrow new CustomException('Deployment S3_Bucket destination must be defined!');\n\t\t}\n\n\t\t/**\n\t\t * Create S3 bucket if enabled\n\t\t */\n\t\tif (props?.withS3Bucket) {\n\t\t\tthis.bucket = new BaseS3Construct(this, 'bucket', {\n\t\t\t\tenableDebug: props.enableDebug,\n\t\t\t\toptions: { bucketOptions: props.options?.bucketOptions }\n\t\t\t}).bucket;\n\t\t}\n\n\t\t/**\n\t\t * Create CloudFront distribution if enabled\n\t\t */\n\t\tif (props?.withCloudfront) {\n\n\t\t\t/**\n\t\t\t * Resolve S3 origin for distribution\n\t\t\t */\n\t\t\tconst s3Origin =\n\t\t\t\tprops.options?.cloudfrontOptions?.defaultBehavior?.origin\n\t\t\t\t|| S3BucketOrigin.withOriginAccessControl(this.bucket);\n\n\t\t\tthis.distribution = new BaseCloudfrontConstruct(this, 'distribution', {\n\t\t\t\tenableDebug: props.enableDebug,\n\t\t\t\toptions: {\n\t\t\t\t\tcloudfrontOptions: {\n\t\t\t\t\t\t...props.options?.cloudfrontOptions,\n\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * Map additional behaviors and ensure origin is assigned\n\t\t\t\t\t\t */\n\t\t\t\t\t\tadditionalBehaviors: Object.entries(props.options?.cloudfrontOptions?.additionalBehaviors || {})\n\t\t\t\t\t\t\t.reduce((behavior, [pattern, behaviorOptions]) => {\n\t\t\t\t\t\t\t\tbehavior[pattern] = {\n\t\t\t\t\t\t\t\t\t...behaviorOptions,\n\t\t\t\t\t\t\t\t\torigin: behaviorOptions.origin || s3Origin\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\treturn behavior;\n\t\t\t\t\t\t\t}, {} as typeof props.options.cloudfrontOptions.additionalBehaviors) as ObjectType<BehaviorOptions>,\n\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * Default behavior configuration\n\t\t\t\t\t\t */\n\t\t\t\t\t\tdefaultBehavior: {\n\t\t\t\t\t\t\t...props.options?.cloudfrontOptions?.defaultBehavior,\n\t\t\t\t\t\t\torigin: s3Origin\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t}).distribution;\n\t\t}\n\n\t\t/**\n\t\t * Deploy assets to S3 bucket\n\t\t *\n\t\t * Automatically resolves:\n\t\t * - Destination bucket\n\t\t * - CloudFront distribution\n\t\t * - Invalidation paths\n\t\t */\n\t\tthis.bucketDeployment = new BucketDeployment(this, 'deployment', {\n\t\t\t...props.options?.bucketDeploymentOptions,\n\n\t\t\t/** Target distribution for cache invalidation */\n\t\t\tdistribution:\n\t\t\t\tprops.options?.bucketDeploymentOptions?.distribution\n\t\t\t\t|| this.distribution,\n\n\t\t\t/** Paths to invalidate after deployment */\n\t\t\tdistributionPaths:\n\t\t\t\tprops.options?.bucketDeploymentOptions?.distributionPaths\n\t\t\t\t|| ['/*'],\n\n\t\t\t/** Destination S3 bucket */\n\t\t\tdestinationBucket:\n\t\t\t\tprops.options?.bucketDeploymentOptions?.destinationBucket\n\t\t\t\t|| this.bucket\n\t\t} as BucketDeploymentProps);\n\t}\n}"]}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Construct } from 'constructs';
|
|
2
|
+
import { Bucket, BucketProps } from 'aws-cdk-lib/aws-s3';
|
|
3
|
+
import { BucketDeployment, BucketDeploymentProps } from 'aws-cdk-lib/aws-s3-deployment';
|
|
4
|
+
import { Distribution, DistributionProps, BehaviorOptions } from 'aws-cdk-lib/aws-cloudfront';
|
|
5
|
+
import { ObjectType } from '@incloodsolutions/toolkit';
|
|
6
|
+
import { IBaseCdkConstructProps } from '../../types/index.cjs';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Props for BaseS3DeploymentConstruct
|
|
10
|
+
*
|
|
11
|
+
* Provides configuration for:
|
|
12
|
+
* - Optional S3 bucket creation
|
|
13
|
+
* - Optional CloudFront distribution
|
|
14
|
+
* - S3 bucket deployment
|
|
15
|
+
*/
|
|
16
|
+
interface IS3DeploymentConstructProps extends Omit<IBaseCdkConstructProps<{
|
|
17
|
+
/** Configuration options for S3 bucket */
|
|
18
|
+
readonly bucketOptions?: BucketProps;
|
|
19
|
+
/**
|
|
20
|
+
* Configuration options for CloudFront distribution
|
|
21
|
+
*
|
|
22
|
+
* Note:
|
|
23
|
+
* - `additionalBehaviors` supports dynamic route mappings
|
|
24
|
+
* - Origins are automatically resolved if not provided
|
|
25
|
+
*/
|
|
26
|
+
readonly cloudfrontOptions?: Partial<Omit<DistributionProps, 'additionalBehaviors'>> & {
|
|
27
|
+
readonly additionalBehaviors?: ObjectType<Partial<BehaviorOptions>, string>;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Configuration for S3 bucket deployment
|
|
31
|
+
*
|
|
32
|
+
* Note:
|
|
33
|
+
* - `sources` is required
|
|
34
|
+
* - `destinationBucket` can be auto-resolved
|
|
35
|
+
*/
|
|
36
|
+
readonly bucketDeploymentOptions: Omit<Partial<BucketDeploymentProps>, 'sources'> & Pick<BucketDeploymentProps, 'sources'>;
|
|
37
|
+
}>, 'appName' | 'stackName'> {
|
|
38
|
+
/** Whether to create a new S3 bucket */
|
|
39
|
+
readonly withS3Bucket?: boolean;
|
|
40
|
+
/** Whether to create a CloudFront distribution */
|
|
41
|
+
readonly withCloudfront?: boolean;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* CDK construct for S3 deployment with optional CloudFront integration
|
|
45
|
+
*
|
|
46
|
+
* Responsibilities:
|
|
47
|
+
* - Optionally creates an S3 bucket
|
|
48
|
+
* - Optionally creates a CloudFront distribution with S3 origin
|
|
49
|
+
* - Deploys assets to S3 bucket
|
|
50
|
+
* - Configures CloudFront invalidation paths
|
|
51
|
+
*
|
|
52
|
+
* Behaviour:
|
|
53
|
+
* - Automatically links S3 bucket as CloudFront origin when enabled
|
|
54
|
+
* - Resolves destination bucket and distribution if not explicitly provided
|
|
55
|
+
* - Throws when required dependencies are missing
|
|
56
|
+
*/
|
|
57
|
+
declare class BaseS3DeploymentConstruct extends Construct {
|
|
58
|
+
/** The created or provided S3 bucket */
|
|
59
|
+
readonly bucket: Bucket;
|
|
60
|
+
/** The created CloudFront distribution */
|
|
61
|
+
readonly distribution: Distribution;
|
|
62
|
+
/** S3 bucket deployment instance */
|
|
63
|
+
readonly bucketDeployment: BucketDeployment;
|
|
64
|
+
/**
|
|
65
|
+
* @param scope Parent construct
|
|
66
|
+
* @param id Unique construct identifier
|
|
67
|
+
* @param props Configuration for bucket, distribution, and deployment
|
|
68
|
+
*/
|
|
69
|
+
constructor(scope: Construct, id: string, props: IS3DeploymentConstructProps);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export { BaseS3DeploymentConstruct };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Construct } from 'constructs';
|
|
2
|
+
import { Bucket, BucketProps } from 'aws-cdk-lib/aws-s3';
|
|
3
|
+
import { BucketDeployment, BucketDeploymentProps } from 'aws-cdk-lib/aws-s3-deployment';
|
|
4
|
+
import { Distribution, DistributionProps, BehaviorOptions } from 'aws-cdk-lib/aws-cloudfront';
|
|
5
|
+
import { ObjectType } from '@incloodsolutions/toolkit';
|
|
6
|
+
import { IBaseCdkConstructProps } from '../../types/index.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Props for BaseS3DeploymentConstruct
|
|
10
|
+
*
|
|
11
|
+
* Provides configuration for:
|
|
12
|
+
* - Optional S3 bucket creation
|
|
13
|
+
* - Optional CloudFront distribution
|
|
14
|
+
* - S3 bucket deployment
|
|
15
|
+
*/
|
|
16
|
+
interface IS3DeploymentConstructProps extends Omit<IBaseCdkConstructProps<{
|
|
17
|
+
/** Configuration options for S3 bucket */
|
|
18
|
+
readonly bucketOptions?: BucketProps;
|
|
19
|
+
/**
|
|
20
|
+
* Configuration options for CloudFront distribution
|
|
21
|
+
*
|
|
22
|
+
* Note:
|
|
23
|
+
* - `additionalBehaviors` supports dynamic route mappings
|
|
24
|
+
* - Origins are automatically resolved if not provided
|
|
25
|
+
*/
|
|
26
|
+
readonly cloudfrontOptions?: Partial<Omit<DistributionProps, 'additionalBehaviors'>> & {
|
|
27
|
+
readonly additionalBehaviors?: ObjectType<Partial<BehaviorOptions>, string>;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Configuration for S3 bucket deployment
|
|
31
|
+
*
|
|
32
|
+
* Note:
|
|
33
|
+
* - `sources` is required
|
|
34
|
+
* - `destinationBucket` can be auto-resolved
|
|
35
|
+
*/
|
|
36
|
+
readonly bucketDeploymentOptions: Omit<Partial<BucketDeploymentProps>, 'sources'> & Pick<BucketDeploymentProps, 'sources'>;
|
|
37
|
+
}>, 'appName' | 'stackName'> {
|
|
38
|
+
/** Whether to create a new S3 bucket */
|
|
39
|
+
readonly withS3Bucket?: boolean;
|
|
40
|
+
/** Whether to create a CloudFront distribution */
|
|
41
|
+
readonly withCloudfront?: boolean;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* CDK construct for S3 deployment with optional CloudFront integration
|
|
45
|
+
*
|
|
46
|
+
* Responsibilities:
|
|
47
|
+
* - Optionally creates an S3 bucket
|
|
48
|
+
* - Optionally creates a CloudFront distribution with S3 origin
|
|
49
|
+
* - Deploys assets to S3 bucket
|
|
50
|
+
* - Configures CloudFront invalidation paths
|
|
51
|
+
*
|
|
52
|
+
* Behaviour:
|
|
53
|
+
* - Automatically links S3 bucket as CloudFront origin when enabled
|
|
54
|
+
* - Resolves destination bucket and distribution if not explicitly provided
|
|
55
|
+
* - Throws when required dependencies are missing
|
|
56
|
+
*/
|
|
57
|
+
declare class BaseS3DeploymentConstruct extends Construct {
|
|
58
|
+
/** The created or provided S3 bucket */
|
|
59
|
+
readonly bucket: Bucket;
|
|
60
|
+
/** The created CloudFront distribution */
|
|
61
|
+
readonly distribution: Distribution;
|
|
62
|
+
/** S3 bucket deployment instance */
|
|
63
|
+
readonly bucketDeployment: BucketDeployment;
|
|
64
|
+
/**
|
|
65
|
+
* @param scope Parent construct
|
|
66
|
+
* @param id Unique construct identifier
|
|
67
|
+
* @param props Configuration for bucket, distribution, and deployment
|
|
68
|
+
*/
|
|
69
|
+
constructor(scope: Construct, id: string, props: IS3DeploymentConstructProps);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export { BaseS3DeploymentConstruct };
|