terruvim-core-test 0.0.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/dist/src/core/config.js +2 -0
- package/dist/src/core/configMerge.js +266 -0
- package/dist/src/core/configUtils.js +72 -0
- package/dist/src/core/dependencyResolver.js +17 -0
- package/dist/src/core/deployUtils.js +73 -0
- package/dist/src/core/dynamicResourceManager.js +709 -0
- package/dist/src/core/entrypoint.js +56 -0
- package/dist/src/core/generateFinalConfig.js +45 -0
- package/dist/src/core/index.js +24 -0
- package/dist/src/core/resourceMap.js +99 -0
- package/dist/src/factories/accountPermissions.js +134 -0
- package/dist/src/factories/acmFactory.js +30 -0
- package/dist/src/factories/albFactory.js +331 -0
- package/dist/src/factories/attachSecretAccessPolicy.js +56 -0
- package/dist/src/factories/auroraFactory.js +619 -0
- package/dist/src/factories/backupPolicy.js +152 -0
- package/dist/src/factories/bastionFactory.js +91 -0
- package/dist/src/factories/bedrockFactory.js +334 -0
- package/dist/src/factories/budgetFactory.js +64 -0
- package/dist/src/factories/buildAlbCloudWatchAlarmsHelper.js +79 -0
- package/dist/src/factories/buildAlbCloudWatchDashboardHelper.js +106 -0
- package/dist/src/factories/buildAlbListenerRulesHelper.js +45 -0
- package/dist/src/factories/buildAlbListenersHelper.js +64 -0
- package/dist/src/factories/buildAlbResourceHelper.js +54 -0
- package/dist/src/factories/buildAlbRoute53RecordHelper.js +49 -0
- package/dist/src/factories/buildAlbTargetGroupsHelper.js +47 -0
- package/dist/src/factories/buildAlbWafAssociationHelper.js +43 -0
- package/dist/src/factories/buildAndPushDockerImage.js +57 -0
- package/dist/src/factories/buildAwsCloudWatchAlarmsHelper.js +118 -0
- package/dist/src/factories/buildCloudFrontRoute53RecordHelper.js +49 -0
- package/dist/src/factories/buildEcsClusterArgs.js +32 -0
- package/dist/src/factories/buildEcsSecrets.js +48 -0
- package/dist/src/factories/buildForceRedeployEnv.js +8 -0
- package/dist/src/factories/buildResourceOptions.js +11 -0
- package/dist/src/factories/buildS3StaticHostingCicdHelper.js +142 -0
- package/dist/src/factories/buildS3StaticHostingCloudWatchDashboardHelper.js +122 -0
- package/dist/src/factories/cloudTrailFactory.js +22 -0
- package/dist/src/factories/cloudWatchCompositeAlarmFactory.js +91 -0
- package/dist/src/factories/cloudWatchInsightsQueryFactory.js +83 -0
- package/dist/src/factories/cloudWatchLogGroupFactory.js +84 -0
- package/dist/src/factories/cloudfrontCodePipelineFactory.js +357 -0
- package/dist/src/factories/cloudwatchAlarmsFactory.js +121 -0
- package/dist/src/factories/codePipelineNotificationFactory.js +193 -0
- package/dist/src/factories/codePipelineNotificationRulesFactory.js +117 -0
- package/dist/src/factories/codeStarConnectionFactory.js +56 -0
- package/dist/src/factories/collectSecretKeys.js +18 -0
- package/dist/src/factories/comprehensiveNotificationFactory.js +250 -0
- package/dist/src/factories/costAndUsageReportFactory.js +32 -0
- package/dist/src/factories/createAwsAcmCertificate.js +40 -0
- package/dist/src/factories/createAwsBudget.js +40 -0
- package/dist/src/factories/createAwsCloudTrail.js +59 -0
- package/dist/src/factories/createAwsCloudwatchDashboard.js +59 -0
- package/dist/src/factories/createAwsEc2Instance.js +40 -0
- package/dist/src/factories/createAwsEventBridgeEventBus.js +40 -0
- package/dist/src/factories/createAwsGuardDutyDetector.js +40 -0
- package/dist/src/factories/createAwsGuardDutyDetectorFeature.js +45 -0
- package/dist/src/factories/createAwsGuardDutyFilter.js +46 -0
- package/dist/src/factories/createAwsGuardDutyPublishingDestination.js +50 -0
- package/dist/src/factories/createAwsHostedZone.js +40 -0
- package/dist/src/factories/createAwsIamRole.js +49 -0
- package/dist/src/factories/createAwsIamRoleInlinePolicies.js +48 -0
- package/dist/src/factories/createAwsIdentitystoreGroup.js +44 -0
- package/dist/src/factories/createAwsIdentitystoreGroupMembership.js +56 -0
- package/dist/src/factories/createAwsIdentitystoreUser.js +47 -0
- package/dist/src/factories/createAwsInspectorAssessmentTarget.js +47 -0
- package/dist/src/factories/createAwsInspectorDelegatedAdminAccount.js +47 -0
- package/dist/src/factories/createAwsInspectorEnabler.js +49 -0
- package/dist/src/factories/createAwsInspectorOrganizationConfiguration.js +55 -0
- package/dist/src/factories/createAwsKmsAliases.js +47 -0
- package/dist/src/factories/createAwsKmsKey.js +51 -0
- package/dist/src/factories/createAwsMacieAccount.js +45 -0
- package/dist/src/factories/createAwsMacieClassificationJob.js +53 -0
- package/dist/src/factories/createAwsMacieMember.js +49 -0
- package/dist/src/factories/createAwsMacieOrganizationConfiguration.js +44 -0
- package/dist/src/factories/createAwsRdsCluster.js +40 -0
- package/dist/src/factories/createAwsRdsClusterInstance.js +40 -0
- package/dist/src/factories/createAwsRdsInstance.js +40 -0
- package/dist/src/factories/createAwsRdsSubnetGroup.js +40 -0
- package/dist/src/factories/createAwsRoute53Record.js +40 -0
- package/dist/src/factories/createAwsSecret.js +40 -0
- package/dist/src/factories/createAwsSecretRotation.js +40 -0
- package/dist/src/factories/createAwsSecretVersion.js +40 -0
- package/dist/src/factories/createAwsSecurityGroup.js +40 -0
- package/dist/src/factories/createAwsSecurityGroupRule.js +40 -0
- package/dist/src/factories/createAwsSecurityHubAccount.js +40 -0
- package/dist/src/factories/createAwsSecurityHubAutomationRule.js +48 -0
- package/dist/src/factories/createAwsSecurityHubStandardsControl.js +44 -0
- package/dist/src/factories/createAwsSecurityHubStandardsSubscription.js +42 -0
- package/dist/src/factories/createAwsSesDomainDkim.js +40 -0
- package/dist/src/factories/createAwsSesDomainIdentity.js +40 -0
- package/dist/src/factories/createAwsSesEmailIdentity.js +40 -0
- package/dist/src/factories/createAwsSnsSubscription.js +62 -0
- package/dist/src/factories/createAwsSnsTopic.js +41 -0
- package/dist/src/factories/createAwsSqsQueue.js +40 -0
- package/dist/src/factories/createAwsSsmParameters.js +66 -0
- package/dist/src/factories/createAwsSsoAccountAssignment.js +66 -0
- package/dist/src/factories/createAwsSsoPermissionSet.js +64 -0
- package/dist/src/factories/createAwsStepFunctionsStateMachine.js +40 -0
- package/dist/src/factories/createBudget.js +56 -0
- package/dist/src/factories/createBudgetWithSnsAlert.js +79 -0
- package/dist/src/factories/createCostAndUsageReport.js +40 -0
- package/dist/src/factories/createEcrRepo.js +69 -0
- package/dist/src/factories/createEcsRolesAndPolicies.js +84 -0
- package/dist/src/factories/createEcsService.js +71 -0
- package/dist/src/factories/createEnvSecret.js +60 -0
- package/dist/src/factories/createGithubCodeStarConnection.js +44 -0
- package/dist/src/factories/createIamUserWithAccessKey.js +44 -0
- package/dist/src/factories/createLambdaFunction.js +89 -0
- package/dist/src/factories/createLambdaPermission.js +57 -0
- package/dist/src/factories/createListenerRule.js +68 -0
- package/dist/src/factories/createLogGroup.js +44 -0
- package/dist/src/factories/createSlackChannelConfiguration.js +49 -0
- package/dist/src/factories/createTargetGroup.js +50 -0
- package/dist/src/factories/createTaskDefinition.js +49 -0
- package/dist/src/factories/createVpcEndpoint.js +49 -0
- package/dist/src/factories/dashboardFactory.js +94 -0
- package/dist/src/factories/dataProtectionPolicyBuilder.js +103 -0
- package/dist/src/factories/ec2Factory.js +67 -0
- package/dist/src/factories/ecsClusterFactory.js +90 -0
- package/dist/src/factories/ecsCodePipelineFactory.js +308 -0
- package/dist/src/factories/ecsServiceFactory.js +350 -0
- package/dist/src/factories/enhancedCloudFrontCodePipelineFactory.js +205 -0
- package/dist/src/factories/enhancedEcsCodePipelineFactory.js +189 -0
- package/dist/src/factories/eventBridgeBusFactory.js +84 -0
- package/dist/src/factories/eventBridgeFactory.js +26 -0
- package/dist/src/factories/eventBridgeRuleFactory.js +114 -0
- package/dist/src/factories/fetchAllSecrets.js +51 -0
- package/dist/src/factories/getDeterministicPriority.js +13 -0
- package/dist/src/factories/getOrCreateSshKeyPair.js +57 -0
- package/dist/src/factories/guardDutyFactory.js +151 -0
- package/dist/src/factories/hostedZoneFactory.js +30 -0
- package/dist/src/factories/iamRoleFactory.js +29 -0
- package/dist/src/factories/inspectorFactory.js +109 -0
- package/dist/src/factories/kmsKeyFactory.js +32 -0
- package/dist/src/factories/lambdaFactory.js +133 -0
- package/dist/src/factories/lambdaPermissionFactory.js +32 -0
- package/dist/src/factories/logDataProtectionPolicyFactory.js +81 -0
- package/dist/src/factories/macieFactory.js +85 -0
- package/dist/src/factories/networkingFactory.js +429 -0
- package/dist/src/factories/opensearchCollectionFactory.js +109 -0
- package/dist/src/factories/organizationFactory.js +221 -0
- package/dist/src/factories/processReservedInstances.js +6 -0
- package/dist/src/factories/processSavingsPlans.js +43 -0
- package/dist/src/factories/rdsFactory.js +40 -0
- package/dist/src/factories/recordFactory.js +36 -0
- package/dist/src/factories/resolveEnvSecrets.js +14 -0
- package/dist/src/factories/resourceFactory.js +12 -0
- package/dist/src/factories/s3Factory.js +262 -0
- package/dist/src/factories/s3StaticHostingFactory.backup.js +424 -0
- package/dist/src/factories/s3StaticHostingFactory.js +348 -0
- package/dist/src/factories/s3StaticHostingFactory.refactored.js +334 -0
- package/dist/src/factories/savingsPlanFactory.js +26 -0
- package/dist/src/factories/secretsManagerFactory.js +107 -0
- package/dist/src/factories/securityGroupFactory.js +28 -0
- package/dist/src/factories/securityGroupRuleFactory.js +43 -0
- package/dist/src/factories/securityHubFactory.js +96 -0
- package/dist/src/factories/sesDomainDkimFactory.js +25 -0
- package/dist/src/factories/sesFactory.js +25 -0
- package/dist/src/factories/sesIdentitiesFactory.js +134 -0
- package/dist/src/factories/simpleNotificationFactory.js +112 -0
- package/dist/src/factories/smtpUserFactory.js +108 -0
- package/dist/src/factories/snsFactory.js +87 -0
- package/dist/src/factories/sqsFactory.js +41 -0
- package/dist/src/factories/ssmParameterFactory.js +67 -0
- package/dist/src/factories/ssoFactory.js +32 -0
- package/dist/src/factories/ssoGroupFactory.js +41 -0
- package/dist/src/factories/ssoPermissionSetFactory.js +29 -0
- package/dist/src/factories/ssoUserFactory.js +30 -0
- package/dist/src/factories/stepFunctionsFactory.js +32 -0
- package/dist/src/factories/tagPolicies.js +99 -0
- package/dist/src/factories/transformBudgetCostFilters.js +8 -0
- package/dist/src/factories/transformBudgetNotifications.js +12 -0
- package/dist/src/factories/transformBudgetPlannedLimits.js +8 -0
- package/dist/src/factories/types.js +2 -0
- package/dist/src/factories/validateAcmConfig.js +26 -0
- package/dist/src/factories/validateAuroraConfig.js +8 -0
- package/dist/src/factories/validateBedrockConfig.js +124 -0
- package/dist/src/factories/validateDashboardConfig.js +28 -0
- package/dist/src/factories/validateEventBridgeConfig.js +14 -0
- package/dist/src/factories/validateHostedZoneConfig.js +26 -0
- package/dist/src/factories/validateIamRoleConfig.js +8 -0
- package/dist/src/factories/validateKmsKeyConfig.js +8 -0
- package/dist/src/factories/validateRdsConfig.js +17 -0
- package/dist/src/factories/validateRoute53RecordConfig.js +41 -0
- package/dist/src/factories/validateS3Config.js +8 -0
- package/dist/src/factories/validateSecretsManagerConfig.js +8 -0
- package/dist/src/factories/validateSecurityGroupConfig.js +8 -0
- package/dist/src/factories/validateSecurityGroupRuleConfig.js +8 -0
- package/dist/src/factories/validateSesDomainDkimConfig.js +8 -0
- package/dist/src/factories/validateSesDomainIdentityConfig.js +8 -0
- package/dist/src/factories/validateSesIdentitiesConfig.js +40 -0
- package/dist/src/factories/validateSnsConfig.js +11 -0
- package/dist/src/factories/validateSqsConfig.js +11 -0
- package/dist/src/factories/validateSsmParameterFactoryConfig.js +9 -0
- package/dist/src/factories/validateStepFunctionsConfig.js +8 -0
- package/dist/src/factories/vpcEndpointFactory.js +98 -0
- package/dist/src/factories/wafFactory.js +499 -0
- package/package.json +71 -0
- package/scripts/copy-assets.js +136 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.LogDataProtectionPolicyFactory = void 0;
|
|
37
|
+
const aws = __importStar(require("@pulumi/aws"));
|
|
38
|
+
const resourceFactory_1 = require("./resourceFactory");
|
|
39
|
+
const dataProtectionPolicyBuilder_1 = require("./dataProtectionPolicyBuilder");
|
|
40
|
+
class LogDataProtectionPolicyFactory extends resourceFactory_1.ResourceFactory {
|
|
41
|
+
async createResource(config, provider) {
|
|
42
|
+
this.validateConfig(config);
|
|
43
|
+
if (!config.configuration.dataProtection?.enabled) {
|
|
44
|
+
throw new Error(`Data protection must be enabled for ${config.id}`);
|
|
45
|
+
}
|
|
46
|
+
const dataProtectionPolicy = this.buildDataProtectionPolicy(config);
|
|
47
|
+
const policy = new aws.cloudwatch.LogDataProtectionPolicy(`${config.id}-data-protection-policy`, {
|
|
48
|
+
logGroupName: config.configuration.logGroupName,
|
|
49
|
+
policyDocument: JSON.stringify(dataProtectionPolicy),
|
|
50
|
+
}, provider ? { provider } : undefined);
|
|
51
|
+
return policy;
|
|
52
|
+
}
|
|
53
|
+
getOutputs(resource) {
|
|
54
|
+
return {
|
|
55
|
+
policyId: resource.id,
|
|
56
|
+
logGroupName: resource.logGroupName,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
buildDataProtectionPolicy(config) {
|
|
60
|
+
const dataProtectionConfig = {
|
|
61
|
+
enabled: config.configuration.dataProtection.enabled,
|
|
62
|
+
policy: config.configuration.dataProtection.policy,
|
|
63
|
+
auditLogGroup: config.configuration.dataProtection.auditLogGroup,
|
|
64
|
+
enableAudit: config.configuration.dataProtection.enableAudit,
|
|
65
|
+
enableRedaction: config.configuration.dataProtection.enableRedaction,
|
|
66
|
+
dataIdentifiers: config.configuration.dataProtection.dataIdentifiers,
|
|
67
|
+
customDataIdentifiers: config.configuration.dataProtection.customDataIdentifiers,
|
|
68
|
+
operations: config.configuration.dataProtection.operations,
|
|
69
|
+
};
|
|
70
|
+
return (0, dataProtectionPolicyBuilder_1.buildDataProtectionPolicy)(dataProtectionConfig, config.configuration.logGroupName, dataProtectionPolicyBuilder_1.DEFAULT_DATA_IDENTIFIERS.GENERAL, "ALB WAF Logs");
|
|
71
|
+
}
|
|
72
|
+
validateConfig(config) {
|
|
73
|
+
if (!config.configuration.logGroupName) {
|
|
74
|
+
throw new Error(`Log group name is required for ${config.id}`);
|
|
75
|
+
}
|
|
76
|
+
if (!config.configuration.dataProtection) {
|
|
77
|
+
throw new Error(`Data protection configuration is required for ${config.id}`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.LogDataProtectionPolicyFactory = LogDataProtectionPolicyFactory;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MacieFactory = void 0;
|
|
4
|
+
const resourceFactory_1 = require("./resourceFactory");
|
|
5
|
+
const createAwsMacieAccount_1 = require("./createAwsMacieAccount");
|
|
6
|
+
const createAwsMacieClassificationJob_1 = require("./createAwsMacieClassificationJob");
|
|
7
|
+
const createAwsMacieOrganizationConfiguration_1 = require("./createAwsMacieOrganizationConfiguration");
|
|
8
|
+
const createAwsMacieMember_1 = require("./createAwsMacieMember");
|
|
9
|
+
class MacieFactory extends resourceFactory_1.ResourceFactory {
|
|
10
|
+
async createResource(config) {
|
|
11
|
+
if (config.hooks?.beforeCreateResources)
|
|
12
|
+
await config.hooks.beforeCreateResources(config);
|
|
13
|
+
const resources = {};
|
|
14
|
+
if (config.configuration.account) {
|
|
15
|
+
resources.account = (0, createAwsMacieAccount_1.createAwsMacieAccount)(`${config.id}-account`, config.configuration.account);
|
|
16
|
+
}
|
|
17
|
+
if (config.configuration.organizationConfiguration && resources.account) {
|
|
18
|
+
resources.organizationConfiguration = (0, createAwsMacieOrganizationConfiguration_1.createAwsMacieOrganizationConfiguration)(`${config.id}-org-config`, config.configuration.organizationConfiguration, [resources.account]);
|
|
19
|
+
}
|
|
20
|
+
if (config.configuration.classificationJobs) {
|
|
21
|
+
resources.classificationJobs = config.configuration.classificationJobs.map((jobConfig, index) => {
|
|
22
|
+
const dependencies = resources.account ? [resources.account] : [];
|
|
23
|
+
return (0, createAwsMacieClassificationJob_1.createAwsMacieClassificationJob)({
|
|
24
|
+
...jobConfig,
|
|
25
|
+
name: `${config.id}-${jobConfig.name || `job-${index}`}`,
|
|
26
|
+
}, dependencies);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
if (config.configuration.members) {
|
|
30
|
+
resources.members = config.configuration.members.map((memberConfig, index) => {
|
|
31
|
+
const dependencies = resources.account ? [resources.account] : [];
|
|
32
|
+
return (0, createAwsMacieMember_1.createAwsMacieMember)(`${config.id}-member-${index}`, memberConfig, dependencies);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
if (config.hooks?.afterCreateResources)
|
|
36
|
+
await config.hooks.afterCreateResources(resources, config);
|
|
37
|
+
return resources;
|
|
38
|
+
}
|
|
39
|
+
getOutputs(resources) {
|
|
40
|
+
const outputs = {};
|
|
41
|
+
if (resources.account) {
|
|
42
|
+
outputs.accountId = resources.account.id;
|
|
43
|
+
outputs.accountServiceRole = resources.account.serviceRole;
|
|
44
|
+
outputs.accountStatus = resources.account.status;
|
|
45
|
+
}
|
|
46
|
+
if (resources.organizationConfiguration) {
|
|
47
|
+
outputs.organizationConfigurationId = resources.organizationConfiguration.id;
|
|
48
|
+
}
|
|
49
|
+
if (resources.classificationJobs && resources.classificationJobs.length > 0) {
|
|
50
|
+
outputs.classificationJobIds = resources.classificationJobs.map((job) => job.jobId);
|
|
51
|
+
outputs.classificationJobArns = resources.classificationJobs.map((job) => job.jobArn);
|
|
52
|
+
}
|
|
53
|
+
if (resources.members && resources.members.length > 0) {
|
|
54
|
+
outputs.memberIds = resources.members.map((member) => member.id);
|
|
55
|
+
outputs.memberAccountIds = resources.members.map((member) => member.accountId);
|
|
56
|
+
}
|
|
57
|
+
return outputs;
|
|
58
|
+
}
|
|
59
|
+
validateConfig(config) {
|
|
60
|
+
if (!config.id) {
|
|
61
|
+
throw new Error("Macie factory configuration must include an 'id'");
|
|
62
|
+
}
|
|
63
|
+
if (!config.configuration) {
|
|
64
|
+
throw new Error("Macie factory configuration must include a 'configuration' object");
|
|
65
|
+
}
|
|
66
|
+
if (config.configuration.classificationJobs) {
|
|
67
|
+
config.configuration.classificationJobs.forEach((job, index) => {
|
|
68
|
+
if (!job.jobType) {
|
|
69
|
+
throw new Error(`Classification job at index ${index} must specify jobType`);
|
|
70
|
+
}
|
|
71
|
+
if (!job.s3JobDefinition || !job.s3JobDefinition.bucketDefinitions) {
|
|
72
|
+
throw new Error(`Classification job at index ${index} must include s3JobDefinition with bucketDefinitions`);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
if (config.configuration.members) {
|
|
77
|
+
config.configuration.members.forEach((member, index) => {
|
|
78
|
+
if (!member.accountId || !member.email) {
|
|
79
|
+
throw new Error(`Member at index ${index} must include both accountId and email`);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
exports.MacieFactory = MacieFactory;
|
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.AdvancedNetworkingFactory = exports.NetworkingFactory = void 0;
|
|
37
|
+
const aws = __importStar(require("@pulumi/aws"));
|
|
38
|
+
const pulumi = __importStar(require("@pulumi/pulumi"));
|
|
39
|
+
const resourceFactory_1 = require("./resourceFactory");
|
|
40
|
+
const dataProtectionPolicyBuilder_1 = require("./dataProtectionPolicyBuilder");
|
|
41
|
+
class NetworkingFactory extends resourceFactory_1.ResourceFactory {
|
|
42
|
+
createResource(config, provider) {
|
|
43
|
+
const vpc = new aws.ec2.Vpc(`${config.meta.environment}-${config.id}-vpc`, {
|
|
44
|
+
cidrBlock: config.configuration.vpc.cidrBlock,
|
|
45
|
+
enableDnsSupport: true,
|
|
46
|
+
enableDnsHostnames: true,
|
|
47
|
+
}, provider ? { provider } : undefined);
|
|
48
|
+
const subnets = (config.configuration.subnets || []).map((subnet) => {
|
|
49
|
+
return new aws.ec2.Subnet(`${config.meta.environment}-${subnet.name}`, {
|
|
50
|
+
vpcId: vpc.id,
|
|
51
|
+
cidrBlock: subnet.cidrBlock,
|
|
52
|
+
availabilityZone: subnet.availabilityZone,
|
|
53
|
+
}, provider ? { provider } : undefined);
|
|
54
|
+
});
|
|
55
|
+
const igw = new aws.ec2.InternetGateway(`${config.meta.environment}-${config.id}-igw`, {
|
|
56
|
+
vpcId: vpc.id,
|
|
57
|
+
}, provider ? { provider } : undefined);
|
|
58
|
+
const routeTable = new aws.ec2.RouteTable(`${config.meta.environment}-${config.id}-rt`, {
|
|
59
|
+
vpcId: vpc.id,
|
|
60
|
+
routes: [
|
|
61
|
+
{
|
|
62
|
+
cidrBlock: "0.0.0.0/0",
|
|
63
|
+
gatewayId: igw.id,
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
}, provider ? { provider } : undefined);
|
|
67
|
+
subnets.forEach((subnet, idx) => {
|
|
68
|
+
new aws.ec2.RouteTableAssociation(`${config.meta.environment}-${config.id}-rta-${idx}`, {
|
|
69
|
+
subnetId: subnet.id,
|
|
70
|
+
routeTableId: routeTable.id,
|
|
71
|
+
}, provider ? { provider } : undefined);
|
|
72
|
+
});
|
|
73
|
+
return { vpc, subnets, igw, routeTable };
|
|
74
|
+
}
|
|
75
|
+
getOutputs(resource) {
|
|
76
|
+
console.log("[NetworkingFactory] getOutputs: subnets:", resource.subnets.map(s => s.id));
|
|
77
|
+
console.log("[NetworkingFactory] getOutputs: configSubnets:", resource.config?.configuration?.subnets || []);
|
|
78
|
+
const configSubnets = resource.config?.configuration?.subnets || [];
|
|
79
|
+
const subnets = resource.subnets;
|
|
80
|
+
const publicSubnetIds = subnets
|
|
81
|
+
.filter((_, idx) => configSubnets[idx]?.type === "public")
|
|
82
|
+
.map(s => s.id);
|
|
83
|
+
const privateSubnetIds = subnets
|
|
84
|
+
.filter((_, idx) => configSubnets[idx]?.type === "private")
|
|
85
|
+
.map(s => s.id);
|
|
86
|
+
const isolatedSubnetIds = subnets
|
|
87
|
+
.filter((_, idx) => configSubnets[idx]?.type === "isolated")
|
|
88
|
+
.map(s => s.id);
|
|
89
|
+
const subnetNameMap = {};
|
|
90
|
+
configSubnets.forEach((subnet, idx) => {
|
|
91
|
+
subnetNameMap[subnet.name] = subnets[idx].id;
|
|
92
|
+
});
|
|
93
|
+
console.log("[NetworkingFactory] getOutputs: subnetNameMap:", subnetNameMap);
|
|
94
|
+
return {
|
|
95
|
+
vpcId: resource.vpc.id,
|
|
96
|
+
subnetIds: subnets.map(s => s.id),
|
|
97
|
+
publicSubnetIds,
|
|
98
|
+
privateSubnetIds,
|
|
99
|
+
isolatedSubnetIds,
|
|
100
|
+
subnetNameMap,
|
|
101
|
+
internetGatewayId: resource.igw.id,
|
|
102
|
+
routeTableId: resource.routeTable.id,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
validateConfig(config) {
|
|
106
|
+
if (!config.configuration?.vpc?.cidrBlock) {
|
|
107
|
+
throw new Error("Networking config must include vpc.cidrBlock");
|
|
108
|
+
}
|
|
109
|
+
if (!Array.isArray(config.configuration.subnets) || config.configuration.subnets.length === 0) {
|
|
110
|
+
throw new Error("Networking config must include at least one subnet");
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
exports.NetworkingFactory = NetworkingFactory;
|
|
115
|
+
class AdvancedNetworkingFactory extends resourceFactory_1.ResourceFactory {
|
|
116
|
+
async createResource(config, provider) {
|
|
117
|
+
const { configuration } = config;
|
|
118
|
+
const environment = config.meta?.environment || 'dev';
|
|
119
|
+
const region = config.meta?.region || 'us-east-1';
|
|
120
|
+
const resourceId = config.id || 'networking';
|
|
121
|
+
if (config.hooks?.beforeCreateVpc)
|
|
122
|
+
await config.hooks.beforeCreateVpc(config);
|
|
123
|
+
const vpc = new aws.ec2.Vpc(`${environment}-${resourceId}-vpc`, {
|
|
124
|
+
cidrBlock: configuration.vpc.cidrBlock,
|
|
125
|
+
enableDnsSupport: configuration.vpc.enableDnsSupport ?? true,
|
|
126
|
+
enableDnsHostnames: configuration.vpc.enableDnsHostnames ?? true,
|
|
127
|
+
instanceTenancy: configuration.vpc.instanceTenancy ?? "default",
|
|
128
|
+
tags: configuration.vpc.tags,
|
|
129
|
+
}, provider ? { provider } : undefined);
|
|
130
|
+
const subnets = (configuration.subnets || []).map((subnet) => new aws.ec2.Subnet(`${environment}-${subnet.name}`, {
|
|
131
|
+
vpcId: vpc.id,
|
|
132
|
+
cidrBlock: subnet.cidrBlock,
|
|
133
|
+
availabilityZone: subnet.availabilityZone,
|
|
134
|
+
mapPublicIpOnLaunch: subnet.type === "public" ? true : subnet.mapPublicIpOnLaunch,
|
|
135
|
+
tags: subnet.tags,
|
|
136
|
+
}, provider ? { provider } : undefined));
|
|
137
|
+
if (config.hooks?.afterCreateSubnets)
|
|
138
|
+
await config.hooks.afterCreateSubnets(subnets, config);
|
|
139
|
+
let igw = undefined;
|
|
140
|
+
if (configuration.internetGateway?.enabled !== false) {
|
|
141
|
+
igw = new aws.ec2.InternetGateway(`${environment}-${resourceId}-igw`, { vpcId: vpc.id }, provider ? { provider } : undefined);
|
|
142
|
+
}
|
|
143
|
+
let natGateways = [];
|
|
144
|
+
let eips = [];
|
|
145
|
+
if (configuration.natGateways?.enabled) {
|
|
146
|
+
const azs = Array.from(new Set(configuration.subnets.filter(s => s.type === "public").map(s => s.availabilityZone)));
|
|
147
|
+
azs.forEach((az, idx) => {
|
|
148
|
+
const eip = new aws.ec2.Eip(`${config.meta.environment}-${config.id}-eip-${az}`, {}, provider ? { provider } : undefined);
|
|
149
|
+
eips.push(eip);
|
|
150
|
+
const publicSubnet = subnets.find(s => configuration.subnets[subnets.indexOf(s)].availabilityZone === az && configuration.subnets[subnets.indexOf(s)].type === "public");
|
|
151
|
+
if (publicSubnet) {
|
|
152
|
+
natGateways.push(new aws.ec2.NatGateway(`${config.meta.environment}-${config.id}-natgw-${az}`, {
|
|
153
|
+
subnetId: publicSubnet.id,
|
|
154
|
+
allocationId: eip.id,
|
|
155
|
+
}, provider ? { provider } : undefined));
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
const routeTables = (configuration.routeTables || []).map(rt => {
|
|
160
|
+
const routes = (rt.routes || []).map(route => {
|
|
161
|
+
let gatewayId = undefined;
|
|
162
|
+
if (route.gatewayType === "igw" && igw)
|
|
163
|
+
gatewayId = igw.id;
|
|
164
|
+
if (route.gatewayType === "nat" && natGateways.length > 0) {
|
|
165
|
+
const nat = route.natGatewayAz ? natGateways.find((ng, idx) => configuration.subnets[subnets.indexOf(subnets[idx])].availabilityZone === route.natGatewayAz) : natGateways[0];
|
|
166
|
+
if (nat)
|
|
167
|
+
gatewayId = nat.id;
|
|
168
|
+
}
|
|
169
|
+
return { cidrBlock: route.cidrBlock, gatewayId };
|
|
170
|
+
});
|
|
171
|
+
const rtRes = new aws.ec2.RouteTable(`${config.meta.environment}-${config.id}-rt-${rt.name}`, { vpcId: vpc.id, routes, tags: rt.tags }, provider ? { provider } : undefined);
|
|
172
|
+
rt.subnetNames.forEach(subnetName => {
|
|
173
|
+
const subnet = subnets.find((s, idx) => configuration.subnets[idx].name === subnetName);
|
|
174
|
+
if (subnet) {
|
|
175
|
+
new aws.ec2.RouteTableAssociation(`${config.meta.environment}-${config.id}-rta-${rt.name}-${subnetName}`, { subnetId: subnet.id, routeTableId: rtRes.id }, provider ? { provider } : undefined);
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
return rtRes;
|
|
179
|
+
});
|
|
180
|
+
let securityGroups = [];
|
|
181
|
+
if (configuration.securityGroups) {
|
|
182
|
+
securityGroups = configuration.securityGroups.map(sg => new aws.ec2.SecurityGroup(`${config.meta.environment}-${config.id}-sg-${sg.name}`, {
|
|
183
|
+
vpcId: vpc.id,
|
|
184
|
+
description: sg.description,
|
|
185
|
+
ingress: sg.ingress,
|
|
186
|
+
egress: sg.egress,
|
|
187
|
+
tags: sg.tags,
|
|
188
|
+
}, provider ? { provider } : undefined));
|
|
189
|
+
}
|
|
190
|
+
let vpcEndpoints = [];
|
|
191
|
+
if (configuration.vpcEndpoints) {
|
|
192
|
+
vpcEndpoints = configuration.vpcEndpoints.map(ep => {
|
|
193
|
+
const subnetIds = ep.subnets
|
|
194
|
+
? ep.subnets
|
|
195
|
+
.map(name => {
|
|
196
|
+
const subnet = subnets.find((s, idx) => configuration.subnets[idx].name === name);
|
|
197
|
+
return subnet ? subnet.id : undefined;
|
|
198
|
+
})
|
|
199
|
+
.filter((id) => !!id)
|
|
200
|
+
: undefined;
|
|
201
|
+
let securityGroupIds = ep.securityGroupNames && securityGroups
|
|
202
|
+
? ep.securityGroupNames
|
|
203
|
+
.map(name => {
|
|
204
|
+
const sg = securityGroups.find((s, idx) => configuration.securityGroups && configuration.securityGroups[idx].name === name);
|
|
205
|
+
return sg ? sg.id : undefined;
|
|
206
|
+
})
|
|
207
|
+
.filter((id) => !!id)
|
|
208
|
+
: undefined;
|
|
209
|
+
if (ep.allowFromVpcCidr) {
|
|
210
|
+
const vpcEndpointSg = new aws.ec2.SecurityGroup(`${environment}-${resourceId}-ep-${ep.service}-vpc-access-sg`, {
|
|
211
|
+
vpcId: vpc.id,
|
|
212
|
+
description: `VPC Endpoint security group for ${ep.service} with VPC-wide access`,
|
|
213
|
+
ingress: [
|
|
214
|
+
{
|
|
215
|
+
protocol: "tcp",
|
|
216
|
+
fromPort: 443,
|
|
217
|
+
toPort: 443,
|
|
218
|
+
cidrBlocks: [configuration.vpc.cidrBlock],
|
|
219
|
+
description: `HTTPS access from VPC CIDR for ${ep.service}`,
|
|
220
|
+
}
|
|
221
|
+
],
|
|
222
|
+
egress: [
|
|
223
|
+
{
|
|
224
|
+
protocol: "-1",
|
|
225
|
+
fromPort: 0,
|
|
226
|
+
toPort: 0,
|
|
227
|
+
cidrBlocks: ["0.0.0.0/0"],
|
|
228
|
+
description: "All outbound traffic",
|
|
229
|
+
}
|
|
230
|
+
],
|
|
231
|
+
tags: {
|
|
232
|
+
Name: `${ep.service}-vpc-endpoint-sg`,
|
|
233
|
+
Purpose: "VPC Endpoint Access",
|
|
234
|
+
Service: ep.service,
|
|
235
|
+
},
|
|
236
|
+
}, provider ? { provider } : undefined);
|
|
237
|
+
if (securityGroupIds) {
|
|
238
|
+
securityGroupIds = [...securityGroupIds, vpcEndpointSg.id];
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
securityGroupIds = [vpcEndpointSg.id];
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
return new aws.ec2.VpcEndpoint(`${environment}-${resourceId}-ep-${ep.service}`, {
|
|
245
|
+
vpcId: vpc.id,
|
|
246
|
+
serviceName: pulumi.interpolate `com.amazonaws.${region}.${ep.service}`,
|
|
247
|
+
vpcEndpointType: ep.type,
|
|
248
|
+
subnetIds,
|
|
249
|
+
securityGroupIds,
|
|
250
|
+
}, provider ? { provider } : undefined);
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
let flowLog = undefined;
|
|
254
|
+
let flowLogGroup = undefined;
|
|
255
|
+
let flowLogRole = undefined;
|
|
256
|
+
if (configuration.vpcFlowLogs?.enabled) {
|
|
257
|
+
const logGroupName = configuration.vpcFlowLogs.logGroupName || `${config.meta.environment}-${config.id}-vpc-flow-logs`;
|
|
258
|
+
flowLogGroup = new aws.cloudwatch.LogGroup(logGroupName, {
|
|
259
|
+
name: logGroupName,
|
|
260
|
+
retentionInDays: configuration.vpcFlowLogs.retentionInDays || 365,
|
|
261
|
+
}, provider ? { provider } : undefined);
|
|
262
|
+
if (configuration.vpcFlowLogs.dataProtection?.enabled) {
|
|
263
|
+
const dataProtectionPolicy = this.buildDataProtectionPolicy(configuration.vpcFlowLogs.dataProtection, logGroupName);
|
|
264
|
+
new aws.cloudwatch.LogDataProtectionPolicy(`${config.meta.environment}-${config.id}-vpc-flowlog-data-protection`, {
|
|
265
|
+
logGroupName: flowLogGroup.name,
|
|
266
|
+
policyDocument: JSON.stringify(dataProtectionPolicy),
|
|
267
|
+
}, {
|
|
268
|
+
provider: provider,
|
|
269
|
+
dependsOn: [flowLogGroup]
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
const assumeRole = aws.iam.getPolicyDocument({
|
|
273
|
+
statements: [{
|
|
274
|
+
effect: "Allow",
|
|
275
|
+
principals: [{ type: "Service", identifiers: ["vpc-flow-logs.amazonaws.com"] }],
|
|
276
|
+
actions: ["sts:AssumeRole"],
|
|
277
|
+
}],
|
|
278
|
+
});
|
|
279
|
+
flowLogRole = new aws.iam.Role(`${config.meta.environment}-${config.id}-vpc-flowlog-role`, {
|
|
280
|
+
name: configuration.vpcFlowLogs.iamRoleName || `${config.meta.environment}-${config.id}-vpc-flowlog-role`,
|
|
281
|
+
assumeRolePolicy: assumeRole.then(doc => doc.json),
|
|
282
|
+
}, provider ? { provider } : undefined);
|
|
283
|
+
const logPolicyDoc = aws.iam.getPolicyDocument({
|
|
284
|
+
statements: [{
|
|
285
|
+
effect: "Allow",
|
|
286
|
+
actions: [
|
|
287
|
+
"logs:CreateLogGroup",
|
|
288
|
+
"logs:CreateLogStream",
|
|
289
|
+
"logs:PutLogEvents",
|
|
290
|
+
"logs:DescribeLogGroups",
|
|
291
|
+
"logs:DescribeLogStreams"
|
|
292
|
+
],
|
|
293
|
+
resources: ["*"],
|
|
294
|
+
}],
|
|
295
|
+
});
|
|
296
|
+
new aws.iam.RolePolicy(`${config.meta.environment}-${config.id}-vpc-flowlog-role-policy`, {
|
|
297
|
+
name: `${config.meta.environment}-${config.id}-vpc-flowlog-role-policy`,
|
|
298
|
+
role: flowLogRole.id,
|
|
299
|
+
policy: logPolicyDoc.then(doc => doc.json),
|
|
300
|
+
}, provider ? { provider } : undefined);
|
|
301
|
+
flowLog = new aws.ec2.FlowLog(`${config.meta.environment}-${config.id}-vpc-flowlog`, {
|
|
302
|
+
iamRoleArn: flowLogRole.arn,
|
|
303
|
+
logDestination: flowLogGroup.arn,
|
|
304
|
+
trafficType: configuration.vpcFlowLogs.trafficType || "ALL",
|
|
305
|
+
vpcId: vpc.id,
|
|
306
|
+
}, provider ? { provider } : undefined);
|
|
307
|
+
}
|
|
308
|
+
let networkAcls = [];
|
|
309
|
+
if (configuration.networkAcls && configuration.networkAcls.length > 0) {
|
|
310
|
+
networkAcls = configuration.networkAcls.map(naclConfig => {
|
|
311
|
+
const nacl = new aws.ec2.NetworkAcl(`${config.meta.environment}-${config.id}-nacl-${naclConfig.name}`, {
|
|
312
|
+
vpcId: vpc.id,
|
|
313
|
+
tags: { Name: naclConfig.name, ...naclConfig.tags },
|
|
314
|
+
}, provider ? { provider } : undefined);
|
|
315
|
+
naclConfig.ingress.forEach(rule => {
|
|
316
|
+
new aws.ec2.NetworkAclRule(`${config.meta.environment}-${config.id}-nacl-${naclConfig.name}-ingress-${rule.ruleNumber}`, {
|
|
317
|
+
networkAclId: nacl.id,
|
|
318
|
+
ruleNumber: rule.ruleNumber,
|
|
319
|
+
protocol: rule.protocol,
|
|
320
|
+
ruleAction: rule.action,
|
|
321
|
+
cidrBlock: rule.cidrBlock,
|
|
322
|
+
fromPort: rule.fromPort,
|
|
323
|
+
toPort: rule.toPort,
|
|
324
|
+
icmpType: rule.icmpType,
|
|
325
|
+
icmpCode: rule.icmpCode,
|
|
326
|
+
}, provider ? { provider } : undefined);
|
|
327
|
+
});
|
|
328
|
+
naclConfig.egress.forEach(rule => {
|
|
329
|
+
new aws.ec2.NetworkAclRule(`${config.meta.environment}-${config.id}-nacl-${naclConfig.name}-egress-${rule.ruleNumber}`, {
|
|
330
|
+
networkAclId: nacl.id,
|
|
331
|
+
ruleNumber: rule.ruleNumber,
|
|
332
|
+
protocol: rule.protocol,
|
|
333
|
+
ruleAction: rule.action,
|
|
334
|
+
cidrBlock: rule.cidrBlock,
|
|
335
|
+
fromPort: rule.fromPort,
|
|
336
|
+
toPort: rule.toPort,
|
|
337
|
+
icmpType: rule.icmpType,
|
|
338
|
+
icmpCode: rule.icmpCode,
|
|
339
|
+
egress: true,
|
|
340
|
+
}, provider ? { provider } : undefined);
|
|
341
|
+
});
|
|
342
|
+
naclConfig.subnetNames.forEach(subnetName => {
|
|
343
|
+
const subnet = subnets.find((s, idx) => configuration.subnets[idx].name === subnetName);
|
|
344
|
+
if (subnet) {
|
|
345
|
+
new aws.ec2.NetworkAclAssociation(`${config.meta.environment}-${config.id}-nacl-assoc-${naclConfig.name}-${subnetName}`, {
|
|
346
|
+
networkAclId: nacl.id,
|
|
347
|
+
subnetId: subnet.id,
|
|
348
|
+
}, provider ? { provider } : undefined);
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
return nacl;
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
let defaultSg = undefined;
|
|
355
|
+
if (configuration.securityEnhancements?.defaultSecurityGroupRestrictions) {
|
|
356
|
+
defaultSg = new aws.ec2.DefaultSecurityGroup(`${config.meta.environment}-${config.id}-default-sg`, {
|
|
357
|
+
vpcId: vpc.id,
|
|
358
|
+
ingress: [],
|
|
359
|
+
egress: [],
|
|
360
|
+
tags: { Name: "Default-Restricted" },
|
|
361
|
+
}, provider ? { provider } : undefined);
|
|
362
|
+
}
|
|
363
|
+
return {
|
|
364
|
+
vpc,
|
|
365
|
+
subnets,
|
|
366
|
+
natGateways,
|
|
367
|
+
eips,
|
|
368
|
+
igw,
|
|
369
|
+
routeTables,
|
|
370
|
+
securityGroups,
|
|
371
|
+
vpcEndpoints,
|
|
372
|
+
flowLog,
|
|
373
|
+
flowLogGroup,
|
|
374
|
+
flowLogRole,
|
|
375
|
+
networkAcls,
|
|
376
|
+
defaultSg,
|
|
377
|
+
config
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
getOutputs(resource) {
|
|
381
|
+
const configSubnets = resource.config?.configuration?.subnets || [];
|
|
382
|
+
const publicSubnetIds = resource.subnets
|
|
383
|
+
.filter((_, idx) => configSubnets[idx]?.type === "public")
|
|
384
|
+
.map(s => s.id);
|
|
385
|
+
const privateSubnetIds = resource.subnets
|
|
386
|
+
.filter((_, idx) => configSubnets[idx]?.type === "private")
|
|
387
|
+
.map(s => s.id);
|
|
388
|
+
const isolatedSubnetIds = resource.subnets
|
|
389
|
+
.filter((_, idx) => configSubnets[idx]?.type === "isolated")
|
|
390
|
+
.map(s => s.id);
|
|
391
|
+
const subnetNameMap = {};
|
|
392
|
+
configSubnets.forEach((subnet, idx) => {
|
|
393
|
+
if (resource.subnets[idx]) {
|
|
394
|
+
subnetNameMap[subnet.name] = resource.subnets[idx].id;
|
|
395
|
+
}
|
|
396
|
+
});
|
|
397
|
+
return {
|
|
398
|
+
vpcId: resource.vpc.id,
|
|
399
|
+
subnetIds: resource.subnets.map(s => s.id),
|
|
400
|
+
publicSubnetIds,
|
|
401
|
+
privateSubnetIds,
|
|
402
|
+
isolatedSubnetIds,
|
|
403
|
+
subnetNameMap,
|
|
404
|
+
natGatewayIds: resource.natGateways ? resource.natGateways.map(n => n.id) : undefined,
|
|
405
|
+
eipAllocationIds: resource.eips ? resource.eips.map(e => e.id) : undefined,
|
|
406
|
+
internetGatewayId: resource.igw ? resource.igw.id : undefined,
|
|
407
|
+
routeTableIds: resource.routeTables.map(rt => rt.id),
|
|
408
|
+
securityGroupIds: resource.securityGroups ? resource.securityGroups.map(sg => sg.id) : undefined,
|
|
409
|
+
vpcEndpointIds: resource.vpcEndpoints ? resource.vpcEndpoints.map(ep => ep.id) : undefined,
|
|
410
|
+
flowLogId: resource.flowLog ? resource.flowLog.id : undefined,
|
|
411
|
+
flowLogGroupName: resource.flowLogGroup ? resource.flowLogGroup.name : undefined,
|
|
412
|
+
flowLogRoleArn: resource.flowLogRole ? resource.flowLogRole.arn : undefined,
|
|
413
|
+
networkAclIds: resource.networkAcls ? resource.networkAcls.map(nacl => nacl.id) : undefined,
|
|
414
|
+
defaultSecurityGroupId: resource.defaultSg ? resource.defaultSg.id : undefined,
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
buildDataProtectionPolicy(dataProtectionConfig, logGroupName) {
|
|
418
|
+
return (0, dataProtectionPolicyBuilder_1.buildDataProtectionPolicy)(dataProtectionConfig, logGroupName, dataProtectionPolicyBuilder_1.DEFAULT_DATA_IDENTIFIERS.VPC_FLOW_LOGS, "VPC Flow Logs");
|
|
419
|
+
}
|
|
420
|
+
validateConfig(config) {
|
|
421
|
+
if (!config.configuration?.vpc?.cidrBlock)
|
|
422
|
+
throw new Error("Networking config must include vpc.cidrBlock");
|
|
423
|
+
if (!Array.isArray(config.configuration.subnets) || config.configuration.subnets.length === 0)
|
|
424
|
+
throw new Error("Networking config must include at least one subnet");
|
|
425
|
+
if (!Array.isArray(config.configuration.routeTables) || config.configuration.routeTables.length === 0)
|
|
426
|
+
throw new Error("Networking config must include at least one routeTable");
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
exports.AdvancedNetworkingFactory = AdvancedNetworkingFactory;
|