Skip to content
Merged
Show file tree
Hide file tree
Changes from 77 commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
7b8bac4
Create db v2 component
mandryllo Dec 2, 2025
396e648
Remove ability to create custom parameter group
mandryllo Dec 5, 2025
b295e28
Cleanup
mandryllo Dec 5, 2025
35bc5cb
Fix kms key id type
mandryllo Dec 5, 2025
19c3ece
Cleanup
mandryllo Dec 5, 2025
ce83def
Cleanup vpc parameters
mandryllo Dec 5, 2025
292b549
Cleanup types
mandryllo Dec 5, 2025
d4120ce
Fix formatting
mandryllo Dec 5, 2025
b09a6c0
Cleanup
mandryllo Dec 8, 2025
53061fe
Create db builder component
mandryllo Dec 2, 2025
c32427b
Fix typo
mandryllo Dec 3, 2025
cb12a13
Remove custom parameter group args
mandryllo Dec 5, 2025
784af7f
Cleanup private props
mandryllo Dec 5, 2025
4df9363
Remove parameter group name from builder
mandryllo Dec 5, 2025
b439523
Cleanup naming
mandryllo Dec 5, 2025
0195797
Fix formatting
mandryllo Dec 5, 2025
2d399cf
Cleanup
mandryllo Dec 8, 2025
b17a54f
Expose db v2 components
mandryllo Dec 3, 2025
def9885
Add type tests
mandryllo Dec 8, 2025
9cc3856
Add default db tests
mandryllo Dec 8, 2025
bb298bc
Cleanup database types
mandryllo Dec 10, 2025
6af2d1b
Cleanup
mandryllo Dec 10, 2025
950fe1a
Revert allocatedStorage type to number
mandryllo Dec 10, 2025
ff389f9
Remove withKms method from builder
mandryllo Dec 10, 2025
817f100
Update type tests
mandryllo Dec 10, 2025
0605888
Update integration tests
mandryllo Dec 10, 2025
15927fe
fix tags
mandryllo Dec 10, 2025
f72366f
Fix snapshot id
mandryllo Dec 10, 2025
3b4d3e5
Remove export
mandryllo Dec 10, 2025
ef9fea4
Fix imports in tests
mandryllo Dec 10, 2025
c826e12
Fix wrong condition
mandryllo Dec 11, 2025
20a59e3
Cleanup final snapshots
mandryllo Dec 15, 2025
3648874
Fix getting snapshots
mandryllo Dec 15, 2025
3bba784
Update database builder
mandryllo Dec 16, 2025
3602506
Cleanup
mandryllo Dec 16, 2025
7822894
Fix type tests
mandryllo Dec 16, 2025
3107de3
Create db v2 component
mandryllo Dec 2, 2025
e0cae9b
Remove ability to create custom parameter group
mandryllo Dec 5, 2025
117e798
Cleanup
mandryllo Dec 5, 2025
7c2b479
Fix kms key id type
mandryllo Dec 5, 2025
06fe2d8
Cleanup
mandryllo Dec 5, 2025
17f5e9e
Cleanup vpc parameters
mandryllo Dec 5, 2025
f491332
Cleanup types
mandryllo Dec 5, 2025
9056cf8
Fix formatting
mandryllo Dec 5, 2025
75308bc
Cleanup
mandryllo Dec 8, 2025
3ba47f5
Create db builder component
mandryllo Dec 2, 2025
6b0648f
Fix typo
mandryllo Dec 3, 2025
65f030a
Remove custom parameter group args
mandryllo Dec 5, 2025
bfec1fc
Cleanup private props
mandryllo Dec 5, 2025
a48d054
Remove parameter group name from builder
mandryllo Dec 5, 2025
379dc30
Cleanup naming
mandryllo Dec 5, 2025
14d208b
Fix formatting
mandryllo Dec 5, 2025
c629546
Cleanup
mandryllo Dec 8, 2025
6906eb4
Cleanup database types
mandryllo Dec 10, 2025
8f5939e
Cleanup
mandryllo Dec 10, 2025
80804be
Revert allocatedStorage type to number
mandryllo Dec 10, 2025
98fb66b
Remove withKms method from builder
mandryllo Dec 10, 2025
5cfb8f9
fix tags
mandryllo Dec 10, 2025
823598e
Fix snapshot id
mandryllo Dec 10, 2025
9d7d045
Fix wrong condition
mandryllo Dec 11, 2025
1937146
Update database builder
mandryllo Dec 16, 2025
311d792
Cleanup
mandryllo Dec 16, 2025
b43859c
Move applyImmediately to instance config
mandryllo Dec 16, 2025
62b03d9
Update builder methods
mandryllo Dec 16, 2025
e8a017b
Update tests
mandryllo Dec 16, 2025
f9fdc02
Move kms key from storage type
mandryllo Dec 16, 2025
6467dff
Update builder
mandryllo Dec 16, 2025
3375e86
Cleanup default tests
mandryllo Dec 16, 2025
dce0103
Fix allocated storage type
mandryllo Dec 16, 2025
a783195
Revert "Fix allocated storage type"
mandryllo Dec 16, 2025
41783a5
Update after merge
mandryllo Dec 19, 2025
6f9884f
Add custom db tests
mandryllo Dec 16, 2025
54ca753
Merge branch 'master' into feat/db-v2-tests
mandryllo Jan 12, 2026
b70eb78
Cleanup
mandryllo Jan 12, 2026
b3e2bc8
Merge branch 'master' into feat/db-v2-tests
mandryllo Jan 12, 2026
b0d1817
Merge branch 'feat/db-v2-tests' into feat/custom-db-v2-tests
mandryllo Jan 12, 2026
8f7df17
Cleanup
mandryllo Jan 12, 2026
dd0efc7
Merge branch 'master' into feat/db-v2-tests
mandryllo Jan 13, 2026
d760f4e
Resolve comments
mandryllo Jan 14, 2026
242e60f
Merge branch 'master' into feat/db-v2-tests
mandryllo Jan 14, 2026
44df91e
Update dependecies
mandryllo Jan 14, 2026
39160de
Merge branch 'feat/db-v2-tests' into feat/custom-db-v2-tests
mandryllo Jan 14, 2026
c7c47fe
Rename custom to configurable
mandryllo Jan 14, 2026
790d762
Cleanup
mandryllo Jan 14, 2026
23cf048
Merge branch 'master' into feat/db-v2-tests
mandryllo Jan 15, 2026
71f458f
Merge branch 'feat/db-v2-tests' into feat/custom-db-v2-tests
mandryllo Jan 15, 2026
5befbf0
Fix typo
mandryllo Jan 15, 2026
bb0f995
Add parent
mandryllo Jan 15, 2026
5dd8521
Merge branch 'feat/db-v2-tests' into feat/custom-db-v2-tests
mandryllo Jan 15, 2026
31acb68
Merge branch 'master' into feat/db-v2-tests
mandryllo Jan 16, 2026
c17d9e1
Merge branch 'feat/db-v2-tests' into feat/custom-db-v2-tests
mandryllo Jan 16, 2026
1ee6a4a
Merge branch 'master' into feat/custom-db-v2-tests
mandryllo Jan 16, 2026
1062118
Merge branch 'master' into feat/custom-db-v2-tests
mandryllo Jan 16, 2026
69dd9c2
refactor: update aws import
mandryllo Jan 20, 2026
ef13c7f
Merge branch 'master' into feat/custom-db-v2-tests
mandryllo Jan 21, 2026
5bed70e
Add test if database is created
mandryllo Jan 21, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,505 changes: 2,269 additions & 236 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
"@aws-sdk/client-efs": "^3.758.0",
"@aws-sdk/client-elastic-load-balancing-v2": "^3.764.0",
"@aws-sdk/client-elasticache": "^3.901.0",
"@aws-sdk/client-iam": "^3.952.0",
"@aws-sdk/client-kms": "^3.943.0",
"@aws-sdk/client-rds": "^3.943.0",
"@aws-sdk/client-route-53": "^3.782.0",
"@aws-sdk/client-secrets-manager": "^3.906.0",
"@aws-sdk/client-servicediscovery": "^3.758.0",
Expand Down
85 changes: 85 additions & 0 deletions tests/build/index.tst.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { describe, expect, it } from 'tstyche';
import { next as studion } from '@studion/infra-code-blocks';
import { OtelCollector } from '../../dist/v2/otel';
import { OtelCollectorBuilder } from '../../dist/v2/otel/builder';
import { Database } from '../../dist/v2/components/database';
import { DatabaseBuilder } from '../../dist/v2/components/database/builder';

describe('Build output', () => {
describe('ECS Service', () => {
Expand Down Expand Up @@ -258,4 +260,87 @@ describe('Build output', () => {
});
});
});

describe('Database', () => {
it.skip('should export Database', () => {
expect(studion).type.toHaveProperty('Database');
});

it.skip('should export DatabaseBuilder', () => {
expect(studion).type.toHaveProperty('DatabaseBuilder');
});

describe('Instantiation', () => {
it('should construct Database', () => {
expect(Database).type.toBeConstructableWith('db-test', {
vpc: new awsx.ec2.Vpc('vpcName'),
dbName: 'dbName',
username: 'username',
});
});

it('should construct DatabaseBuilder', () => {
expect(DatabaseBuilder).type.toBeConstructableWith('db-test');
});
});

describe('Builder', () => {
const builder = new DatabaseBuilder('db-test');

it('should have build method', () => {
expect(builder.build).type.toBeCallableWith();
});

it('should have withInstance method', () => {
expect(builder.withInstance).type.toBeCallableWith({
dbName: 'dbName',
});
});

it('should have withCredentials method', () => {
expect(builder.withCredentials).type.toBeCallableWith({
username: 'username',
password: 'password',
});
});

it('should have withStorage method', () => {
expect(builder.withStorage).type.toBeCallableWith({
allocatedStorage: 50,
maxAllocatedStorage: 200,
});
});

it('should have withVpc method', () => {
expect(builder.withVpc).type.toBeCallableWith(
new awsx.ec2.Vpc('vpcName'),
);
});

it('should have withMonitoring method', () => {
expect(builder.withMonitoring).type.toBeCallableWith();
});

it('should have withSnapshot method', () => {
expect(builder.withSnapshot).type.toBeCallableWith('snapshot-id');
});

it('should have withKms method', () => {
expect(builder.withKms).type.toBeCallableWith('kms-key-id');
});

it('should have withParameterGroup method', () => {
expect(builder.withParameterGroup).type.toBeCallableWith(
'parameter-group-name',
);
});

it('should have withTags method', () => {
expect(builder.withTags).type.toBeCallableWith({
Project: 'db-test',
Environment: 'dev',
});
});
});
});
});
145 changes: 145 additions & 0 deletions tests/database/custom-db.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
import {
GetRoleCommand,
ListAttachedRolePoliciesCommand,
} from '@aws-sdk/client-iam';
import * as assert from 'node:assert';
import { DatabaseTestContext } from './test-context';
import { it } from 'node:test';
import { ListTagsForResourceCommand } from '@aws-sdk/client-rds';

export function testCustomDb(ctx: DatabaseTestContext) {
it('should properly configure instance', () => {
const customDb = ctx.outputs.customDb.value;

assert.strictEqual(
customDb.instance.applyImmediately,
ctx.config.applyImmediately,
'Apply immediately argument should be set correctly',
);
assert.strictEqual(
customDb.instance.allowMajorVersionUpgrade,
ctx.config.allowMajorVersionUpgrade,
'Allow major version upgrade argument should be set correctly',
);
assert.strictEqual(
customDb.instance.autoMinorVersionUpgrade,
ctx.config.autoMinorVersionUpgrade,
'Auto minor version upgrade argument should be set correctly',
);
});

it('should properly configure password', () => {
const customDb = ctx.outputs.customDb.value;

assert.ok(customDb.password, 'Password should exist');
assert.strictEqual(
customDb.instance.masterUserPassword,
ctx.config.dbPassword,
'Master user password should be set correctly',
);
});

it('should properly configure storage', () => {
const customDb = ctx.outputs.customDb.value;

assert.strictEqual(
customDb.instance.allocatedStorage,
ctx.config.allocatedStorage.toString(),
'Allocated storage argument should be set correctly',
);
assert.strictEqual(
customDb.instance.maxAllocatedStorage,
ctx.config.maxAllocatedStorage,
'Max allocated storage argument should be set correctly',
);
});

it('should properly configure monitoring options', () => {
const customDb = ctx.outputs.customDb.value;

assert.strictEqual(
customDb.instance.enablePerformanceInsights,
true,
'Performance insights should be enabled',
);
assert.strictEqual(
customDb.instance.performanceInsightsRetentionPeriod,
7,
'Performance insights retention period should be set correctly',
);
assert.strictEqual(
customDb.instance.monitoringInterval,
60,
'Monitoring interval should be set correctly',
);
assert.ok(
customDb.instance.monitoringRoleArn,
'Monitoring role ARN should exist',
);
});

it('should create monitoring IAM role and attach correct policy', async () => {
const customDb = ctx.outputs.customDb.value;
const roleName = customDb.monitoringRole.name;

const roleCommand = new GetRoleCommand({
RoleName: roleName,
});
const { Role } = await ctx.clients.iam.send(roleCommand);
assert.ok(Role, 'Monitoring IAM role should exist');

const policyCommand = new ListAttachedRolePoliciesCommand({
RoleName: roleName,
});
const { AttachedPolicies } = await ctx.clients.iam.send(policyCommand);
assert.ok(
AttachedPolicies && AttachedPolicies.length > 0,
'Attached policies should exist',
);
const [attachedPolicy] = AttachedPolicies;
assert.strictEqual(
attachedPolicy.PolicyArn,
'arn:aws:iam::aws:policy/service-role/AmazonRDSEnhancedMonitoringRole',
'Monitoring IAM role should have correct policy attached',
);
});

it('should properly configure kms', () => {
const customDb = ctx.outputs.customDb.value;
const kms = ctx.outputs.kms.value;

assert.ok(customDb.kmsKeyId, 'Kms key id should exist');
assert.strictEqual(
customDb.instance.kmsKeyId,
kms.arn,
'Kms key id should be set correctly',
);
});

it('should properly configure parameter group', () => {
const customDb = ctx.outputs.customDb.value;
const paramGroup = ctx.outputs.paramGroup.value;

assert.strictEqual(
customDb.instance.dbParameterGroupName,
paramGroup.name,
'Parameter group name should be set correctly',
);
});

it('should properly configure tags', async () => {
const customDb = ctx.outputs.customDb.value;

const command = new ListTagsForResourceCommand({
ResourceName: customDb.instance.dbInstanceArn,
});
const { TagList } = await ctx.clients.rds.send(command);
assert.ok(TagList && TagList.length > 0, 'Tags should exist');

Object.entries(ctx.config.tags).map(([Key, Value]) => {
const tag = TagList.find(tag => tag.Key === Key);
assert.ok(tag, `${Key} tag should exist`);
assert.strictEqual(tag.Value, Value, `${Key} tag should set correctly`);
});
});
}
Loading