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,331 @@
|
|
|
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.AlbFactory = void 0;
|
|
37
|
+
const aws = __importStar(require("@pulumi/aws"));
|
|
38
|
+
const pulumi = __importStar(require("@pulumi/pulumi"));
|
|
39
|
+
const resourceFactory_1 = require("./resourceFactory");
|
|
40
|
+
const buildAlbCloudWatchAlarmsHelper_1 = require("./buildAlbCloudWatchAlarmsHelper");
|
|
41
|
+
const buildAlbCloudWatchDashboardHelper_1 = require("./buildAlbCloudWatchDashboardHelper");
|
|
42
|
+
const buildAlbResourceHelper_1 = require("./buildAlbResourceHelper");
|
|
43
|
+
const buildAlbListenersHelper_1 = require("./buildAlbListenersHelper");
|
|
44
|
+
const buildAlbTargetGroupsHelper_1 = require("./buildAlbTargetGroupsHelper");
|
|
45
|
+
const buildAlbListenerRulesHelper_1 = require("./buildAlbListenerRulesHelper");
|
|
46
|
+
const buildAlbWafAssociationHelper_1 = require("./buildAlbWafAssociationHelper");
|
|
47
|
+
const buildAlbRoute53RecordHelper_1 = require("./buildAlbRoute53RecordHelper");
|
|
48
|
+
const wafFactory_1 = require("./wafFactory");
|
|
49
|
+
class AlbFactory extends resourceFactory_1.ResourceFactory {
|
|
50
|
+
static supportsProviderRegistry = true;
|
|
51
|
+
async createResource(config, provider, providerRegistry = {}) {
|
|
52
|
+
const { vpcId, subnetIds, sgId, route53Provider } = config.inputs;
|
|
53
|
+
const getRoute53Provider = () => {
|
|
54
|
+
let selectedProvider;
|
|
55
|
+
if (!route53Provider)
|
|
56
|
+
selectedProvider = provider;
|
|
57
|
+
else if (typeof route53Provider === "object" && route53Provider !== null)
|
|
58
|
+
selectedProvider = route53Provider;
|
|
59
|
+
else if (typeof route53Provider === "string" && providerRegistry && providerRegistry[route53Provider])
|
|
60
|
+
selectedProvider = providerRegistry[route53Provider];
|
|
61
|
+
else {
|
|
62
|
+
throw new Error(`route53Provider='${route53Provider}' is not found in providerRegistry. Available keys: ${Object.keys(providerRegistry).join(", ")}. Must be an aws.Provider object or a valid provider name string for cross-account Route53 access.`);
|
|
63
|
+
}
|
|
64
|
+
return selectedProvider;
|
|
65
|
+
};
|
|
66
|
+
const { certificateArn, domain, hostedZoneId, monitoring, accessLogs, waf, targetGroups, listenerRules, securityEnhancements, tags, deletionProtection, crossZone, dualstack, enableCertProvisioning } = config.configuration || {};
|
|
67
|
+
if (!sgId) {
|
|
68
|
+
throw new Error("ALB requires sgId (security group id) to be provided in inputs");
|
|
69
|
+
}
|
|
70
|
+
const alb = (0, buildAlbResourceHelper_1.buildAlbResourceHelper)({
|
|
71
|
+
name: `${config.meta.environment}-${config.id}`,
|
|
72
|
+
vpcId,
|
|
73
|
+
subnetIds,
|
|
74
|
+
sgId,
|
|
75
|
+
accessLogs,
|
|
76
|
+
deletionProtection,
|
|
77
|
+
crossZone,
|
|
78
|
+
dualstack,
|
|
79
|
+
tags,
|
|
80
|
+
provider
|
|
81
|
+
});
|
|
82
|
+
let wafAssoc;
|
|
83
|
+
let effectiveWafArn = waf?.wafArn;
|
|
84
|
+
if (waf && waf.enabled && (!effectiveWafArn || waf.wafConfig?.enabled)) {
|
|
85
|
+
const wafName = `${config.meta.environment}-${config.id}-alb-waf`;
|
|
86
|
+
let wafConfig;
|
|
87
|
+
if (waf.wafConfig?.customConfig) {
|
|
88
|
+
wafConfig = {
|
|
89
|
+
name: wafName,
|
|
90
|
+
scope: "REGIONAL",
|
|
91
|
+
defaultAction: "allow",
|
|
92
|
+
...waf.wafConfig.customConfig,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
else if (waf.wafConfig?.useSecureDefaults !== false) {
|
|
96
|
+
wafConfig = wafFactory_1.WafFactory.createSecureWafConfig(wafName, "REGIONAL");
|
|
97
|
+
if (waf.wafConfig?.rateLimiting) {
|
|
98
|
+
wafConfig.rateLimiting = waf.wafConfig.rateLimiting;
|
|
99
|
+
}
|
|
100
|
+
if (waf.wafConfig?.ipRestrictions) {
|
|
101
|
+
wafConfig.ipRestrictions = waf.wafConfig.ipRestrictions;
|
|
102
|
+
}
|
|
103
|
+
if (waf.wafConfig?.geoRestrictions) {
|
|
104
|
+
wafConfig.geoRestrictions = waf.wafConfig.geoRestrictions;
|
|
105
|
+
}
|
|
106
|
+
if (waf.wafConfig?.managedRuleGroups) {
|
|
107
|
+
const managedRules = waf.wafConfig.managedRuleGroups;
|
|
108
|
+
wafConfig.managedRuleGroups = [];
|
|
109
|
+
if (managedRules.enableCommonRules !== false) {
|
|
110
|
+
wafConfig.managedRuleGroups.push({
|
|
111
|
+
name: "AWSManagedRulesCommonRuleSet",
|
|
112
|
+
vendorName: "AWS",
|
|
113
|
+
priority: 10,
|
|
114
|
+
overrideAction: "count",
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
if (managedRules.enableKnownBadInputs !== false) {
|
|
118
|
+
wafConfig.managedRuleGroups.push({
|
|
119
|
+
name: "AWSManagedRulesKnownBadInputsRuleSet",
|
|
120
|
+
vendorName: "AWS",
|
|
121
|
+
priority: 20,
|
|
122
|
+
overrideAction: "count",
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
if (managedRules.enableSQLInjection !== false) {
|
|
126
|
+
wafConfig.managedRuleGroups.push({
|
|
127
|
+
name: "AWSManagedRulesSQLiRuleSet",
|
|
128
|
+
vendorName: "AWS",
|
|
129
|
+
priority: 30,
|
|
130
|
+
overrideAction: "count",
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
if (managedRules.enableLinuxRules !== false) {
|
|
134
|
+
wafConfig.managedRuleGroups.push({
|
|
135
|
+
name: "AWSManagedRulesLinuxRuleSet",
|
|
136
|
+
vendorName: "AWS",
|
|
137
|
+
priority: 40,
|
|
138
|
+
overrideAction: "count",
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
if (managedRules.enableIpReputation !== false) {
|
|
142
|
+
wafConfig.managedRuleGroups.push({
|
|
143
|
+
name: "AWSManagedRulesAmazonIpReputationList",
|
|
144
|
+
vendorName: "AWS",
|
|
145
|
+
priority: 50,
|
|
146
|
+
overrideAction: "count",
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
if (managedRules.enableAnonymousIp !== false) {
|
|
150
|
+
wafConfig.managedRuleGroups.push({
|
|
151
|
+
name: "AWSManagedRulesAnonymousIpList",
|
|
152
|
+
vendorName: "AWS",
|
|
153
|
+
priority: 60,
|
|
154
|
+
overrideAction: "count",
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
if (waf.wafConfig?.customRules?.length) {
|
|
159
|
+
wafConfig.customRegexRules = waf.wafConfig.customRules.map(rule => ({
|
|
160
|
+
name: rule.name,
|
|
161
|
+
priority: rule.priority,
|
|
162
|
+
regex: rule.regex || "/.*",
|
|
163
|
+
action: rule.action,
|
|
164
|
+
fieldToMatch: { type: "uri" },
|
|
165
|
+
}));
|
|
166
|
+
}
|
|
167
|
+
if (waf.wafConfig?.logging) {
|
|
168
|
+
wafConfig.logging = waf.wafConfig.logging;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
wafConfig = {
|
|
173
|
+
name: wafName,
|
|
174
|
+
scope: "REGIONAL",
|
|
175
|
+
description: `WAF for ALB ${config.meta.environment}-${config.id}`,
|
|
176
|
+
defaultAction: "allow",
|
|
177
|
+
rateLimiting: {
|
|
178
|
+
enabled: true,
|
|
179
|
+
limit: 2000,
|
|
180
|
+
action: "block",
|
|
181
|
+
},
|
|
182
|
+
visibilityConfig: {
|
|
183
|
+
cloudwatchMetricsEnabled: true,
|
|
184
|
+
sampledRequestsEnabled: true,
|
|
185
|
+
},
|
|
186
|
+
tags: tags,
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
const createdWaf = wafFactory_1.WafFactory.createWaf(wafConfig, provider);
|
|
190
|
+
effectiveWafArn = createdWaf.arn;
|
|
191
|
+
}
|
|
192
|
+
if (waf && waf.enabled && effectiveWafArn) {
|
|
193
|
+
wafAssoc = (0, buildAlbWafAssociationHelper_1.buildAlbWafAssociationHelper)(`${config.meta.environment}-${config.id}`, alb.arn, effectiveWafArn, provider);
|
|
194
|
+
}
|
|
195
|
+
let effectiveCertificateArn = certificateArn;
|
|
196
|
+
let acmCert, acmValidationRecord, certValidation;
|
|
197
|
+
if ((!certificateArn || certificateArn === "") && enableCertProvisioning && domain && hostedZoneId) {
|
|
198
|
+
const acmProvider = provider;
|
|
199
|
+
acmCert = new aws.acm.Certificate(`${config.meta.environment}-${config.id}-cert`, {
|
|
200
|
+
domainName: domain,
|
|
201
|
+
validationMethod: "DNS",
|
|
202
|
+
tags,
|
|
203
|
+
}, { provider: acmProvider });
|
|
204
|
+
acmValidationRecord = pulumi.all([acmCert.domainValidationOptions]).apply(([options]) => {
|
|
205
|
+
if (!options || options.length === 0)
|
|
206
|
+
return undefined;
|
|
207
|
+
const opt = options[0];
|
|
208
|
+
return new aws.route53.Record(`${config.meta.environment}-${config.id}-acm-validation`, {
|
|
209
|
+
name: opt.resourceRecordName,
|
|
210
|
+
zoneId: hostedZoneId,
|
|
211
|
+
type: opt.resourceRecordType,
|
|
212
|
+
records: [opt.resourceRecordValue],
|
|
213
|
+
ttl: 300,
|
|
214
|
+
}, { provider: getRoute53Provider() });
|
|
215
|
+
});
|
|
216
|
+
certValidation = pulumi.all([acmCert.arn, acmCert.domainValidationOptions]).apply(([arn, options]) => {
|
|
217
|
+
const fqdns = options && options.length > 0 ? [options[0].resourceRecordName] : [];
|
|
218
|
+
return new aws.acm.CertificateValidation(`${config.meta.environment}-${config.id}-cert-validation`, {
|
|
219
|
+
certificateArn: arn,
|
|
220
|
+
validationRecordFqdns: fqdns,
|
|
221
|
+
}, { provider: acmProvider });
|
|
222
|
+
});
|
|
223
|
+
effectiveCertificateArn = certValidation.apply(v => v.certificateArn);
|
|
224
|
+
}
|
|
225
|
+
if (!effectiveCertificateArn) {
|
|
226
|
+
throw new Error("certificateArn is required for HTTPS listener and downstream rules");
|
|
227
|
+
}
|
|
228
|
+
const { httpsListener, httpListener: albListener } = (0, buildAlbListenersHelper_1.buildAlbListenersHelper)({
|
|
229
|
+
name: `${config.meta.environment}-${config.id}`,
|
|
230
|
+
albArn: alb.arn,
|
|
231
|
+
certificateArn: effectiveCertificateArn,
|
|
232
|
+
tlsPolicy: securityEnhancements?.tlsPolicy,
|
|
233
|
+
provider
|
|
234
|
+
});
|
|
235
|
+
let createdTargetGroups = [];
|
|
236
|
+
if (targetGroups && targetGroups.length > 0) {
|
|
237
|
+
createdTargetGroups = (0, buildAlbTargetGroupsHelper_1.buildAlbTargetGroupsHelper)({
|
|
238
|
+
name: `${config.meta.environment}-${config.id}`,
|
|
239
|
+
vpcId,
|
|
240
|
+
targetGroups,
|
|
241
|
+
provider
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
let createdListenerRules = [];
|
|
245
|
+
if (listenerRules && listenerRules.length > 0) {
|
|
246
|
+
createdListenerRules = (0, buildAlbListenerRulesHelper_1.buildAlbListenerRulesHelper)({
|
|
247
|
+
name: `${config.meta.environment}-${config.id}`,
|
|
248
|
+
listenerArn: httpsListener.arn,
|
|
249
|
+
rules: listenerRules,
|
|
250
|
+
provider
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
let monitoringResources;
|
|
254
|
+
let dashboardResource;
|
|
255
|
+
if (monitoring?.enabled) {
|
|
256
|
+
monitoringResources = (0, buildAlbCloudWatchAlarmsHelper_1.buildAlbCloudWatchAlarmsHelper)(`${config.meta.environment}-${config.id}`, {
|
|
257
|
+
albArn: alb.arn,
|
|
258
|
+
alarmActions: monitoring.alarms?.map(a => a.alarmActionArn),
|
|
259
|
+
okActions: monitoring.alarms?.map(a => a.okActionArn),
|
|
260
|
+
tags,
|
|
261
|
+
});
|
|
262
|
+
if (monitoring.dashboard) {
|
|
263
|
+
dashboardResource = (0, buildAlbCloudWatchDashboardHelper_1.buildAlbCloudWatchDashboardHelper)(`${config.meta.environment}-${config.id}`, {
|
|
264
|
+
albArn: alb.arn,
|
|
265
|
+
albDnsName: alb.dnsName,
|
|
266
|
+
tags,
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
let record;
|
|
271
|
+
if (domain && hostedZoneId) {
|
|
272
|
+
record = (0, buildAlbRoute53RecordHelper_1.buildAlbRoute53RecordHelper)(`${config.meta.environment}-${config.id}`, domain, hostedZoneId, alb.dnsName, alb.zoneId, getRoute53Provider());
|
|
273
|
+
}
|
|
274
|
+
return { alb, albListener, httpsListener, createdTargetGroups, createdListenerRules, wafAssoc, monitoringResources, dashboardResource };
|
|
275
|
+
}
|
|
276
|
+
getOutputs(resource) {
|
|
277
|
+
return {
|
|
278
|
+
arn: resource.alb.arn,
|
|
279
|
+
name: resource.alb.name,
|
|
280
|
+
dnsName: resource.alb.dnsName,
|
|
281
|
+
sgId: resource.alb.securityGroups[0],
|
|
282
|
+
listenerArn: resource.httpsListener ? resource.httpsListener.arn : resource.albListener.arn,
|
|
283
|
+
httpsListenerArn: resource.httpsListener?.arn || pulumi.output(""),
|
|
284
|
+
targetGroupArn: resource.createdTargetGroups?.[0]?.arn || pulumi.output(undefined),
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
validateConfig(config) {
|
|
288
|
+
if (!config.id) {
|
|
289
|
+
throw new Error("ALB config must include id");
|
|
290
|
+
}
|
|
291
|
+
if (!config.inputs?.vpcId) {
|
|
292
|
+
throw new Error("ALB config must include vpcId in inputs");
|
|
293
|
+
}
|
|
294
|
+
if (!config.inputs?.subnetIds || config.inputs.subnetIds.length < 2) {
|
|
295
|
+
throw new Error("ALB config must include at least two subnetIds in inputs");
|
|
296
|
+
}
|
|
297
|
+
if (!config.inputs?.sgId) {
|
|
298
|
+
throw new Error("ALB config must include sgId in inputs");
|
|
299
|
+
}
|
|
300
|
+
const certArn = config.configuration?.certificateArn;
|
|
301
|
+
const enableCertProvisioning = config.configuration?.enableCertProvisioning;
|
|
302
|
+
const domain = config.configuration?.domain;
|
|
303
|
+
const hostedZoneId = config.configuration?.hostedZoneId;
|
|
304
|
+
if (!certArn && !(enableCertProvisioning && domain && hostedZoneId)) {
|
|
305
|
+
throw new Error("certificateArn is required for HTTPS listener unless ACM automation is enabled and domain/hostedZoneId are set");
|
|
306
|
+
}
|
|
307
|
+
if (config.configuration?.accessLogs?.enabled && !config.configuration.accessLogs.bucketArn) {
|
|
308
|
+
throw new Error("accessLogs.enabled=true requires bucketArn");
|
|
309
|
+
}
|
|
310
|
+
if (config.configuration?.waf?.enabled) {
|
|
311
|
+
if (!config.configuration.waf.wafArn && !config.configuration.waf.wafConfig) {
|
|
312
|
+
throw new Error("waf.enabled=true requires either wafArn or wafConfig");
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
if (config.configuration?.targetGroups) {
|
|
316
|
+
for (const tg of config.configuration.targetGroups) {
|
|
317
|
+
if (!tg.name || !tg.port || !tg.protocol) {
|
|
318
|
+
throw new Error("Each targetGroup must have name, port, and protocol");
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
if (config.configuration?.listenerRules) {
|
|
323
|
+
for (const rule of config.configuration.listenerRules) {
|
|
324
|
+
if (!rule.priority || !rule.conditions || !rule.actions) {
|
|
325
|
+
throw new Error("Each listenerRule must have priority, conditions, and actions");
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
exports.AlbFactory = AlbFactory;
|
|
@@ -0,0 +1,56 @@
|
|
|
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.attachSecretAccessPolicy = attachSecretAccessPolicy;
|
|
37
|
+
const aws = __importStar(require("@pulumi/aws"));
|
|
38
|
+
const pulumi = __importStar(require("@pulumi/pulumi"));
|
|
39
|
+
function attachSecretAccessPolicy(params) {
|
|
40
|
+
return new aws.iam.RolePolicy(`${params.name}-secrets-policy`, {
|
|
41
|
+
role: params.role.id,
|
|
42
|
+
policy: pulumi.all([params.secretArn]).apply(([secretArn]) => JSON.stringify({
|
|
43
|
+
Version: "2012-10-17",
|
|
44
|
+
Statement: [
|
|
45
|
+
{
|
|
46
|
+
Effect: "Allow",
|
|
47
|
+
Action: [
|
|
48
|
+
"secretsmanager:GetSecretValue",
|
|
49
|
+
"secretsmanager:DescribeSecret"
|
|
50
|
+
],
|
|
51
|
+
Resource: secretArn,
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
})),
|
|
55
|
+
});
|
|
56
|
+
}
|