@dga-itc/aws-cdk-constructs 1.0.0
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 +219 -0
- package/dist/aws-cdk/constructs/acm.d.ts +28 -0
- package/dist/aws-cdk/constructs/acm.js +239 -0
- package/dist/aws-cdk/constructs/alb.d.ts +28 -0
- package/dist/aws-cdk/constructs/alb.js +304 -0
- package/dist/aws-cdk/constructs/bastion.d.ts +46 -0
- package/dist/aws-cdk/constructs/bastion.js +332 -0
- package/dist/aws-cdk/constructs/cloudfront.d.ts +45 -0
- package/dist/aws-cdk/constructs/cloudfront.js +261 -0
- package/dist/aws-cdk/constructs/ecr.d.ts +17 -0
- package/dist/aws-cdk/constructs/ecr.js +143 -0
- package/dist/aws-cdk/constructs/ecs-cluster.d.ts +21 -0
- package/dist/aws-cdk/constructs/ecs-cluster.js +124 -0
- package/dist/aws-cdk/constructs/ecs-service.d.ts +72 -0
- package/dist/aws-cdk/constructs/ecs-service.js +682 -0
- package/dist/aws-cdk/constructs/efs.d.ts +31 -0
- package/dist/aws-cdk/constructs/efs.js +241 -0
- package/dist/aws-cdk/constructs/elasticache.d.ts +35 -0
- package/dist/aws-cdk/constructs/elasticache.js +210 -0
- package/dist/aws-cdk/constructs/nacl.d.ts +37 -0
- package/dist/aws-cdk/constructs/nacl.js +88 -0
- package/dist/aws-cdk/constructs/nlb.d.ts +39 -0
- package/dist/aws-cdk/constructs/nlb.js +276 -0
- package/dist/aws-cdk/constructs/rds.d.ts +40 -0
- package/dist/aws-cdk/constructs/rds.js +320 -0
- package/dist/aws-cdk/constructs/self-signed-cert.d.ts +83 -0
- package/dist/aws-cdk/constructs/self-signed-cert.js +215 -0
- package/dist/aws-cdk/constructs/sqs.d.ts +30 -0
- package/dist/aws-cdk/constructs/sqs.js +268 -0
- package/dist/aws-cdk/constructs/vpc.d.ts +30 -0
- package/dist/aws-cdk/constructs/vpc.js +423 -0
- package/dist/aws-cdk/constructs/waf.d.ts +37 -0
- package/dist/aws-cdk/constructs/waf.js +350 -0
- package/dist/aws-cdk/interfaces/account-config.d.ts +18 -0
- package/dist/aws-cdk/interfaces/account-config.js +2 -0
- package/dist/aws-cdk/interfaces/acm-config.d.ts +94 -0
- package/dist/aws-cdk/interfaces/acm-config.js +14 -0
- package/dist/aws-cdk/interfaces/alb-config.d.ts +72 -0
- package/dist/aws-cdk/interfaces/alb-config.js +2 -0
- package/dist/aws-cdk/interfaces/bastion-config.d.ts +77 -0
- package/dist/aws-cdk/interfaces/bastion-config.js +10 -0
- package/dist/aws-cdk/interfaces/cloudfront-config.d.ts +154 -0
- package/dist/aws-cdk/interfaces/cloudfront-config.js +15 -0
- package/dist/aws-cdk/interfaces/ecr-config.d.ts +40 -0
- package/dist/aws-cdk/interfaces/ecr-config.js +2 -0
- package/dist/aws-cdk/interfaces/ecs-cluster-config.d.ts +30 -0
- package/dist/aws-cdk/interfaces/ecs-cluster-config.js +2 -0
- package/dist/aws-cdk/interfaces/ecs-service-config.d.ts +237 -0
- package/dist/aws-cdk/interfaces/ecs-service-config.js +2 -0
- package/dist/aws-cdk/interfaces/efs-config.d.ts +56 -0
- package/dist/aws-cdk/interfaces/efs-config.js +7 -0
- package/dist/aws-cdk/interfaces/elasticache-config.d.ts +56 -0
- package/dist/aws-cdk/interfaces/elasticache-config.js +7 -0
- package/dist/aws-cdk/interfaces/nacl-config.d.ts +1 -0
- package/dist/aws-cdk/interfaces/nacl-config.js +3 -0
- package/dist/aws-cdk/interfaces/nlb-config.d.ts +69 -0
- package/dist/aws-cdk/interfaces/nlb-config.js +2 -0
- package/dist/aws-cdk/interfaces/rds-config.d.ts +84 -0
- package/dist/aws-cdk/interfaces/rds-config.js +7 -0
- package/dist/aws-cdk/interfaces/sqs-config.d.ts +145 -0
- package/dist/aws-cdk/interfaces/sqs-config.js +12 -0
- package/dist/aws-cdk/interfaces/tag-config.d.ts +18 -0
- package/dist/aws-cdk/interfaces/tag-config.js +2 -0
- package/dist/aws-cdk/interfaces/vpc-config.d.ts +72 -0
- package/dist/aws-cdk/interfaces/vpc-config.js +2 -0
- package/dist/aws-cdk/interfaces/waf-config.d.ts +180 -0
- package/dist/aws-cdk/interfaces/waf-config.js +2 -0
- package/dist/aws-cdk/utils/priority-tracker.d.ts +60 -0
- package/dist/aws-cdk/utils/priority-tracker.js +131 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +55 -0
- package/dist/terraform-cdk/constructs/alb-listener-rule.d.ts +33 -0
- package/dist/terraform-cdk/constructs/alb-listener-rule.js +81 -0
- package/dist/terraform-cdk/constructs/ecs-service.d.ts +29 -0
- package/dist/terraform-cdk/constructs/ecs-service.js +238 -0
- package/dist/terraform-cdk/interfaces/ecs-service-config.d.ts +53 -0
- package/dist/terraform-cdk/interfaces/ecs-service-config.js +25 -0
- package/dist/terraform-cdk/interfaces/infrastructure-refs.d.ts +16 -0
- package/dist/terraform-cdk/interfaces/infrastructure-refs.js +8 -0
- package/dist/terraform-cdk/utils/priority-tracker.d.ts +60 -0
- package/dist/terraform-cdk/utils/priority-tracker.js +131 -0
- package/package.json +46 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export interface NlbListenerConfig {
|
|
2
|
+
/** Listener port on NLB */
|
|
3
|
+
port: number;
|
|
4
|
+
/** Protocol: TCP or TLS */
|
|
5
|
+
protocol: 'TCP' | 'TLS';
|
|
6
|
+
/** Certificate ARN - required for TLS protocol */
|
|
7
|
+
certificateArn?: string;
|
|
8
|
+
/** Port to forward to on ALB (default: same as listener port) */
|
|
9
|
+
targetPort?: number;
|
|
10
|
+
/** Custom Target Group name (max 32 chars) */
|
|
11
|
+
targetGroupName?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface NlbHealthCheckConfig {
|
|
14
|
+
/** Health check protocol (default: 'HTTP' for ALB target) */
|
|
15
|
+
protocol?: 'TCP' | 'HTTP' | 'HTTPS';
|
|
16
|
+
/** Health check path - required for HTTP/HTTPS (default: '/') */
|
|
17
|
+
path?: string;
|
|
18
|
+
/** Health check port override (default: uses target port) */
|
|
19
|
+
port?: number;
|
|
20
|
+
/** Interval in seconds (default: 30) */
|
|
21
|
+
interval?: number;
|
|
22
|
+
/** Healthy threshold count (default: 3) */
|
|
23
|
+
healthyThresholdCount?: number;
|
|
24
|
+
/** Unhealthy threshold count (default: 3) */
|
|
25
|
+
unhealthyThresholdCount?: number;
|
|
26
|
+
/** HTTP status codes to consider healthy (default: '200') e.g. '200-399' */
|
|
27
|
+
healthyHttpCodes?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface NlbSecurityConfig {
|
|
30
|
+
/** Allow from 0.0.0.0/0 on listener ports (default: true) */
|
|
31
|
+
allowFromAnywhere?: boolean;
|
|
32
|
+
/** Additional CIDRs to allow */
|
|
33
|
+
allowFromCidrs?: string[];
|
|
34
|
+
}
|
|
35
|
+
export interface NlbVpcRefSource {
|
|
36
|
+
vpcStackName: string;
|
|
37
|
+
/** ใช้ subnet ชื่ออะไร (default: 'public') */
|
|
38
|
+
subnetName?: string;
|
|
39
|
+
}
|
|
40
|
+
export interface NlbConfig {
|
|
41
|
+
stackName: string;
|
|
42
|
+
nlbName: string;
|
|
43
|
+
region?: string;
|
|
44
|
+
account?: string;
|
|
45
|
+
/** อ้างอิง Account Config name (ดู configs/accounts/) */
|
|
46
|
+
accountConfigName?: string;
|
|
47
|
+
/** Custom Security Group name (optional, removes CDK hash suffix) */
|
|
48
|
+
securityGroupName?: string;
|
|
49
|
+
/** VPC source - อ้างอิง VPC stack */
|
|
50
|
+
source: NlbVpcRefSource;
|
|
51
|
+
/** ALB stack name ที่จะเป็น target ของ NLB */
|
|
52
|
+
albStackName: string;
|
|
53
|
+
/** Listener configurations (TCP/TLS → ALB) */
|
|
54
|
+
listeners: NlbListenerConfig[];
|
|
55
|
+
/** Security configuration */
|
|
56
|
+
security?: NlbSecurityConfig;
|
|
57
|
+
/** Health check for NLB → ALB target group */
|
|
58
|
+
healthCheck?: NlbHealthCheckConfig;
|
|
59
|
+
/** Enable cross-zone load balancing (default: true) */
|
|
60
|
+
crossZoneEnabled?: boolean;
|
|
61
|
+
/** Deletion protection (default: false) */
|
|
62
|
+
deletionProtection?: boolean;
|
|
63
|
+
/** Removal policy (default: 'destroy') */
|
|
64
|
+
removalPolicy?: 'destroy' | 'retain';
|
|
65
|
+
/** อ้างอิง Tag Config name (ดู configs/tags/) */
|
|
66
|
+
tagConfigName?: string;
|
|
67
|
+
/** Tags เสริม — merge กับ tagConfigName (override ถ้า key ซ้ำ) */
|
|
68
|
+
tags?: Record<string, string>;
|
|
69
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RDS Configuration Interface
|
|
3
|
+
*
|
|
4
|
+
* สำหรับสร้าง RDS Database Instance (MySQL/MariaDB/PostgreSQL)
|
|
5
|
+
*/
|
|
6
|
+
export interface RdsVpcRefSource {
|
|
7
|
+
vpcStackName: string;
|
|
8
|
+
/** ใช้ subnet ชื่ออะไร (default: 'db') */
|
|
9
|
+
subnetName?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface RdsConfig {
|
|
12
|
+
stackName: string;
|
|
13
|
+
instanceIdentifier: string;
|
|
14
|
+
region?: string;
|
|
15
|
+
account?: string;
|
|
16
|
+
/** อ้างอิง Account Config name (ดู configs/accounts/) */
|
|
17
|
+
accountConfigName?: string;
|
|
18
|
+
/** VPC source - อ้างอิง VPC stack */
|
|
19
|
+
source: RdsVpcRefSource;
|
|
20
|
+
/** Custom Security Group name (optional) */
|
|
21
|
+
securityGroupName?: string;
|
|
22
|
+
/** Database engine: 'mysql' | 'mariadb' | 'postgres' */
|
|
23
|
+
engine: 'mysql' | 'mariadb' | 'postgres';
|
|
24
|
+
/** Engine version (e.g., '10.6' for MariaDB, '8.0' for MySQL) */
|
|
25
|
+
engineVersion: string;
|
|
26
|
+
/** Instance class (default: 'db.t3.medium') */
|
|
27
|
+
instanceClass?: string;
|
|
28
|
+
/** Allocated storage in GB (default: 20) */
|
|
29
|
+
allocatedStorage?: number;
|
|
30
|
+
/** Max allocated storage for autoscaling in GB (optional) */
|
|
31
|
+
maxAllocatedStorage?: number;
|
|
32
|
+
/** Storage type (default: 'gp3') */
|
|
33
|
+
storageType?: 'gp2' | 'gp3' | 'io1' | 'io2';
|
|
34
|
+
/** IOPS for gp3/io1/io2 (optional) */
|
|
35
|
+
iops?: number;
|
|
36
|
+
/** Storage throughput for gp3 in MiB/s (optional) */
|
|
37
|
+
storageThroughput?: number;
|
|
38
|
+
/** Database name */
|
|
39
|
+
databaseName: string;
|
|
40
|
+
/** Master username */
|
|
41
|
+
masterUsername: string;
|
|
42
|
+
/** Master password from Secrets Manager ARN */
|
|
43
|
+
masterPasswordSecretArn?: string;
|
|
44
|
+
/** Master password (plain text - not recommended, use secret) */
|
|
45
|
+
masterPassword?: string;
|
|
46
|
+
/** Enable Multi-AZ (default: true for prod) */
|
|
47
|
+
multiAz?: boolean;
|
|
48
|
+
/** Enable storage encryption (default: true) */
|
|
49
|
+
storageEncrypted?: boolean;
|
|
50
|
+
/** KMS key ARN for encryption (optional) */
|
|
51
|
+
kmsKeyArn?: string;
|
|
52
|
+
/** Enable deletion protection (default: true for prod) */
|
|
53
|
+
deletionProtection?: boolean;
|
|
54
|
+
/** Backup retention period in days (default: 7) */
|
|
55
|
+
backupRetentionPeriod?: number;
|
|
56
|
+
/** Preferred backup window (default: '03:00-04:00') */
|
|
57
|
+
preferredBackupWindow?: string;
|
|
58
|
+
/** Preferred maintenance window (default: 'sun:04:00-sun:05:00') */
|
|
59
|
+
preferredMaintenanceWindow?: string;
|
|
60
|
+
/** Enable Performance Insights (default: true) */
|
|
61
|
+
performanceInsightsEnabled?: boolean;
|
|
62
|
+
/** Performance Insights retention in days (default: 7) */
|
|
63
|
+
performanceInsightsRetention?: number;
|
|
64
|
+
/** Enable Enhanced Monitoring (default: true) */
|
|
65
|
+
enhancedMonitoringEnabled?: boolean;
|
|
66
|
+
/** Enhanced Monitoring interval in seconds (default: 60) */
|
|
67
|
+
monitoringInterval?: number;
|
|
68
|
+
/** Enable auto minor version upgrade (default: true) */
|
|
69
|
+
autoMinorVersionUpgrade?: boolean;
|
|
70
|
+
/** Enable public accessibility (default: false) */
|
|
71
|
+
publiclyAccessible?: boolean;
|
|
72
|
+
/** Port (default: 3306 for MySQL/MariaDB, 5432 for PostgreSQL) */
|
|
73
|
+
port?: number;
|
|
74
|
+
/** Parameter group family (e.g., 'mariadb10.6', 'mysql8.0', 'postgres14') */
|
|
75
|
+
parameterGroupFamily?: string;
|
|
76
|
+
/** Custom parameters */
|
|
77
|
+
parameters?: Record<string, string>;
|
|
78
|
+
/** Removal policy (default: 'retain' for data safety) */
|
|
79
|
+
removalPolicy?: 'destroy' | 'retain' | 'snapshot';
|
|
80
|
+
/** อ้างอิง Tag Config name (ดู configs/tags/) */
|
|
81
|
+
tagConfigName?: string;
|
|
82
|
+
/** Tags เสริม — merge กับ tagConfigName (override ถ้า key ซ้ำ) */
|
|
83
|
+
tags?: Record<string, string>;
|
|
84
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SQS + Dead Letter Queue Config Interface
|
|
3
|
+
*
|
|
4
|
+
* สร้าง SQS Queue พร้อม Dead Letter Queue (DLQ) อัตโนมัติ
|
|
5
|
+
*
|
|
6
|
+
* Architecture:
|
|
7
|
+
* Producer → SQS Queue → Consumer
|
|
8
|
+
* ↓ (failed messages)
|
|
9
|
+
* DLQ Queue → alarm / reprocessing
|
|
10
|
+
*/
|
|
11
|
+
export interface SqsDlqConfig {
|
|
12
|
+
/**
|
|
13
|
+
* จำนวนครั้งที่ retry ก่อนส่งเข้า DLQ
|
|
14
|
+
* (default: 3)
|
|
15
|
+
*/
|
|
16
|
+
maxReceiveCount?: number;
|
|
17
|
+
/**
|
|
18
|
+
* DLQ message retention period (วินาที)
|
|
19
|
+
* (default: 1209600 = 14 วัน — maximum)
|
|
20
|
+
*/
|
|
21
|
+
retentionPeriod?: number;
|
|
22
|
+
/**
|
|
23
|
+
* DLQ visibility timeout (วินาที)
|
|
24
|
+
* (default: ใช้ค่า visibilityTimeout ของ main queue)
|
|
25
|
+
*/
|
|
26
|
+
visibilityTimeout?: number;
|
|
27
|
+
/**
|
|
28
|
+
* ชื่อ DLQ (default: จะสร้างจาก queueName + '-dlq')
|
|
29
|
+
*/
|
|
30
|
+
queueName?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface SqsEncryptionConfig {
|
|
33
|
+
/**
|
|
34
|
+
* Encryption type
|
|
35
|
+
* - 'sqs-managed' → SQS managed encryption (SSE-SQS, default)
|
|
36
|
+
* - 'kms' → KMS encryption (SSE-KMS)
|
|
37
|
+
* - 'none' → ไม่เข้ารหัส
|
|
38
|
+
* (default: 'sqs-managed')
|
|
39
|
+
*/
|
|
40
|
+
type?: 'sqs-managed' | 'kms' | 'none';
|
|
41
|
+
/** KMS key ARN (required if type = 'kms') */
|
|
42
|
+
kmsKeyArn?: string;
|
|
43
|
+
/** KMS data key reuse period in seconds (default: 300) */
|
|
44
|
+
kmsDataKeyReusePeriod?: number;
|
|
45
|
+
}
|
|
46
|
+
export interface SqsRedriveAllowConfig {
|
|
47
|
+
/**
|
|
48
|
+
* Redrive allow policy — กำหนดว่า queue ใดบ้างที่มีสิทธิ์ใช้ queue นี้เป็น DLQ
|
|
49
|
+
* - 'allowAll' → ทุก queue ใน account ใช้ได้ (default)
|
|
50
|
+
* - 'denyAll' → ไม่มีใครใช้ได้
|
|
51
|
+
* - 'byQueue' → ระบุ queue ARN ที่อนุญาต
|
|
52
|
+
*/
|
|
53
|
+
redrivePermission?: 'allowAll' | 'denyAll' | 'byQueue';
|
|
54
|
+
/** Queue ARNs ที่อนุญาต (ใช้เมื่อ redrivePermission = 'byQueue') */
|
|
55
|
+
sourceQueueArns?: string[];
|
|
56
|
+
}
|
|
57
|
+
export interface SqsConfig {
|
|
58
|
+
stackName: string;
|
|
59
|
+
/** SQS queue name */
|
|
60
|
+
queueName: string;
|
|
61
|
+
/** Account config reference (ดู configs/accounts/) */
|
|
62
|
+
accountConfigName?: string;
|
|
63
|
+
account?: string;
|
|
64
|
+
region?: string;
|
|
65
|
+
/**
|
|
66
|
+
* FIFO queue
|
|
67
|
+
* - true → FIFO queue (.fifo suffix จะถูกเพิ่มอัตโนมัติ)
|
|
68
|
+
* - false → Standard queue (default)
|
|
69
|
+
*/
|
|
70
|
+
fifo?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Content-based deduplication (FIFO only)
|
|
73
|
+
* ใช้ message body hash เป็น deduplication ID
|
|
74
|
+
* (default: false)
|
|
75
|
+
*/
|
|
76
|
+
contentBasedDeduplication?: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* FIFO throughput limit
|
|
79
|
+
* - 'perQueue' → 300 msg/s per queue (default)
|
|
80
|
+
* - 'perMessageGroupId' → 300 msg/s per message group
|
|
81
|
+
*/
|
|
82
|
+
fifoThroughputLimit?: 'perQueue' | 'perMessageGroupId';
|
|
83
|
+
/**
|
|
84
|
+
* High throughput FIFO (requires fifoThroughputLimit: 'perMessageGroupId')
|
|
85
|
+
* เปิดให้ได้ 3,000 msg/s ต่อ API action per queue
|
|
86
|
+
* (default: false)
|
|
87
|
+
*/
|
|
88
|
+
highThroughputFifo?: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Visibility timeout (วินาที)
|
|
91
|
+
* ระยะเวลาที่ message จะถูกซ่อนหลังจาก consumer receive
|
|
92
|
+
* (default: 30)
|
|
93
|
+
*/
|
|
94
|
+
visibilityTimeout?: number;
|
|
95
|
+
/**
|
|
96
|
+
* Message retention period (วินาที)
|
|
97
|
+
* ระยะเวลาที่ SQS เก็บ message ไว้ก่อนลบ
|
|
98
|
+
* (default: 345600 = 4 วัน)
|
|
99
|
+
* (max: 1209600 = 14 วัน)
|
|
100
|
+
*/
|
|
101
|
+
retentionPeriod?: number;
|
|
102
|
+
/**
|
|
103
|
+
* Delay seconds — delay ก่อน message จะ available
|
|
104
|
+
* (default: 0)
|
|
105
|
+
* (max: 900 = 15 นาที)
|
|
106
|
+
*/
|
|
107
|
+
deliveryDelay?: number;
|
|
108
|
+
/**
|
|
109
|
+
* Receive message wait time (วินาที) — สำหรับ long polling
|
|
110
|
+
* (default: 0 = short polling)
|
|
111
|
+
* (recommended: 20 = long polling)
|
|
112
|
+
*/
|
|
113
|
+
receiveMessageWaitTime?: number;
|
|
114
|
+
/**
|
|
115
|
+
* Maximum message size (bytes)
|
|
116
|
+
* (default: 262144 = 256 KB — maximum)
|
|
117
|
+
*/
|
|
118
|
+
maxMessageSize?: number;
|
|
119
|
+
/**
|
|
120
|
+
* Dead Letter Queue config
|
|
121
|
+
* ถ้าไม่ใส่ → ไม่สร้าง DLQ
|
|
122
|
+
* ถ้าใส่ {} → สร้าง DLQ ด้วย defaults (maxReceiveCount: 3, retention: 14 วัน)
|
|
123
|
+
*/
|
|
124
|
+
deadLetterQueue?: SqsDlqConfig;
|
|
125
|
+
/** Encryption config (default: SQS managed encryption) */
|
|
126
|
+
encryption?: SqsEncryptionConfig;
|
|
127
|
+
/**
|
|
128
|
+
* AWS account IDs ที่อนุญาตให้ส่ง message เข้า queue
|
|
129
|
+
* (เพิ่ม SendMessage permission ให้ accounts เหล่านี้)
|
|
130
|
+
*/
|
|
131
|
+
allowSendFromAccounts?: string[];
|
|
132
|
+
/**
|
|
133
|
+
* AWS account IDs ที่อนุญาตให้รับ message จาก queue
|
|
134
|
+
* (เพิ่ม ReceiveMessage + DeleteMessage permission)
|
|
135
|
+
*/
|
|
136
|
+
allowReceiveFromAccounts?: string[];
|
|
137
|
+
/** Redrive allow policy for DLQ */
|
|
138
|
+
redriveAllowPolicy?: SqsRedriveAllowConfig;
|
|
139
|
+
/** Removal policy (default: 'destroy') */
|
|
140
|
+
removalPolicy?: 'destroy' | 'retain';
|
|
141
|
+
/** Tag config name (ดู configs/tags/) */
|
|
142
|
+
tagConfigName?: string;
|
|
143
|
+
/** Additional tags */
|
|
144
|
+
tags?: Record<string, string>;
|
|
145
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* SQS + Dead Letter Queue Config Interface
|
|
4
|
+
*
|
|
5
|
+
* สร้าง SQS Queue พร้อม Dead Letter Queue (DLQ) อัตโนมัติ
|
|
6
|
+
*
|
|
7
|
+
* Architecture:
|
|
8
|
+
* Producer → SQS Queue → Consumer
|
|
9
|
+
* ↓ (failed messages)
|
|
10
|
+
* DLQ Queue → alarm / reprocessing
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tag Configuration Interface
|
|
3
|
+
*
|
|
4
|
+
* ใช้เป็น "resource" กลางสำหรับ tags เหมือน VPC ที่ทุก service อ้างอิง
|
|
5
|
+
*
|
|
6
|
+
* วิธีใช้:
|
|
7
|
+
* 1. สร้าง TagConfig ใน configs/tags/ (เช่น myapp-prod-tags.ts)
|
|
8
|
+
* 2. ทุก service config ใส่ tagConfigName เพื่ออ้างอิง
|
|
9
|
+
* 3. bin/main.ts จะ resolve tags จาก tagConfigName + merge กับ service tags
|
|
10
|
+
*
|
|
11
|
+
* ลำดับ priority: service tags > tag config tags
|
|
12
|
+
*/
|
|
13
|
+
export interface TagConfig {
|
|
14
|
+
/** ชื่อ tag config (ใช้อ้างอิงจาก service configs) */
|
|
15
|
+
name: string;
|
|
16
|
+
/** Tags กลางที่ติดทุก resource ใน project นี้ */
|
|
17
|
+
tags: Record<string, string>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export type VpcType = 'demo' | 'dev' | 'uat' | 'prod';
|
|
2
|
+
export type RouteTarget = {
|
|
3
|
+
type: 'igw';
|
|
4
|
+
} | {
|
|
5
|
+
type: 'nat';
|
|
6
|
+
natIndex: number;
|
|
7
|
+
} | {
|
|
8
|
+
type: 'vpcPeering';
|
|
9
|
+
peeringId: string;
|
|
10
|
+
} | {
|
|
11
|
+
type: 'transitGateway';
|
|
12
|
+
tgwId: string;
|
|
13
|
+
} | {
|
|
14
|
+
type: 'vpcEndpoint';
|
|
15
|
+
endpointId: string;
|
|
16
|
+
};
|
|
17
|
+
export interface RouteConfig {
|
|
18
|
+
destinationCidr: string;
|
|
19
|
+
target: RouteTarget;
|
|
20
|
+
}
|
|
21
|
+
export interface SubnetConfig {
|
|
22
|
+
name: string;
|
|
23
|
+
cidr: string;
|
|
24
|
+
az: string;
|
|
25
|
+
type: 'public' | 'private' | 'isolated';
|
|
26
|
+
}
|
|
27
|
+
export interface RouteTableConfig {
|
|
28
|
+
name: string;
|
|
29
|
+
az?: string;
|
|
30
|
+
routes: RouteConfig[];
|
|
31
|
+
}
|
|
32
|
+
export interface VpcConfig {
|
|
33
|
+
stackName: string;
|
|
34
|
+
name: string;
|
|
35
|
+
type: VpcType;
|
|
36
|
+
region?: string;
|
|
37
|
+
account?: string;
|
|
38
|
+
/** อ้างอิง Account Config name (ดู configs/accounts/) — ถ้าใส่จะใช้แทน account + region */
|
|
39
|
+
accountConfigName?: string;
|
|
40
|
+
cidr: string;
|
|
41
|
+
secondaryCidrs?: string[];
|
|
42
|
+
subnets: SubnetConfig[];
|
|
43
|
+
routeTablePerAz?: boolean;
|
|
44
|
+
routeTables?: RouteTableConfig[];
|
|
45
|
+
enableFlowLogs?: boolean;
|
|
46
|
+
enableDnsHostnames?: boolean;
|
|
47
|
+
enableDnsSupport?: boolean;
|
|
48
|
+
natGateways?: {
|
|
49
|
+
subnetName: string;
|
|
50
|
+
az?: string;
|
|
51
|
+
}[];
|
|
52
|
+
nacls?: NaclConfig[];
|
|
53
|
+
removalPolicy?: 'destroy' | 'retain';
|
|
54
|
+
/** อ้างอิง Tag Config name (ดู configs/tags/) */
|
|
55
|
+
tagConfigName?: string;
|
|
56
|
+
/** Tags เสริม — merge กับ tagConfigName (override ถ้า key ซ้ำ) */
|
|
57
|
+
tags?: Record<string, string>;
|
|
58
|
+
}
|
|
59
|
+
export interface NaclRuleConfig {
|
|
60
|
+
ruleNumber: number;
|
|
61
|
+
protocol: number;
|
|
62
|
+
ruleAction: 'allow' | 'deny';
|
|
63
|
+
cidr: string;
|
|
64
|
+
fromPort?: number;
|
|
65
|
+
toPort?: number;
|
|
66
|
+
egress: boolean;
|
|
67
|
+
}
|
|
68
|
+
export interface NaclConfig {
|
|
69
|
+
name: string;
|
|
70
|
+
subnetNames: string[];
|
|
71
|
+
rules: NaclRuleConfig[];
|
|
72
|
+
}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import * as logs from 'aws-cdk-lib/aws-logs';
|
|
2
|
+
/**
|
|
3
|
+
* WAF v2 WebACL Configuration Interface
|
|
4
|
+
*
|
|
5
|
+
* สร้าง AWS WAF WebACL พร้อม AWS Managed Rule Sets
|
|
6
|
+
*
|
|
7
|
+
* ⚠️ สำหรับ CloudFront: scope ต้องเป็น 'CLOUDFRONT' และ region ต้องเป็น us-east-1
|
|
8
|
+
* ⚠️ สำหรับ ALB/API Gateway: scope ต้องเป็น 'REGIONAL' และ region เดียวกับ resource
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Preset AWS Managed Rule Groups ที่ใช้บ่อย
|
|
12
|
+
*
|
|
13
|
+
* Core Rule Sets:
|
|
14
|
+
* - 'AWSManagedRulesCommonRuleSet' : General web app protection (XSS, file inclusion, etc.)
|
|
15
|
+
* - 'AWSManagedRulesKnownBadInputsRuleSet' : Known bad inputs & exploits (Log4j, SSRF, etc.)
|
|
16
|
+
* - 'AWSManagedRulesSQLiRuleSet' : SQL Injection protection
|
|
17
|
+
*
|
|
18
|
+
* Use Case Rule Sets:
|
|
19
|
+
* - 'AWSManagedRulesLinuxRuleSet' : Linux-specific LFI/RCE attacks
|
|
20
|
+
* - 'AWSManagedRulesUnixRuleSet' : Unix-specific POSIX OS attacks
|
|
21
|
+
* - 'AWSManagedRulesWindowsRuleSet' : Windows-specific (PowerShell, cmd)
|
|
22
|
+
* - 'AWSManagedRulesPHPRuleSet' : PHP-specific attacks
|
|
23
|
+
* - 'AWSManagedRulesWordPressRuleSet' : WordPress-specific exploits
|
|
24
|
+
*
|
|
25
|
+
* IP Reputation:
|
|
26
|
+
* - 'AWSManagedRulesAmazonIpReputationList' : Known malicious IP addresses
|
|
27
|
+
* - 'AWSManagedRulesAnonymousIpList' : VPN/Tor/proxy/hosting providers
|
|
28
|
+
*
|
|
29
|
+
* Bot Control:
|
|
30
|
+
* - 'AWSManagedRulesBotControlRuleSet' : Bot detection & mitigation (มีค่าใช้จ่ายเพิ่ม)
|
|
31
|
+
*
|
|
32
|
+
* Account Takeover:
|
|
33
|
+
* - 'AWSManagedRulesATPRuleSet' : Account takeover prevention (มีค่าใช้จ่ายเพิ่ม)
|
|
34
|
+
*/
|
|
35
|
+
export interface WafManagedRuleGroupConfig {
|
|
36
|
+
/** AWS Managed Rule Group name (e.g., 'AWSManagedRulesCommonRuleSet') */
|
|
37
|
+
name: string;
|
|
38
|
+
/** Vendor name (default: 'AWS') */
|
|
39
|
+
vendorName?: string;
|
|
40
|
+
/** Rule priority (ต้อง unique ต่อ WebACL, ค่าน้อย = evaluate ก่อน) */
|
|
41
|
+
priority: number;
|
|
42
|
+
/**
|
|
43
|
+
* Override action สำหรับ managed rule group
|
|
44
|
+
* - 'none' → ใช้ action ตามที่ rule group กำหนด (Block/Count) — default
|
|
45
|
+
* - 'count' → Count only ไม่ block (ใช้ตอนทดสอบ)
|
|
46
|
+
*/
|
|
47
|
+
overrideAction?: 'none' | 'count';
|
|
48
|
+
/**
|
|
49
|
+
* Rule overrides สำหรับ rules ภายใน rule group
|
|
50
|
+
* ใช้เมื่อต้องการ override บาง rule ให้เป็น Count แทน Block (false positive)
|
|
51
|
+
*
|
|
52
|
+
* Example: { 'SizeRestrictions_BODY': 'count' } → ไม่ block requests ที่ body ใหญ่
|
|
53
|
+
*/
|
|
54
|
+
ruleOverrides?: Record<string, 'count' | 'block' | 'allow'>;
|
|
55
|
+
/**
|
|
56
|
+
* Excluded rules — ปิดการทำงานของ rules เหล่านี้ทั้งหมด
|
|
57
|
+
* ใช้เมื่อ rule ทำให้เกิด false positive มาก
|
|
58
|
+
*
|
|
59
|
+
* Example: ['CrossSiteScripting_BODY'] → ปิด XSS check สำหรับ body
|
|
60
|
+
*/
|
|
61
|
+
excludedRules?: string[];
|
|
62
|
+
}
|
|
63
|
+
export interface WafRateLimitConfig {
|
|
64
|
+
/** Rule priority */
|
|
65
|
+
priority: number;
|
|
66
|
+
/**
|
|
67
|
+
* Rate limit per 5-minute window per IP
|
|
68
|
+
* (min: 100, max: 2,000,000,000)
|
|
69
|
+
* Default: 2000
|
|
70
|
+
*/
|
|
71
|
+
limit: number;
|
|
72
|
+
/**
|
|
73
|
+
* Action เมื่อเกิน rate limit
|
|
74
|
+
* - 'block' → block request (default)
|
|
75
|
+
* - 'count' → count only (ใช้ตอนทดสอบ)
|
|
76
|
+
*/
|
|
77
|
+
action?: 'block' | 'count';
|
|
78
|
+
}
|
|
79
|
+
export interface WafGeoBlockConfig {
|
|
80
|
+
/** Rule priority */
|
|
81
|
+
priority: number;
|
|
82
|
+
/**
|
|
83
|
+
* ISO 3166-1 alpha-2 country codes to block
|
|
84
|
+
* e.g., ['CN', 'RU', 'KP']
|
|
85
|
+
*/
|
|
86
|
+
countryCodes: string[];
|
|
87
|
+
/**
|
|
88
|
+
* Action
|
|
89
|
+
* - 'block' → block requests from these countries (default)
|
|
90
|
+
* - 'count' → count only
|
|
91
|
+
*/
|
|
92
|
+
action?: 'block' | 'count';
|
|
93
|
+
}
|
|
94
|
+
export interface WafIpSetConfig {
|
|
95
|
+
/** Display name */
|
|
96
|
+
name: string;
|
|
97
|
+
/** Rule priority */
|
|
98
|
+
priority: number;
|
|
99
|
+
/**
|
|
100
|
+
* IP addresses in CIDR notation
|
|
101
|
+
* e.g., ['203.0.113.0/24', '198.51.100.1/32']
|
|
102
|
+
*/
|
|
103
|
+
addresses: string[];
|
|
104
|
+
/**
|
|
105
|
+
* IP version (default: 'IPV4')
|
|
106
|
+
*/
|
|
107
|
+
ipAddressVersion?: 'IPV4' | 'IPV6';
|
|
108
|
+
/**
|
|
109
|
+
* Action
|
|
110
|
+
* - 'allow' → allow these IPs (whitelist)
|
|
111
|
+
* - 'block' → block these IPs (blacklist)
|
|
112
|
+
* - 'count' → count only
|
|
113
|
+
*/
|
|
114
|
+
action: 'allow' | 'block' | 'count';
|
|
115
|
+
}
|
|
116
|
+
export interface WafLoggingConfig {
|
|
117
|
+
/** Log retention (default: ONE_MONTH) */
|
|
118
|
+
retention?: logs.RetentionDays;
|
|
119
|
+
/**
|
|
120
|
+
* Log filter — เลือก log เฉพาะบาง action
|
|
121
|
+
* - 'all' → log ทุก request
|
|
122
|
+
* - 'blocked' → log เฉพาะ blocked requests (default, ประหยัด cost)
|
|
123
|
+
*/
|
|
124
|
+
logFilter?: 'all' | 'blocked';
|
|
125
|
+
/** Log group removal policy (default: 'destroy') */
|
|
126
|
+
removalPolicy?: 'destroy' | 'retain';
|
|
127
|
+
}
|
|
128
|
+
export interface WafConfig {
|
|
129
|
+
stackName: string;
|
|
130
|
+
region?: string;
|
|
131
|
+
account?: string;
|
|
132
|
+
/** อ้างอิง Account Config name (ดู configs/accounts/) */
|
|
133
|
+
accountConfigName?: string;
|
|
134
|
+
/**
|
|
135
|
+
* WAF Scope:
|
|
136
|
+
* - 'CLOUDFRONT' → สำหรับ CloudFront (ต้อง deploy ใน us-east-1)
|
|
137
|
+
* - 'REGIONAL' → สำหรับ ALB, API Gateway, AppSync
|
|
138
|
+
*/
|
|
139
|
+
scope: 'CLOUDFRONT' | 'REGIONAL';
|
|
140
|
+
/** WebACL name */
|
|
141
|
+
webAclName: string;
|
|
142
|
+
/** WebACL description */
|
|
143
|
+
description?: string;
|
|
144
|
+
/**
|
|
145
|
+
* Default action เมื่อไม่ match rule ใดเลย
|
|
146
|
+
* - 'allow' → allow request (default — ใช้ rules เป็น blocklist)
|
|
147
|
+
* - 'block' → block request (ใช้ rules เป็น allowlist)
|
|
148
|
+
*/
|
|
149
|
+
defaultAction?: 'allow' | 'block';
|
|
150
|
+
/** AWS Managed Rule Groups */
|
|
151
|
+
managedRuleGroups?: WafManagedRuleGroupConfig[];
|
|
152
|
+
/** Rate limiting rule */
|
|
153
|
+
rateLimit?: WafRateLimitConfig;
|
|
154
|
+
/** Geographic blocking rule */
|
|
155
|
+
geoBlock?: WafGeoBlockConfig;
|
|
156
|
+
/** IP Allow List (whitelist) */
|
|
157
|
+
ipAllowList?: WafIpSetConfig;
|
|
158
|
+
/** IP Block List (blacklist) */
|
|
159
|
+
ipBlockList?: WafIpSetConfig;
|
|
160
|
+
/** Logging configuration (optional) */
|
|
161
|
+
logging?: WafLoggingConfig;
|
|
162
|
+
/**
|
|
163
|
+
* สำหรับ CLOUDFRONT scope → ไม่ต้อง associate ที่นี่
|
|
164
|
+
* ไปใส่ webAclId ที่ CloudFront config แทน
|
|
165
|
+
*
|
|
166
|
+
* สำหรับ REGIONAL scope → ระบุ resource ARN ที่ต้องการ associate
|
|
167
|
+
* e.g., ALB ARN
|
|
168
|
+
*/
|
|
169
|
+
associatedResourceArns?: string[];
|
|
170
|
+
/** Enable CloudWatch metrics (default: true) */
|
|
171
|
+
enableCloudWatchMetrics?: boolean;
|
|
172
|
+
/** Enable sampled requests (default: true) */
|
|
173
|
+
enableSampledRequests?: boolean;
|
|
174
|
+
/** Removal policy (default: 'destroy') */
|
|
175
|
+
removalPolicy?: 'destroy' | 'retain';
|
|
176
|
+
/** อ้างอิง Tag Config name (ดู configs/tags/) */
|
|
177
|
+
tagConfigName?: string;
|
|
178
|
+
/** Tags เสริม */
|
|
179
|
+
tags?: Record<string, string>;
|
|
180
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Priority Tracker for ALB Listener Rules
|
|
3
|
+
*
|
|
4
|
+
* Manages priority assignments for ALB Listener Rules to prevent conflicts.
|
|
5
|
+
* Priorities must be unique within a listener (range: 1-50000).
|
|
6
|
+
*/
|
|
7
|
+
export interface PriorityAssignment {
|
|
8
|
+
serviceName: string;
|
|
9
|
+
priority: number;
|
|
10
|
+
path?: string;
|
|
11
|
+
host?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare class PriorityTracker {
|
|
14
|
+
private assignments;
|
|
15
|
+
private serviceNames;
|
|
16
|
+
/**
|
|
17
|
+
* Register a priority assignment
|
|
18
|
+
* @param serviceName Name of the ECS service
|
|
19
|
+
* @param priority Priority value (1-50000)
|
|
20
|
+
* @param path Optional path pattern
|
|
21
|
+
* @param host Optional host header
|
|
22
|
+
* @throws Error if priority is already assigned or out of range
|
|
23
|
+
*/
|
|
24
|
+
registerPriority(serviceName: string, priority: number, path?: string, host?: string): void;
|
|
25
|
+
/**
|
|
26
|
+
* Get all priority assignments sorted by priority
|
|
27
|
+
* @returns Array of priority assignments
|
|
28
|
+
*/
|
|
29
|
+
getAssignments(): PriorityAssignment[];
|
|
30
|
+
/**
|
|
31
|
+
* Check if a priority is available
|
|
32
|
+
* @param priority Priority value to check
|
|
33
|
+
* @returns True if priority is available
|
|
34
|
+
*/
|
|
35
|
+
isPriorityAvailable(priority: number): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Get the next available priority
|
|
38
|
+
* @param startFrom Starting priority (default: 1)
|
|
39
|
+
* @returns Next available priority
|
|
40
|
+
*/
|
|
41
|
+
getNextAvailablePriority(startFrom?: number): number;
|
|
42
|
+
/**
|
|
43
|
+
* Print a summary of all priority assignments
|
|
44
|
+
*/
|
|
45
|
+
printSummary(): void;
|
|
46
|
+
/**
|
|
47
|
+
* Validate all assignments for conflicts
|
|
48
|
+
* @throws Error if conflicts are detected
|
|
49
|
+
*/
|
|
50
|
+
validate(): void;
|
|
51
|
+
/**
|
|
52
|
+
* Clear all assignments
|
|
53
|
+
*/
|
|
54
|
+
clear(): void;
|
|
55
|
+
/**
|
|
56
|
+
* Get total number of assignments
|
|
57
|
+
* @returns Number of registered assignments
|
|
58
|
+
*/
|
|
59
|
+
get count(): number;
|
|
60
|
+
}
|