cdk-cost-analyzer 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.cdk-cost-analyzer-cache/metadata.json +12 -0
- package/.gitlab-ci.yml +214 -0
- package/.husky/pre-commit +12 -0
- package/.kiro/hooks/accessibility-audit.kiro.hook +18 -0
- package/.kiro/hooks/api-schema-validation.kiro.hook +21 -0
- package/.kiro/hooks/auto-test-on-save.kiro.hook +19 -0
- package/.kiro/hooks/cdk-synth-on-change.kiro.hook +20 -0
- package/.kiro/hooks/code-coverage-check.kiro.hook +14 -0
- package/.kiro/hooks/commit-message-helper.kiro.hook +14 -0
- package/.kiro/hooks/dependency-update-check.kiro.hook +14 -0
- package/.kiro/hooks/env-file-validation.kiro.hook +18 -0
- package/.kiro/hooks/lint-and-format-on-save.kiro.hook +21 -0
- package/.kiro/hooks/mcp-config-validation.kiro.hook +17 -0
- package/.kiro/hooks/mcp-server-test.kiro.hook +14 -0
- package/.kiro/hooks/performance-analysis.kiro.hook +14 -0
- package/.kiro/hooks/readme-spell-check.kiro.hook +14 -0
- package/.kiro/hooks/security-scan-on-dependency-change.kiro.hook +21 -0
- package/.kiro/hooks/translation-update.kiro.hook +18 -0
- package/.kiro/hooks/update-documentation.kiro.hook +18 -0
- package/.kiro/settings/mcp.json +20 -0
- package/.kiro/specs/cdk-cost-analyzer/design.md +620 -0
- package/.kiro/specs/cdk-cost-analyzer/requirements.md +183 -0
- package/.kiro/specs/cdk-cost-analyzer/tasks.md +357 -0
- package/.kiro/specs/github-actions-ci/design.md +281 -0
- package/.kiro/specs/github-actions-ci/requirements.md +86 -0
- package/.kiro/specs/github-actions-ci/tasks.md +115 -0
- package/.kiro/specs/nlb-calculator-test-coverage/design.md +190 -0
- package/.kiro/specs/nlb-calculator-test-coverage/requirements.md +84 -0
- package/.kiro/specs/nlb-calculator-test-coverage/tasks.md +150 -0
- package/.kiro/specs/production-readiness/design.md +1213 -0
- package/.kiro/specs/production-readiness/requirements.md +312 -0
- package/.kiro/specs/production-readiness/tasks.md +269 -0
- package/.kiro/specs/repository-cleanup/design.md +283 -0
- package/.kiro/specs/repository-cleanup/requirements.md +74 -0
- package/.kiro/specs/repository-cleanup/tasks.md +64 -0
- package/.kiro/steering/aws-cli-best-practices.md +41 -0
- package/.kiro/steering/cdk-best-practices.md +49 -0
- package/.kiro/steering/development-standards.md +54 -0
- package/.kiro/steering/docker-best-practices.md +34 -0
- package/.kiro/steering/documentation-style.md +151 -0
- package/.kiro/steering/git-best-practices.md +37 -0
- package/.kiro/steering/mcp-best-practices.md +95 -0
- package/.kiro/steering/python-best-practices.md +48 -0
- package/.kiro/steering/react-best-practices.md +44 -0
- package/.kiro/steering/security-best-practices.md +41 -0
- package/.kiro/steering/testing-best-practices.md +59 -0
- package/.kiro/steering/typescript-best-practices.md +40 -0
- package/CHANGELOG.md +49 -0
- package/CONTRIBUTING.md +258 -0
- package/LICENSE +19 -0
- package/README.md +480 -0
- package/SECURITY.md +117 -0
- package/dist/api/index.d.ts +11 -0
- package/dist/api/index.js +65 -0
- package/dist/api/types.d.ts +15 -0
- package/dist/api/types.js +3 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +262 -0
- package/dist/config/ConfigManager.d.ts +40 -0
- package/dist/config/ConfigManager.js +238 -0
- package/dist/config/index.d.ts +2 -0
- package/dist/config/index.js +19 -0
- package/dist/config/types.d.ts +72 -0
- package/dist/config/types.js +15 -0
- package/dist/diff/DiffEngine.d.ts +7 -0
- package/dist/diff/DiffEngine.js +73 -0
- package/dist/diff/index.d.ts +2 -0
- package/dist/diff/index.js +21 -0
- package/dist/diff/types.d.ts +20 -0
- package/dist/diff/types.js +3 -0
- package/dist/integrations/GitLabIntegration.d.ts +7 -0
- package/dist/integrations/GitLabIntegration.js +45 -0
- package/dist/integrations/index.d.ts +2 -0
- package/dist/integrations/index.js +21 -0
- package/dist/integrations/types.d.ts +11 -0
- package/dist/integrations/types.js +13 -0
- package/dist/parser/TemplateParser.d.ts +8 -0
- package/dist/parser/TemplateParser.js +75 -0
- package/dist/parser/index.d.ts +2 -0
- package/dist/parser/index.js +22 -0
- package/dist/parser/types.d.ts +30 -0
- package/dist/parser/types.js +3 -0
- package/dist/pipeline/PipelineOrchestrator.d.ts +23 -0
- package/dist/pipeline/PipelineOrchestrator.js +191 -0
- package/dist/pipeline/index.d.ts +2 -0
- package/dist/pipeline/index.js +19 -0
- package/dist/pipeline/types.d.ts +41 -0
- package/dist/pipeline/types.js +13 -0
- package/dist/pricing/CacheManager.d.ts +75 -0
- package/dist/pricing/CacheManager.js +195 -0
- package/dist/pricing/PricingClient.d.ts +17 -0
- package/dist/pricing/PricingClient.js +122 -0
- package/dist/pricing/PricingService.d.ts +16 -0
- package/dist/pricing/PricingService.js +149 -0
- package/dist/pricing/calculators/ALBCalculator.d.ts +16 -0
- package/dist/pricing/calculators/ALBCalculator.js +163 -0
- package/dist/pricing/calculators/APIGatewayCalculator.d.ts +10 -0
- package/dist/pricing/calculators/APIGatewayCalculator.js +177 -0
- package/dist/pricing/calculators/CloudFrontCalculator.d.ts +59 -0
- package/dist/pricing/calculators/CloudFrontCalculator.js +151 -0
- package/dist/pricing/calculators/DynamoDBCalculator.d.ts +9 -0
- package/dist/pricing/calculators/DynamoDBCalculator.js +146 -0
- package/dist/pricing/calculators/EC2Calculator.d.ts +7 -0
- package/dist/pricing/calculators/EC2Calculator.js +80 -0
- package/dist/pricing/calculators/ECSCalculator.d.ts +9 -0
- package/dist/pricing/calculators/ECSCalculator.js +116 -0
- package/dist/pricing/calculators/ElastiCacheCalculator.d.ts +8 -0
- package/dist/pricing/calculators/ElastiCacheCalculator.js +106 -0
- package/dist/pricing/calculators/LambdaCalculator.d.ts +13 -0
- package/dist/pricing/calculators/LambdaCalculator.js +111 -0
- package/dist/pricing/calculators/NLBCalculator.d.ts +16 -0
- package/dist/pricing/calculators/NLBCalculator.js +138 -0
- package/dist/pricing/calculators/NatGatewayCalculator.d.ts +12 -0
- package/dist/pricing/calculators/NatGatewayCalculator.js +116 -0
- package/dist/pricing/calculators/RDSCalculator.d.ts +9 -0
- package/dist/pricing/calculators/RDSCalculator.js +103 -0
- package/dist/pricing/calculators/S3Calculator.d.ts +8 -0
- package/dist/pricing/calculators/S3Calculator.js +68 -0
- package/dist/pricing/calculators/VPCEndpointCalculator.d.ts +12 -0
- package/dist/pricing/calculators/VPCEndpointCalculator.js +129 -0
- package/dist/pricing/index.d.ts +10 -0
- package/dist/pricing/index.js +37 -0
- package/dist/pricing/types.d.ts +53 -0
- package/dist/pricing/types.js +22 -0
- package/dist/releasetag.txt +1 -0
- package/dist/reporter/Reporter.d.ts +18 -0
- package/dist/reporter/Reporter.js +412 -0
- package/dist/reporter/index.d.ts +2 -0
- package/dist/reporter/index.js +21 -0
- package/dist/reporter/types.d.ts +72 -0
- package/dist/reporter/types.js +3 -0
- package/dist/synthesis/SynthesisOrchestrator.d.ts +26 -0
- package/dist/synthesis/SynthesisOrchestrator.js +243 -0
- package/dist/synthesis/index.d.ts +2 -0
- package/dist/synthesis/index.js +19 -0
- package/dist/synthesis/types.d.ts +17 -0
- package/dist/synthesis/types.js +13 -0
- package/dist/threshold/ThresholdEnforcer.d.ts +29 -0
- package/dist/threshold/ThresholdEnforcer.js +143 -0
- package/dist/threshold/index.d.ts +2 -0
- package/dist/threshold/index.js +19 -0
- package/dist/threshold/types.d.ts +15 -0
- package/dist/threshold/types.js +17 -0
- package/docs/CALCULATORS.md +820 -0
- package/docs/CI_CD.md +608 -0
- package/docs/CONFIGURATION.md +407 -0
- package/docs/DEVELOPMENT.md +387 -0
- package/docs/RELEASE.md +223 -0
- package/docs/TROUBLESHOOTING.md +847 -0
- package/examples/.cdk-cost-analyzer.yml +85 -0
- package/examples/.gitlab-ci.yml +125 -0
- package/examples/api-usage.js +26 -0
- package/examples/complex/base.json +16 -0
- package/examples/complex/target.json +29 -0
- package/examples/monorepo/.gitlab-ci.yml +251 -0
- package/examples/monorepo/README.md +341 -0
- package/examples/monorepo/package.json +27 -0
- package/examples/monorepo/packages/backend-infra/.cdk-cost-analyzer.yml +34 -0
- package/examples/monorepo/packages/backend-infra/bin/app.ts +16 -0
- package/examples/monorepo/packages/backend-infra/cdk.json +7 -0
- package/examples/monorepo/packages/backend-infra/lib/backend-stack.ts +128 -0
- package/examples/monorepo/packages/backend-infra/package.json +30 -0
- package/examples/monorepo/packages/backend-infra/tsconfig.json +11 -0
- package/examples/monorepo/packages/data-infra/.cdk-cost-analyzer.yml +38 -0
- package/examples/monorepo/packages/data-infra/bin/app.ts +16 -0
- package/examples/monorepo/packages/data-infra/cdk.json +7 -0
- package/examples/monorepo/packages/data-infra/lib/data-stack.ts +121 -0
- package/examples/monorepo/packages/data-infra/package.json +30 -0
- package/examples/monorepo/packages/data-infra/tsconfig.json +11 -0
- package/examples/monorepo/packages/frontend-infra/.cdk-cost-analyzer.yml +31 -0
- package/examples/monorepo/packages/frontend-infra/bin/app.ts +16 -0
- package/examples/monorepo/packages/frontend-infra/cdk.json +7 -0
- package/examples/monorepo/packages/frontend-infra/lib/frontend-stack.ts +60 -0
- package/examples/monorepo/packages/frontend-infra/package.json +30 -0
- package/examples/monorepo/packages/frontend-infra/tsconfig.json +11 -0
- package/examples/monorepo/tsconfig.json +35 -0
- package/examples/multi-stack/.cdk-cost-analyzer.yml +72 -0
- package/examples/multi-stack/.gitlab-ci.yml +184 -0
- package/examples/multi-stack/README.md +279 -0
- package/examples/multi-stack/bin/app.ts +36 -0
- package/examples/multi-stack/cdk.json +72 -0
- package/examples/multi-stack/lib/compute-stack.ts +128 -0
- package/examples/multi-stack/lib/networking-stack.ts +69 -0
- package/examples/multi-stack/lib/storage-stack.ts +141 -0
- package/examples/multi-stack/package-lock.json +4437 -0
- package/examples/multi-stack/package.json +42 -0
- package/examples/multi-stack/tsconfig.json +34 -0
- package/examples/simple/base.json +8 -0
- package/examples/simple/target.json +14 -0
- package/examples/single-stack/.NVP +0 -0
- package/examples/single-stack/.cdk-cost-analyzer.yml +52 -0
- package/examples/single-stack/.gitlab-ci.yml +126 -0
- package/examples/single-stack/README.md +184 -0
- package/examples/single-stack/UeK +0 -0
- package/examples/single-stack/bin/app.ts +16 -0
- package/examples/single-stack/cdk.json +72 -0
- package/examples/single-stack/lib/infrastructure-stack.ts +119 -0
- package/examples/single-stack/package-lock.json +4443 -0
- package/examples/single-stack/package.json +38 -0
- package/examples/single-stack/tsconfig.json +34 -0
- package/package.json +139 -0
- package/test-cdk-project/README-COMPUTE.md +141 -0
- package/test-cdk-project/README.md +95 -0
- package/test-cdk-project/app-with-compute.js +102 -0
- package/test-cdk-project/app.js +81 -0
- package/test-cdk-project/cdk-compute.json +3 -0
- package/test-cdk-project/cdk.context.json +7 -0
- package/test-cdk-project/cdk.json +3 -0
- package/test-cdk-project/cdk.out/TestStack.assets.json +21 -0
- package/test-cdk-project/cdk.out/TestStack.template.json +115 -0
- package/test-cdk-project/cdk.out/cdk.out +1 -0
- package/test-cdk-project/cdk.out/manifest.json +503 -0
- package/test-cdk-project/cdk.out/tree.json +1 -0
- package/test-cdk-project/cdk.out.base/TestStack.assets.json +21 -0
- package/test-cdk-project/cdk.out.base/TestStack.template.json +115 -0
- package/test-cdk-project/cdk.out.base/cdk.out +1 -0
- package/test-cdk-project/cdk.out.base/manifest.json +503 -0
- package/test-cdk-project/cdk.out.base/tree.json +1 -0
- package/test-cdk-project/cdk.out.target/TestStack.assets.json +21 -0
- package/test-cdk-project/cdk.out.target/TestStack.template.json +183 -0
- package/test-cdk-project/cdk.out.target/cdk.out +1 -0
- package/test-cdk-project/cdk.out.target/manifest.json +521 -0
- package/test-cdk-project/cdk.out.target/tree.json +1 -0
- package/test-cdk-project/package-lock.json +422 -0
- package/test-cdk-project/package.json +17 -0
- package/tools/workflows/README.md +102 -0
- package/tools/workflows/validate-workflows.js +109 -0
- package/tools/workflows/workflow-utils.ts +181 -0
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import * as cdk from 'aws-cdk-lib';
|
|
2
|
+
import * as ec2 from 'aws-cdk-lib/aws-ec2';
|
|
3
|
+
import * as rds from 'aws-cdk-lib/aws-rds';
|
|
4
|
+
import * as elasticache from 'aws-cdk-lib/aws-elasticache';
|
|
5
|
+
import * as s3 from 'aws-cdk-lib/aws-s3';
|
|
6
|
+
import { Construct } from 'constructs';
|
|
7
|
+
|
|
8
|
+
export interface StorageStackProps extends cdk.StackProps {
|
|
9
|
+
vpc: ec2.IVpc;
|
|
10
|
+
appSecurityGroup: ec2.ISecurityGroup;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Storage stack - Data layer
|
|
15
|
+
*
|
|
16
|
+
* Creates RDS database, ElastiCache cluster, and S3 bucket
|
|
17
|
+
*/
|
|
18
|
+
export class StorageStack extends cdk.Stack {
|
|
19
|
+
constructor(scope: Construct, id: string, props: StorageStackProps) {
|
|
20
|
+
super(scope, id, props);
|
|
21
|
+
|
|
22
|
+
const { vpc, appSecurityGroup } = props;
|
|
23
|
+
|
|
24
|
+
// Security group for database
|
|
25
|
+
const dbSecurityGroup = new ec2.SecurityGroup(this, 'DbSecurityGroup', {
|
|
26
|
+
vpc,
|
|
27
|
+
description: 'Security group for RDS database',
|
|
28
|
+
allowAllOutbound: false,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
// Allow application to connect to database
|
|
32
|
+
dbSecurityGroup.addIngressRule(
|
|
33
|
+
appSecurityGroup,
|
|
34
|
+
ec2.Port.tcp(5432),
|
|
35
|
+
'Allow PostgreSQL access from application'
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
// RDS PostgreSQL Database
|
|
39
|
+
const database = new rds.DatabaseInstance(this, 'Database', {
|
|
40
|
+
engine: rds.DatabaseInstanceEngine.postgres({
|
|
41
|
+
version: rds.PostgresEngineVersion.VER_15_3,
|
|
42
|
+
}),
|
|
43
|
+
instanceType: ec2.InstanceType.of(
|
|
44
|
+
ec2.InstanceClass.T3,
|
|
45
|
+
ec2.InstanceSize.MEDIUM
|
|
46
|
+
),
|
|
47
|
+
vpc,
|
|
48
|
+
vpcSubnets: {
|
|
49
|
+
subnetType: ec2.SubnetType.PRIVATE_WITH_EGRESS,
|
|
50
|
+
},
|
|
51
|
+
securityGroups: [dbSecurityGroup],
|
|
52
|
+
allocatedStorage: 100,
|
|
53
|
+
storageType: rds.StorageType.GP3,
|
|
54
|
+
multiAz: false,
|
|
55
|
+
databaseName: 'appdb',
|
|
56
|
+
backupRetention: cdk.Duration.days(7),
|
|
57
|
+
deleteAutomatedBackups: true,
|
|
58
|
+
removalPolicy: cdk.RemovalPolicy.DESTROY,
|
|
59
|
+
deletionProtection: false,
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// Security group for cache
|
|
63
|
+
const cacheSecurityGroup = new ec2.SecurityGroup(this, 'CacheSecurityGroup', {
|
|
64
|
+
vpc,
|
|
65
|
+
description: 'Security group for ElastiCache',
|
|
66
|
+
allowAllOutbound: false,
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// Allow application to connect to cache
|
|
70
|
+
cacheSecurityGroup.addIngressRule(
|
|
71
|
+
appSecurityGroup,
|
|
72
|
+
ec2.Port.tcp(6379),
|
|
73
|
+
'Allow Redis access from application'
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
// ElastiCache subnet group
|
|
77
|
+
const cacheSubnetGroup = new elasticache.CfnSubnetGroup(this, 'CacheSubnetGroup', {
|
|
78
|
+
description: 'Subnet group for ElastiCache',
|
|
79
|
+
subnetIds: vpc.selectSubnets({
|
|
80
|
+
subnetType: ec2.SubnetType.PRIVATE_WITH_EGRESS,
|
|
81
|
+
}).subnetIds,
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
// ElastiCache Redis Cluster
|
|
85
|
+
const cacheCluster = new elasticache.CfnCacheCluster(this, 'CacheCluster', {
|
|
86
|
+
cacheNodeType: 'cache.t3.micro',
|
|
87
|
+
engine: 'redis',
|
|
88
|
+
numCacheNodes: 2,
|
|
89
|
+
vpcSecurityGroupIds: [cacheSecurityGroup.securityGroupId],
|
|
90
|
+
cacheSubnetGroupName: cacheSubnetGroup.ref,
|
|
91
|
+
engineVersion: '7.0',
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
// S3 bucket for application data
|
|
95
|
+
const dataBucket = new s3.Bucket(this, 'DataBucket', {
|
|
96
|
+
bucketName: `${cdk.Stack.of(this).account}-app-data-${cdk.Stack.of(this).region}`,
|
|
97
|
+
versioned: true,
|
|
98
|
+
encryption: s3.BucketEncryption.S3_MANAGED,
|
|
99
|
+
blockPublicAccess: s3.BlockPublicAccess.BLOCK_ALL,
|
|
100
|
+
removalPolicy: cdk.RemovalPolicy.DESTROY,
|
|
101
|
+
autoDeleteObjects: true,
|
|
102
|
+
lifecycleRules: [
|
|
103
|
+
{
|
|
104
|
+
id: 'DeleteOldVersions',
|
|
105
|
+
noncurrentVersionExpiration: cdk.Duration.days(90),
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
id: 'TransitionToIA',
|
|
109
|
+
transitions: [
|
|
110
|
+
{
|
|
111
|
+
storageClass: s3.StorageClass.INFREQUENT_ACCESS,
|
|
112
|
+
transitionAfter: cdk.Duration.days(30),
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
},
|
|
116
|
+
],
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
// Stack outputs
|
|
120
|
+
new cdk.CfnOutput(this, 'DatabaseEndpoint', {
|
|
121
|
+
value: database.dbInstanceEndpointAddress,
|
|
122
|
+
description: 'RDS database endpoint',
|
|
123
|
+
exportName: 'StorageStack-DatabaseEndpoint',
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
new cdk.CfnOutput(this, 'DatabasePort', {
|
|
127
|
+
value: database.dbInstanceEndpointPort,
|
|
128
|
+
description: 'RDS database port',
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
new cdk.CfnOutput(this, 'CacheEndpoint', {
|
|
132
|
+
value: cacheCluster.attrRedisEndpointAddress,
|
|
133
|
+
description: 'ElastiCache Redis endpoint',
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
new cdk.CfnOutput(this, 'DataBucketName', {
|
|
137
|
+
value: dataBucket.bucketName,
|
|
138
|
+
description: 'S3 data bucket name',
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|