@minimonolith/infra v0.6.18
@minimonolith/infra
@minimonolith/infra
is a library based on @minimonolith/lib
and aws-cdk-lib
to implement modular and validated infrastructure
Example Project
Here's an example project using @minimonolith/infra
:
.
├── package.json
├── .gitignore
├── deploy.js // file that will be called when executing `cdk deploy`
├── test.js // test infrastructure specified at deploy.js (does not deploy it)
└── cdk.json // aws cdk configuration (specifies deploy.js to be used as deployment file)
deploy.js
This file defines the resources to be deployed:
// deploy.js
import * as INFRA from '@minimonolith/infra';
// Project definition
const app = await INFRA.cdk.postApp();
const projectName = 'TODO';
const env = await INFRA.env.get({ name: 'qa' });
const projectContext = { app, projectName, env }
// Networking
const cidrBlock = '172.16.0.0/12';
const privateAPI = true;
const albAPI = true;
const apiBalancingType = 'ip';
const apiPort = 80;
const vpcContext = await INFRA.networkingVPC.post({ ...projectContext,
cidrBlock, privateAPI, albAPI, apiPort, apiBalancingType });
// DB
const minCapacity=1, maxCapacity=64, qaAutoPause=true;
const dbContext = await INFRA.dbMySQL.post({ ...projectContext,
vpcContext, minCapacity, maxCapacity, qaAutoPause });
// Backend
const cpu = '512';
const memory = '1G';
const desiredCount = 1;
const externalImage = 'httpd';
const apiContext = await INFRA.apiFargate.post({ ...projectContext,
vpcContext, cpu, memory, desiredCount, externalImage });
test.js
Here deploy.js is tested:
// test.js
describe('test deploy', () => {
test('test deploy', async () => {
await import('./deploy.js');
});
});
cdk.json
This is the cdk.json configuration
{
"app": "node deploy.js",
"watch": {
"include": [
"**"
],
"exclude": [
"README.md",
"cdk*.json",
"jest.config.js",
"package*.json",
"yarn.lock",
"node_modules",
"test"
]
},
"context": {
"@aws-cdk/aws-apigateway:usagePlanKeyOrderInsensitiveId": true,
"@aws-cdk/core:stackRelativeExports": true,
"@aws-cdk/aws-rds:lowercaseDbIdentifier": true,
"@aws-cdk/aws-lambda:recognizeVersionProps": true,
"@aws-cdk/aws-cloudfront:defaultSecurityPolicyTLSv1.2_2021": true,
"@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true,
"@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true,
"@aws-cdk/core:checkSecretUsage": true,
"@aws-cdk/aws-iam:minimizePolicies": true,
"@aws-cdk/core:target-partitions": [
"aws",
"aws-cn"
]
}
}
8 months ago
8 months ago
7 months ago
7 months ago
7 months ago
7 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
7 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
10 months ago
8 months ago
8 months ago
10 months ago
8 months ago
8 months ago
8 months ago
10 months ago
10 months ago
8 months ago
10 months ago
8 months ago
10 months ago
8 months ago
8 months ago
8 months ago
7 months ago
7 months ago
7 months ago
10 months ago
10 months ago
7 months ago
7 months ago
10 months ago
10 months ago
10 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago