@terra-graph/conventions-aws 1.0.0-rc.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/CHANGELOG.md +35 -0
- package/README.md +25 -0
- package/dist/cjs/conventions/dataflow/profiles/base.js +89 -0
- package/dist/cjs/conventions/dataflow/profiles/dot.js +44 -0
- package/dist/cjs/conventions/dataflow/profiles/dot.test.js +147 -0
- package/dist/cjs/conventions/dataflow/rules.js +4 -0
- package/dist/cjs/conventions/dataflow/rules.test.js +11 -0
- package/dist/cjs/conventions/dataflow/rulesets.js +751 -0
- package/dist/cjs/conventions/dataflow/rulesets.test.js +27 -0
- package/dist/cjs/conventions/index.js +7 -0
- package/dist/cjs/conventions/index.test.js +8 -0
- package/dist/cjs/index.js +70 -0
- package/dist/cjs/index.test.js +58 -0
- package/dist/cjs/namespaces.js +14 -0
- package/dist/cjs/namespaces.test.js +17 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/plugins/AwsApiGateway.js +218 -0
- package/dist/cjs/plugins/AwsApiGateway.test.js +427 -0
- package/dist/cjs/plugins/AwsIam.js +432 -0
- package/dist/cjs/plugins/AwsIam.test.js +468 -0
- package/dist/cjs/plugins/AwsS3.js +107 -0
- package/dist/cjs/plugins/AwsS3.test.js +102 -0
- package/dist/cjs/plugins/AwsSns.js +52 -0
- package/dist/cjs/plugins/AwsSns.test.js +55 -0
- package/dist/cjs/plugins/AwsTransferFamily.js +105 -0
- package/dist/cjs/plugins/AwsTransferFamily.test.js +279 -0
- package/dist/cjs/rules/dot.js +36 -0
- package/dist/cjs/rules/dot.test.js +42 -0
- package/dist/cjs/rules/general.js +69 -0
- package/dist/cjs/rules/general.test.js +47 -0
- package/dist/cjs/rulesets/dot.js +25 -0
- package/dist/cjs/rulesets/dot.test.js +48 -0
- package/dist/esm/conventions/dataflow/profiles/base.d.ts +4 -0
- package/dist/esm/conventions/dataflow/profiles/base.js +86 -0
- package/dist/esm/conventions/dataflow/profiles/dot.d.ts +4 -0
- package/dist/esm/conventions/dataflow/profiles/dot.js +38 -0
- package/dist/esm/conventions/dataflow/profiles/dot.test.d.ts +1 -0
- package/dist/esm/conventions/dataflow/profiles/dot.test.js +109 -0
- package/dist/esm/conventions/dataflow/rules.d.ts +3 -0
- package/dist/esm/conventions/dataflow/rules.js +2 -0
- package/dist/esm/conventions/dataflow/rules.test.d.ts +1 -0
- package/dist/esm/conventions/dataflow/rules.test.js +6 -0
- package/dist/esm/conventions/dataflow/rulesets.d.ts +3 -0
- package/dist/esm/conventions/dataflow/rulesets.js +749 -0
- package/dist/esm/conventions/dataflow/rulesets.test.d.ts +1 -0
- package/dist/esm/conventions/dataflow/rulesets.test.js +22 -0
- package/dist/esm/conventions/index.d.ts +3 -0
- package/dist/esm/conventions/index.js +4 -0
- package/dist/esm/conventions/index.test.d.ts +1 -0
- package/dist/esm/conventions/index.test.js +6 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.js +32 -0
- package/dist/esm/index.test.d.ts +1 -0
- package/dist/esm/index.test.js +53 -0
- package/dist/esm/namespaces.d.ts +7 -0
- package/dist/esm/namespaces.js +6 -0
- package/dist/esm/namespaces.test.d.ts +1 -0
- package/dist/esm/namespaces.test.js +15 -0
- package/dist/esm/plugins/AwsApiGateway.d.ts +6 -0
- package/dist/esm/plugins/AwsApiGateway.js +214 -0
- package/dist/esm/plugins/AwsApiGateway.test.d.ts +1 -0
- package/dist/esm/plugins/AwsApiGateway.test.js +425 -0
- package/dist/esm/plugins/AwsIam.d.ts +32 -0
- package/dist/esm/plugins/AwsIam.js +428 -0
- package/dist/esm/plugins/AwsIam.test.d.ts +1 -0
- package/dist/esm/plugins/AwsIam.test.js +466 -0
- package/dist/esm/plugins/AwsS3.d.ts +12 -0
- package/dist/esm/plugins/AwsS3.js +103 -0
- package/dist/esm/plugins/AwsS3.test.d.ts +1 -0
- package/dist/esm/plugins/AwsS3.test.js +100 -0
- package/dist/esm/plugins/AwsSns.d.ts +6 -0
- package/dist/esm/plugins/AwsSns.js +48 -0
- package/dist/esm/plugins/AwsSns.test.d.ts +1 -0
- package/dist/esm/plugins/AwsSns.test.js +53 -0
- package/dist/esm/plugins/AwsTransferFamily.d.ts +6 -0
- package/dist/esm/plugins/AwsTransferFamily.js +101 -0
- package/dist/esm/plugins/AwsTransferFamily.test.d.ts +1 -0
- package/dist/esm/plugins/AwsTransferFamily.test.js +277 -0
- package/dist/esm/rules/dot.d.ts +3 -0
- package/dist/esm/rules/dot.js +34 -0
- package/dist/esm/rules/dot.test.d.ts +1 -0
- package/dist/esm/rules/dot.test.js +37 -0
- package/dist/esm/rules/general.d.ts +3 -0
- package/dist/esm/rules/general.js +67 -0
- package/dist/esm/rules/general.test.d.ts +1 -0
- package/dist/esm/rules/general.test.js +42 -0
- package/dist/esm/rulesets/dot.d.ts +3 -0
- package/dist/esm/rulesets/dot.js +23 -0
- package/dist/esm/rulesets/dot.test.d.ts +1 -0
- package/dist/esm/rulesets/dot.test.js +43 -0
- package/package.json +45 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@terra-graph/core");
|
|
4
|
+
const namespaces_js_1 = require("../namespaces.js");
|
|
5
|
+
exports.default = new core_1.NamedRuleSetRegistry({
|
|
6
|
+
[(0, namespaces_js_1.ruleSetName)('dot.sqs.dlq')]: new core_1.RuleSet({
|
|
7
|
+
rules: [
|
|
8
|
+
{ namedRule: (0, namespaces_js_1.ruleName)('dot.sqs.dlq.align') },
|
|
9
|
+
new core_1.EdgeLegend({
|
|
10
|
+
options: {
|
|
11
|
+
colour: '#c20202',
|
|
12
|
+
title: 'SQS dead letters / failures',
|
|
13
|
+
},
|
|
14
|
+
edge: {
|
|
15
|
+
from: {
|
|
16
|
+
attr: { key: 'terraform.resource', eq: 'aws_sqs_queue' },
|
|
17
|
+
},
|
|
18
|
+
to: {
|
|
19
|
+
attr: { key: 'terraform.resource', eq: 'aws_sqs_queue' },
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
}),
|
|
23
|
+
],
|
|
24
|
+
}),
|
|
25
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const namespaces_js_1 = require("../namespaces.js");
|
|
7
|
+
const dot_js_1 = __importDefault(require("../rules/dot.js"));
|
|
8
|
+
const dot_js_2 = __importDefault(require("./dot.js"));
|
|
9
|
+
describe('dot rule sets', () => {
|
|
10
|
+
it('shoud expose the SQS dead-letter rule set', () => {
|
|
11
|
+
const name = (0, namespaces_js_1.ruleSetName)('dot.sqs.dlq');
|
|
12
|
+
expect(dot_js_2.default.names()).toEqual([name]);
|
|
13
|
+
const resolved = dot_js_2.default.resolve(name);
|
|
14
|
+
const phases = resolved.resolvePhases(dot_js_1.default);
|
|
15
|
+
expect(phases).toHaveLength(1);
|
|
16
|
+
expect(phases[0]).toHaveLength(2);
|
|
17
|
+
expect(phases[0][0].serialize()).toStrictEqual({
|
|
18
|
+
id: 'AlignNodes',
|
|
19
|
+
config: {
|
|
20
|
+
edge: {
|
|
21
|
+
from: {
|
|
22
|
+
attr: { key: 'terraform.resource', eq: 'aws_sqs_queue' },
|
|
23
|
+
},
|
|
24
|
+
to: {
|
|
25
|
+
attr: { key: 'terraform.resource', eq: 'aws_sqs_queue' },
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
expect(phases[0][1]).toMatchObject({
|
|
31
|
+
serialize: expect.any(Function),
|
|
32
|
+
});
|
|
33
|
+
expect(phases[0][1].serialize().id).toBe('EdgeLegend');
|
|
34
|
+
expect(phases[0][1].serialize().config.options).toMatchObject({
|
|
35
|
+
colour: '#c20202',
|
|
36
|
+
title: 'SQS dead letters / failures',
|
|
37
|
+
});
|
|
38
|
+
const edgeLegend = phases[0][1].serialize();
|
|
39
|
+
if (!('edge' in edgeLegend.config)) {
|
|
40
|
+
throw new Error('Expected EdgeLegend to provide an edge config');
|
|
41
|
+
}
|
|
42
|
+
expect(edgeLegend.config.edge).toMatchObject({
|
|
43
|
+
from: {
|
|
44
|
+
attr: { key: 'terraform.resource', eq: 'aws_sqs_queue' },
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
});
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { coreBase } from '@terra-graph/conventions-core';
|
|
2
|
+
import { Profile, RemoveNode } from '@terra-graph/core';
|
|
3
|
+
import { conventionName, profileName, ruleName, ruleSetName } from '../../../namespaces.js';
|
|
4
|
+
import { AwsIamGraphPlugin } from '../../../plugins/AwsIam.js';
|
|
5
|
+
import { AwsS3 } from '../../../plugins/AwsS3.js';
|
|
6
|
+
import { Convention } from '../../index.js';
|
|
7
|
+
export const conventionDataFlowBaseProfileName = conventionName(Convention.DataFlow, profileName('base'));
|
|
8
|
+
export default new Profile(conventionDataFlowBaseProfileName, {
|
|
9
|
+
usesProfiles: [coreBase],
|
|
10
|
+
phases: [
|
|
11
|
+
{
|
|
12
|
+
phase: 'pre',
|
|
13
|
+
rules: [
|
|
14
|
+
new RemoveNode({
|
|
15
|
+
node: {
|
|
16
|
+
or: [
|
|
17
|
+
{
|
|
18
|
+
attr: {
|
|
19
|
+
key: 'terraform.resource',
|
|
20
|
+
startsWith: ['aws_kms_', 'aws_ssm_'],
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
attr: {
|
|
25
|
+
key: 'terraform.resource',
|
|
26
|
+
in: ['external', 'aws_caller_identity'],
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
}),
|
|
32
|
+
// { namedRule: ruleName('log_groups.only_event_bridge') },
|
|
33
|
+
{ namedRule: ruleName('lambda.only_event_source_mapping') },
|
|
34
|
+
],
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
phase: 'semantics',
|
|
38
|
+
rules: [{ namedRuleSet: conventionName(Convention.DataFlow, ruleSetName('semantics')) }],
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
phase: 'cleanup',
|
|
42
|
+
rules: [
|
|
43
|
+
// not sure this semantics re-run is needed?
|
|
44
|
+
{ namedRuleSet: conventionName(Convention.DataFlow, ruleSetName('semantics')) },
|
|
45
|
+
{ namedRuleSet: conventionName(Convention.DataFlow, ruleSetName('cleanup')) },
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
phase: 'main',
|
|
50
|
+
rules: [
|
|
51
|
+
// TODO: ConvertNodeToEdge probably should apply some hints to the edge (converted node etc)
|
|
52
|
+
// new ConvertNodeToEdge({
|
|
53
|
+
// node: {
|
|
54
|
+
// attr: {
|
|
55
|
+
// key: 'terraform.resource',
|
|
56
|
+
// in: [
|
|
57
|
+
// 'aws_lambda_event_source_mapping',
|
|
58
|
+
// 'aws_cloudwatch_event_target',
|
|
59
|
+
// 'aws_cloudwatch_log_destination',
|
|
60
|
+
// ],
|
|
61
|
+
// },
|
|
62
|
+
// },
|
|
63
|
+
// }),
|
|
64
|
+
],
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
plugins: [
|
|
68
|
+
{ plugin: AwsS3.id },
|
|
69
|
+
{
|
|
70
|
+
plugin: AwsIamGraphPlugin.id,
|
|
71
|
+
options: { mode: 'full', removeOrphans: true },
|
|
72
|
+
},
|
|
73
|
+
// { plugin: 'aws.iam', options: { mode: 'full' } },
|
|
74
|
+
// {
|
|
75
|
+
// plugin: 'aws.iam',
|
|
76
|
+
// options: { mode: 'roles_policies', attachments: 'convert_to_edge' },
|
|
77
|
+
// }, // can't see any difference
|
|
78
|
+
// { plugin: 'aws.iam', options: { mode: 'full' } }, // shows everything as expected
|
|
79
|
+
// {
|
|
80
|
+
// plugin: 'aws.iam',
|
|
81
|
+
// options: {
|
|
82
|
+
// mode: 'full',
|
|
83
|
+
// },
|
|
84
|
+
// },
|
|
85
|
+
],
|
|
86
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { DotAdapter, Profile } from '@terra-graph/core';
|
|
2
|
+
import { conventionName, profileName, ruleName, ruleSetName } from '../../../namespaces.js';
|
|
3
|
+
import { Convention } from '../../index.js';
|
|
4
|
+
import base from './base.js';
|
|
5
|
+
export const conventionDataFlowDotProfileName = conventionName(Convention.DataFlow, profileName('dot'));
|
|
6
|
+
const baseDotProfile = new Profile('overview.dot', {
|
|
7
|
+
supports: DotAdapter,
|
|
8
|
+
render: {
|
|
9
|
+
options: {
|
|
10
|
+
graph: {
|
|
11
|
+
rankdir: 'LR',
|
|
12
|
+
ranksep: 2.5,
|
|
13
|
+
nodesep: 0.6,
|
|
14
|
+
pad: 1,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
phases: [
|
|
19
|
+
{
|
|
20
|
+
phase: 'normalize',
|
|
21
|
+
rules: [{ namedRule: 'dot.normalise_modules' }],
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
});
|
|
25
|
+
export default new Profile(conventionDataFlowDotProfileName, {
|
|
26
|
+
supports: DotAdapter,
|
|
27
|
+
usesProfiles: [base, baseDotProfile],
|
|
28
|
+
phases: [
|
|
29
|
+
{
|
|
30
|
+
phase: 'main',
|
|
31
|
+
rules: [
|
|
32
|
+
{ namedRuleSet: ruleSetName('dot.sqs.dlq') },
|
|
33
|
+
{ namedRule: ruleName('dot.schedule.align') },
|
|
34
|
+
{ namedRule: ruleName('dot.iam_role.align') },
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { DotAdapter, NamedRuleRegistry, NamedRuleSetRegistry, NodeDotProperties, RemoveNode, RemoveNodeAndReconnectEdges, } from '@terra-graph/core';
|
|
2
|
+
import createRuntimeProvider from '../../../index.js';
|
|
3
|
+
import { conventionName, profileName, ruleName, ruleSetName } from '../../../namespaces.js';
|
|
4
|
+
import { AwsIamGraphPlugin } from '../../../plugins/AwsIam.js';
|
|
5
|
+
import { AwsS3 } from '../../../plugins/AwsS3.js';
|
|
6
|
+
import { Convention } from '../../index.js';
|
|
7
|
+
import dataFlowConventionRules from '../rules.js';
|
|
8
|
+
import dataFlowConventionRuleSet from '../rulesets.js';
|
|
9
|
+
import conventionDataFlowDotProfile, { conventionDataFlowDotProfileName } from './dot.js';
|
|
10
|
+
const baseNamedRules = new NamedRuleRegistry({
|
|
11
|
+
'remove.tfconfig': new RemoveNode({
|
|
12
|
+
node: {
|
|
13
|
+
or: [
|
|
14
|
+
{
|
|
15
|
+
attr: {
|
|
16
|
+
key: 'terraform.kind',
|
|
17
|
+
in: ['local', 'var', 'terraform_data'],
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
attr: {
|
|
22
|
+
key: 'terraform.resource',
|
|
23
|
+
in: ['null_resource', 'local_file'],
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
}),
|
|
29
|
+
'reconnect.time_sleep': new RemoveNodeAndReconnectEdges({
|
|
30
|
+
node: {
|
|
31
|
+
attr: {
|
|
32
|
+
key: 'terraform.resource',
|
|
33
|
+
eq: 'time_sleep',
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
}),
|
|
37
|
+
'remove.childless_modules': new RemoveNode({
|
|
38
|
+
node: {
|
|
39
|
+
and: [{ attr: { key: 'terraform.kind', eq: 'module' } }, { children: { exists: false } }],
|
|
40
|
+
},
|
|
41
|
+
}),
|
|
42
|
+
'dot.normalise_modules': new NodeDotProperties({
|
|
43
|
+
options: {
|
|
44
|
+
peripheries: 0,
|
|
45
|
+
label: '',
|
|
46
|
+
height: 0,
|
|
47
|
+
width: 0,
|
|
48
|
+
},
|
|
49
|
+
node: {
|
|
50
|
+
attr: {
|
|
51
|
+
key: 'terraform.kind',
|
|
52
|
+
eq: 'module',
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
}),
|
|
56
|
+
});
|
|
57
|
+
const baseNamedRuleSets = new NamedRuleSetRegistry({});
|
|
58
|
+
describe('data flow dot profile', () => {
|
|
59
|
+
it('shoud expose namespaced profile metadata and plugin refs', () => {
|
|
60
|
+
const serialized = conventionDataFlowDotProfile.serialize();
|
|
61
|
+
expect(serialized.name).toBe(conventionDataFlowDotProfileName);
|
|
62
|
+
expect(serialized.supports).toBe(DotAdapter.name);
|
|
63
|
+
expect(serialized.phases?.map((phase) => phase.phase)).toStrictEqual(['main']);
|
|
64
|
+
const baseProfile = serialized.usesProfiles?.[0];
|
|
65
|
+
expect(baseProfile?.phases?.map((phase) => phase.phase)).toStrictEqual([
|
|
66
|
+
'pre',
|
|
67
|
+
'semantics',
|
|
68
|
+
'cleanup',
|
|
69
|
+
'main',
|
|
70
|
+
]);
|
|
71
|
+
expect(baseProfile?.plugins).toEqual([
|
|
72
|
+
{ plugin: AwsS3.id },
|
|
73
|
+
{
|
|
74
|
+
plugin: AwsIamGraphPlugin.id,
|
|
75
|
+
options: { mode: 'full', removeOrphans: true },
|
|
76
|
+
},
|
|
77
|
+
]);
|
|
78
|
+
expect(conventionDataFlowDotProfileName).toBe(conventionName(Convention.DataFlow, profileName('dot')));
|
|
79
|
+
});
|
|
80
|
+
it('shoud resolve phase plan with runtime provider registries', () => {
|
|
81
|
+
const runtime = createRuntimeProvider();
|
|
82
|
+
const runtimeNamedRules = runtime.namedRules;
|
|
83
|
+
const runtimeNamedRuleSets = runtime.namedRuleSets;
|
|
84
|
+
const runtimePlugins = runtime.plugins;
|
|
85
|
+
if (!runtimeNamedRules || !runtimeNamedRuleSets || !runtimePlugins) {
|
|
86
|
+
throw new Error('Runtime provider missing expected registries');
|
|
87
|
+
}
|
|
88
|
+
const namedRules = NamedRuleRegistry.from([baseNamedRules, runtimeNamedRules]);
|
|
89
|
+
const namedRuleSets = NamedRuleSetRegistry.from([baseNamedRuleSets, runtimeNamedRuleSets]);
|
|
90
|
+
const phases = conventionDataFlowDotProfile.resolvePhases(namedRules, namedRuleSets, runtimePlugins);
|
|
91
|
+
expect(phases.length).toBeGreaterThan(4);
|
|
92
|
+
expect(phases.map((rules) => rules.some((rule) => rule.serialize().id === 'EdgeLegend'))).toContain(true);
|
|
93
|
+
});
|
|
94
|
+
it('shoud reference conventions rules and rule sets from the dataflow profile', () => {
|
|
95
|
+
const baseProfile = conventionDataFlowDotProfile.serialize().usesProfiles?.[0];
|
|
96
|
+
const preRules = baseProfile?.phases?.[0]?.rules;
|
|
97
|
+
const mainRules = conventionDataFlowDotProfile.serialize().phases?.[0]?.rules;
|
|
98
|
+
expect(preRules).toEqual(expect.arrayContaining([
|
|
99
|
+
expect.objectContaining({ id: 'RemoveNode' }),
|
|
100
|
+
{ namedRule: ruleName('lambda.only_event_source_mapping') },
|
|
101
|
+
]));
|
|
102
|
+
expect(mainRules).toEqual(expect.arrayContaining([
|
|
103
|
+
{ namedRuleSet: ruleSetName('dot.sqs.dlq') },
|
|
104
|
+
{ namedRule: ruleName('dot.schedule.align') },
|
|
105
|
+
]));
|
|
106
|
+
expect(dataFlowConventionRuleSet.names()).toContain(conventionName(Convention.DataFlow, ruleSetName('semantics')));
|
|
107
|
+
expect(dataFlowConventionRules.names()).toEqual([]);
|
|
108
|
+
});
|
|
109
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|