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.
Files changed (199) hide show
  1. package/dist/src/core/config.js +2 -0
  2. package/dist/src/core/configMerge.js +266 -0
  3. package/dist/src/core/configUtils.js +72 -0
  4. package/dist/src/core/dependencyResolver.js +17 -0
  5. package/dist/src/core/deployUtils.js +73 -0
  6. package/dist/src/core/dynamicResourceManager.js +709 -0
  7. package/dist/src/core/entrypoint.js +56 -0
  8. package/dist/src/core/generateFinalConfig.js +45 -0
  9. package/dist/src/core/index.js +24 -0
  10. package/dist/src/core/resourceMap.js +99 -0
  11. package/dist/src/factories/accountPermissions.js +134 -0
  12. package/dist/src/factories/acmFactory.js +30 -0
  13. package/dist/src/factories/albFactory.js +331 -0
  14. package/dist/src/factories/attachSecretAccessPolicy.js +56 -0
  15. package/dist/src/factories/auroraFactory.js +619 -0
  16. package/dist/src/factories/backupPolicy.js +152 -0
  17. package/dist/src/factories/bastionFactory.js +91 -0
  18. package/dist/src/factories/bedrockFactory.js +334 -0
  19. package/dist/src/factories/budgetFactory.js +64 -0
  20. package/dist/src/factories/buildAlbCloudWatchAlarmsHelper.js +79 -0
  21. package/dist/src/factories/buildAlbCloudWatchDashboardHelper.js +106 -0
  22. package/dist/src/factories/buildAlbListenerRulesHelper.js +45 -0
  23. package/dist/src/factories/buildAlbListenersHelper.js +64 -0
  24. package/dist/src/factories/buildAlbResourceHelper.js +54 -0
  25. package/dist/src/factories/buildAlbRoute53RecordHelper.js +49 -0
  26. package/dist/src/factories/buildAlbTargetGroupsHelper.js +47 -0
  27. package/dist/src/factories/buildAlbWafAssociationHelper.js +43 -0
  28. package/dist/src/factories/buildAndPushDockerImage.js +57 -0
  29. package/dist/src/factories/buildAwsCloudWatchAlarmsHelper.js +118 -0
  30. package/dist/src/factories/buildCloudFrontRoute53RecordHelper.js +49 -0
  31. package/dist/src/factories/buildEcsClusterArgs.js +32 -0
  32. package/dist/src/factories/buildEcsSecrets.js +48 -0
  33. package/dist/src/factories/buildForceRedeployEnv.js +8 -0
  34. package/dist/src/factories/buildResourceOptions.js +11 -0
  35. package/dist/src/factories/buildS3StaticHostingCicdHelper.js +142 -0
  36. package/dist/src/factories/buildS3StaticHostingCloudWatchDashboardHelper.js +122 -0
  37. package/dist/src/factories/cloudTrailFactory.js +22 -0
  38. package/dist/src/factories/cloudWatchCompositeAlarmFactory.js +91 -0
  39. package/dist/src/factories/cloudWatchInsightsQueryFactory.js +83 -0
  40. package/dist/src/factories/cloudWatchLogGroupFactory.js +84 -0
  41. package/dist/src/factories/cloudfrontCodePipelineFactory.js +357 -0
  42. package/dist/src/factories/cloudwatchAlarmsFactory.js +121 -0
  43. package/dist/src/factories/codePipelineNotificationFactory.js +193 -0
  44. package/dist/src/factories/codePipelineNotificationRulesFactory.js +117 -0
  45. package/dist/src/factories/codeStarConnectionFactory.js +56 -0
  46. package/dist/src/factories/collectSecretKeys.js +18 -0
  47. package/dist/src/factories/comprehensiveNotificationFactory.js +250 -0
  48. package/dist/src/factories/costAndUsageReportFactory.js +32 -0
  49. package/dist/src/factories/createAwsAcmCertificate.js +40 -0
  50. package/dist/src/factories/createAwsBudget.js +40 -0
  51. package/dist/src/factories/createAwsCloudTrail.js +59 -0
  52. package/dist/src/factories/createAwsCloudwatchDashboard.js +59 -0
  53. package/dist/src/factories/createAwsEc2Instance.js +40 -0
  54. package/dist/src/factories/createAwsEventBridgeEventBus.js +40 -0
  55. package/dist/src/factories/createAwsGuardDutyDetector.js +40 -0
  56. package/dist/src/factories/createAwsGuardDutyDetectorFeature.js +45 -0
  57. package/dist/src/factories/createAwsGuardDutyFilter.js +46 -0
  58. package/dist/src/factories/createAwsGuardDutyPublishingDestination.js +50 -0
  59. package/dist/src/factories/createAwsHostedZone.js +40 -0
  60. package/dist/src/factories/createAwsIamRole.js +49 -0
  61. package/dist/src/factories/createAwsIamRoleInlinePolicies.js +48 -0
  62. package/dist/src/factories/createAwsIdentitystoreGroup.js +44 -0
  63. package/dist/src/factories/createAwsIdentitystoreGroupMembership.js +56 -0
  64. package/dist/src/factories/createAwsIdentitystoreUser.js +47 -0
  65. package/dist/src/factories/createAwsInspectorAssessmentTarget.js +47 -0
  66. package/dist/src/factories/createAwsInspectorDelegatedAdminAccount.js +47 -0
  67. package/dist/src/factories/createAwsInspectorEnabler.js +49 -0
  68. package/dist/src/factories/createAwsInspectorOrganizationConfiguration.js +55 -0
  69. package/dist/src/factories/createAwsKmsAliases.js +47 -0
  70. package/dist/src/factories/createAwsKmsKey.js +51 -0
  71. package/dist/src/factories/createAwsMacieAccount.js +45 -0
  72. package/dist/src/factories/createAwsMacieClassificationJob.js +53 -0
  73. package/dist/src/factories/createAwsMacieMember.js +49 -0
  74. package/dist/src/factories/createAwsMacieOrganizationConfiguration.js +44 -0
  75. package/dist/src/factories/createAwsRdsCluster.js +40 -0
  76. package/dist/src/factories/createAwsRdsClusterInstance.js +40 -0
  77. package/dist/src/factories/createAwsRdsInstance.js +40 -0
  78. package/dist/src/factories/createAwsRdsSubnetGroup.js +40 -0
  79. package/dist/src/factories/createAwsRoute53Record.js +40 -0
  80. package/dist/src/factories/createAwsSecret.js +40 -0
  81. package/dist/src/factories/createAwsSecretRotation.js +40 -0
  82. package/dist/src/factories/createAwsSecretVersion.js +40 -0
  83. package/dist/src/factories/createAwsSecurityGroup.js +40 -0
  84. package/dist/src/factories/createAwsSecurityGroupRule.js +40 -0
  85. package/dist/src/factories/createAwsSecurityHubAccount.js +40 -0
  86. package/dist/src/factories/createAwsSecurityHubAutomationRule.js +48 -0
  87. package/dist/src/factories/createAwsSecurityHubStandardsControl.js +44 -0
  88. package/dist/src/factories/createAwsSecurityHubStandardsSubscription.js +42 -0
  89. package/dist/src/factories/createAwsSesDomainDkim.js +40 -0
  90. package/dist/src/factories/createAwsSesDomainIdentity.js +40 -0
  91. package/dist/src/factories/createAwsSesEmailIdentity.js +40 -0
  92. package/dist/src/factories/createAwsSnsSubscription.js +62 -0
  93. package/dist/src/factories/createAwsSnsTopic.js +41 -0
  94. package/dist/src/factories/createAwsSqsQueue.js +40 -0
  95. package/dist/src/factories/createAwsSsmParameters.js +66 -0
  96. package/dist/src/factories/createAwsSsoAccountAssignment.js +66 -0
  97. package/dist/src/factories/createAwsSsoPermissionSet.js +64 -0
  98. package/dist/src/factories/createAwsStepFunctionsStateMachine.js +40 -0
  99. package/dist/src/factories/createBudget.js +56 -0
  100. package/dist/src/factories/createBudgetWithSnsAlert.js +79 -0
  101. package/dist/src/factories/createCostAndUsageReport.js +40 -0
  102. package/dist/src/factories/createEcrRepo.js +69 -0
  103. package/dist/src/factories/createEcsRolesAndPolicies.js +84 -0
  104. package/dist/src/factories/createEcsService.js +71 -0
  105. package/dist/src/factories/createEnvSecret.js +60 -0
  106. package/dist/src/factories/createGithubCodeStarConnection.js +44 -0
  107. package/dist/src/factories/createIamUserWithAccessKey.js +44 -0
  108. package/dist/src/factories/createLambdaFunction.js +89 -0
  109. package/dist/src/factories/createLambdaPermission.js +57 -0
  110. package/dist/src/factories/createListenerRule.js +68 -0
  111. package/dist/src/factories/createLogGroup.js +44 -0
  112. package/dist/src/factories/createSlackChannelConfiguration.js +49 -0
  113. package/dist/src/factories/createTargetGroup.js +50 -0
  114. package/dist/src/factories/createTaskDefinition.js +49 -0
  115. package/dist/src/factories/createVpcEndpoint.js +49 -0
  116. package/dist/src/factories/dashboardFactory.js +94 -0
  117. package/dist/src/factories/dataProtectionPolicyBuilder.js +103 -0
  118. package/dist/src/factories/ec2Factory.js +67 -0
  119. package/dist/src/factories/ecsClusterFactory.js +90 -0
  120. package/dist/src/factories/ecsCodePipelineFactory.js +308 -0
  121. package/dist/src/factories/ecsServiceFactory.js +350 -0
  122. package/dist/src/factories/enhancedCloudFrontCodePipelineFactory.js +205 -0
  123. package/dist/src/factories/enhancedEcsCodePipelineFactory.js +189 -0
  124. package/dist/src/factories/eventBridgeBusFactory.js +84 -0
  125. package/dist/src/factories/eventBridgeFactory.js +26 -0
  126. package/dist/src/factories/eventBridgeRuleFactory.js +114 -0
  127. package/dist/src/factories/fetchAllSecrets.js +51 -0
  128. package/dist/src/factories/getDeterministicPriority.js +13 -0
  129. package/dist/src/factories/getOrCreateSshKeyPair.js +57 -0
  130. package/dist/src/factories/guardDutyFactory.js +151 -0
  131. package/dist/src/factories/hostedZoneFactory.js +30 -0
  132. package/dist/src/factories/iamRoleFactory.js +29 -0
  133. package/dist/src/factories/inspectorFactory.js +109 -0
  134. package/dist/src/factories/kmsKeyFactory.js +32 -0
  135. package/dist/src/factories/lambdaFactory.js +133 -0
  136. package/dist/src/factories/lambdaPermissionFactory.js +32 -0
  137. package/dist/src/factories/logDataProtectionPolicyFactory.js +81 -0
  138. package/dist/src/factories/macieFactory.js +85 -0
  139. package/dist/src/factories/networkingFactory.js +429 -0
  140. package/dist/src/factories/opensearchCollectionFactory.js +109 -0
  141. package/dist/src/factories/organizationFactory.js +221 -0
  142. package/dist/src/factories/processReservedInstances.js +6 -0
  143. package/dist/src/factories/processSavingsPlans.js +43 -0
  144. package/dist/src/factories/rdsFactory.js +40 -0
  145. package/dist/src/factories/recordFactory.js +36 -0
  146. package/dist/src/factories/resolveEnvSecrets.js +14 -0
  147. package/dist/src/factories/resourceFactory.js +12 -0
  148. package/dist/src/factories/s3Factory.js +262 -0
  149. package/dist/src/factories/s3StaticHostingFactory.backup.js +424 -0
  150. package/dist/src/factories/s3StaticHostingFactory.js +348 -0
  151. package/dist/src/factories/s3StaticHostingFactory.refactored.js +334 -0
  152. package/dist/src/factories/savingsPlanFactory.js +26 -0
  153. package/dist/src/factories/secretsManagerFactory.js +107 -0
  154. package/dist/src/factories/securityGroupFactory.js +28 -0
  155. package/dist/src/factories/securityGroupRuleFactory.js +43 -0
  156. package/dist/src/factories/securityHubFactory.js +96 -0
  157. package/dist/src/factories/sesDomainDkimFactory.js +25 -0
  158. package/dist/src/factories/sesFactory.js +25 -0
  159. package/dist/src/factories/sesIdentitiesFactory.js +134 -0
  160. package/dist/src/factories/simpleNotificationFactory.js +112 -0
  161. package/dist/src/factories/smtpUserFactory.js +108 -0
  162. package/dist/src/factories/snsFactory.js +87 -0
  163. package/dist/src/factories/sqsFactory.js +41 -0
  164. package/dist/src/factories/ssmParameterFactory.js +67 -0
  165. package/dist/src/factories/ssoFactory.js +32 -0
  166. package/dist/src/factories/ssoGroupFactory.js +41 -0
  167. package/dist/src/factories/ssoPermissionSetFactory.js +29 -0
  168. package/dist/src/factories/ssoUserFactory.js +30 -0
  169. package/dist/src/factories/stepFunctionsFactory.js +32 -0
  170. package/dist/src/factories/tagPolicies.js +99 -0
  171. package/dist/src/factories/transformBudgetCostFilters.js +8 -0
  172. package/dist/src/factories/transformBudgetNotifications.js +12 -0
  173. package/dist/src/factories/transformBudgetPlannedLimits.js +8 -0
  174. package/dist/src/factories/types.js +2 -0
  175. package/dist/src/factories/validateAcmConfig.js +26 -0
  176. package/dist/src/factories/validateAuroraConfig.js +8 -0
  177. package/dist/src/factories/validateBedrockConfig.js +124 -0
  178. package/dist/src/factories/validateDashboardConfig.js +28 -0
  179. package/dist/src/factories/validateEventBridgeConfig.js +14 -0
  180. package/dist/src/factories/validateHostedZoneConfig.js +26 -0
  181. package/dist/src/factories/validateIamRoleConfig.js +8 -0
  182. package/dist/src/factories/validateKmsKeyConfig.js +8 -0
  183. package/dist/src/factories/validateRdsConfig.js +17 -0
  184. package/dist/src/factories/validateRoute53RecordConfig.js +41 -0
  185. package/dist/src/factories/validateS3Config.js +8 -0
  186. package/dist/src/factories/validateSecretsManagerConfig.js +8 -0
  187. package/dist/src/factories/validateSecurityGroupConfig.js +8 -0
  188. package/dist/src/factories/validateSecurityGroupRuleConfig.js +8 -0
  189. package/dist/src/factories/validateSesDomainDkimConfig.js +8 -0
  190. package/dist/src/factories/validateSesDomainIdentityConfig.js +8 -0
  191. package/dist/src/factories/validateSesIdentitiesConfig.js +40 -0
  192. package/dist/src/factories/validateSnsConfig.js +11 -0
  193. package/dist/src/factories/validateSqsConfig.js +11 -0
  194. package/dist/src/factories/validateSsmParameterFactoryConfig.js +9 -0
  195. package/dist/src/factories/validateStepFunctionsConfig.js +8 -0
  196. package/dist/src/factories/vpcEndpointFactory.js +98 -0
  197. package/dist/src/factories/wafFactory.js +499 -0
  198. package/package.json +71 -0
  199. package/scripts/copy-assets.js +136 -0
@@ -0,0 +1,152 @@
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.BackupPolicy = void 0;
37
+ const aws = __importStar(require("@pulumi/aws"));
38
+ const pulumi = __importStar(require("@pulumi/pulumi"));
39
+ class BackupPolicy extends pulumi.ComponentResource {
40
+ accounts;
41
+ assumeRoleName;
42
+ backupRegion;
43
+ orgUnitId;
44
+ primaryRegions;
45
+ monthlyBackupPolicyIamRoleName = "MyMonthlyBackupIamRole";
46
+ constructor(name, args, opts) {
47
+ super("acme:policies:BackupPolicy", name, undefined, opts);
48
+ this.accounts = args.accounts;
49
+ this.assumeRoleName = args.assumeRoleName;
50
+ this.backupRegion = args.backupRegion;
51
+ this.orgUnitId = args.orgUnitId;
52
+ this.primaryRegions = args.primaryRegions;
53
+ for (const accountName of Object.keys(args.accounts)) {
54
+ const account = args.accounts[accountName];
55
+ const accountProvider = new aws.Provider(`${accountName}Provider`, {
56
+ assumeRole: {
57
+ roleArn: pulumi.interpolate `arn:aws:iam::${account.id}:role/${this.assumeRoleName}`,
58
+ },
59
+ allowedAccountIds: [account.id],
60
+ }, { parent: this });
61
+ this.createBackupVault(accountName, accountProvider);
62
+ this.createBackupPolicyIamRole(accountName, accountProvider);
63
+ }
64
+ this.createMonthlyBackupPolicy();
65
+ super.registerOutputs();
66
+ }
67
+ createBackupVault(accountName, accountProvider) {
68
+ const vault = new aws.backup.Vault(`backupVault-${accountName}`, { name: "Default" }, { provider: accountProvider, parent: this });
69
+ }
70
+ createBackupPolicyIamRole(accountName, accountProvider) {
71
+ const backupPolicyRole = new aws.iam.Role(`${accountName}BackupPolicyRole`, {
72
+ name: this.monthlyBackupPolicyIamRoleName,
73
+ assumeRolePolicy: {
74
+ Statement: [
75
+ {
76
+ Effect: "Allow",
77
+ Action: "sts:AssumeRole",
78
+ Principal: { Service: "backup.amazonaws.com" },
79
+ },
80
+ ],
81
+ Version: "2012-10-17",
82
+ },
83
+ managedPolicyArns: [
84
+ "arn:aws:iam::aws:policy/service-role/AWSBackupServiceRolePolicyForBackup",
85
+ ],
86
+ }, { provider: accountProvider, parent: this });
87
+ }
88
+ createMonthlyBackupPolicy() {
89
+ const content = this.getMonthlyBackupPolicyJson();
90
+ const backupPolicy = new aws.organizations.Policy("orgBackupPolicy", {
91
+ type: "BACKUP_POLICY",
92
+ content,
93
+ }, { parent: this });
94
+ const attachment = new aws.organizations.PolicyAttachment("orgBackupPolicyAttachment", {
95
+ policyId: backupPolicy.id,
96
+ targetId: this.orgUnitId,
97
+ }, { parent: this });
98
+ }
99
+ getMonthlyBackupPolicyJson() {
100
+ const backupVaultCopyAction = {};
101
+ backupVaultCopyAction[`arn:aws:backup:${this.backupRegion}:$account:backup-vault:Default`] = {
102
+ target_backup_vault_arn: {
103
+ "@@assign": `arn:aws:backup:${this.backupRegion}:$account:backup-vault:Default`,
104
+ },
105
+ lifecycle: {
106
+ move_to_cold_storage_after_days: {
107
+ "@@assign": "30",
108
+ },
109
+ delete_after_days: {
110
+ "@@assign": "365",
111
+ },
112
+ },
113
+ };
114
+ return JSON.stringify({
115
+ plans: {
116
+ Monthly_Backup_Plan: {
117
+ regions: {
118
+ "@@assign": this.primaryRegions,
119
+ },
120
+ rules: {
121
+ Monthly: {
122
+ schedule_expression: {
123
+ "@@assign": "cron(0 5 1 * ? *)",
124
+ },
125
+ start_backup_window_minutes: { "@@assign": "480" },
126
+ target_backup_vault_name: { "@@assign": "Default" },
127
+ lifecycle: {
128
+ move_to_cold_storage_after_days: {
129
+ "@@assign": "30",
130
+ },
131
+ delete_after_days: { "@@assign": "365" },
132
+ },
133
+ copy_actions: backupVaultCopyAction,
134
+ },
135
+ },
136
+ selections: {
137
+ tags: {
138
+ Backup_Assignment: {
139
+ iam_role_arn: {
140
+ "@@assign": `arn:aws:iam::$account:role/${this.monthlyBackupPolicyIamRoleName}`,
141
+ },
142
+ tag_key: { "@@assign": "BackupType" },
143
+ tag_value: { "@@assign": ["MONTHLY"] },
144
+ },
145
+ },
146
+ },
147
+ },
148
+ },
149
+ });
150
+ }
151
+ }
152
+ exports.BackupPolicy = BackupPolicy;
@@ -0,0 +1,91 @@
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.BastionFactory = void 0;
37
+ const aws = __importStar(require("@pulumi/aws"));
38
+ const path = __importStar(require("path"));
39
+ const resourceFactory_1 = require("./resourceFactory");
40
+ const getOrCreateSshKeyPair_1 = require("./getOrCreateSshKeyPair");
41
+ class BastionFactory extends resourceFactory_1.ResourceFactory {
42
+ async createResource(config, provider) {
43
+ const { vpcId, subnetId, sgId, ami, instanceType, keyName, publicKey, assetsPath } = config.inputs;
44
+ const meta = config.meta || {};
45
+ let finalKeyName = keyName;
46
+ let keyPair = undefined;
47
+ let privateKey = undefined;
48
+ let pubKey = publicKey;
49
+ const keysDir = assetsPath
50
+ ? path.join(assetsPath, "keys")
51
+ : path.resolve(__dirname, "../../assets/keys");
52
+ if (!finalKeyName) {
53
+ if (!pubKey) {
54
+ const keyPairObj = (0, getOrCreateSshKeyPair_1.getOrCreateSshKeyPair)(config.id, keysDir);
55
+ privateKey = keyPairObj.privateKey;
56
+ pubKey = keyPairObj.publicKey;
57
+ }
58
+ keyPair = new aws.ec2.KeyPair(`${meta.environment}-${config.id}-bastion-key`, {
59
+ publicKey: pubKey,
60
+ }, provider ? { provider } : undefined);
61
+ finalKeyName = undefined;
62
+ }
63
+ const instance = new aws.ec2.Instance(`${meta.environment}-${config.id}-bastion`, {
64
+ ami,
65
+ instanceType: instanceType || "t3.micro",
66
+ subnetId,
67
+ vpcSecurityGroupIds: [sgId],
68
+ keyName: keyPair ? keyPair.keyName : finalKeyName,
69
+ associatePublicIpAddress: true,
70
+ tags: {
71
+ Name: `${config.id}-bastion`,
72
+ },
73
+ }, provider ? { provider } : undefined);
74
+ return { instance, keyPair, privateKey };
75
+ }
76
+ getOutputs(resource) {
77
+ return {
78
+ publicIp: resource.instance.publicIp,
79
+ instanceId: resource.instance.id,
80
+ keyName: resource.keyPair?.keyName,
81
+ privateKey: resource.privateKey,
82
+ sgId: resource.instance.vpcSecurityGroupIds?.[0],
83
+ };
84
+ }
85
+ validateConfig(config) {
86
+ if (!config.inputs.vpcId || !config.inputs.subnetId || !config.inputs.sgId || !config.inputs.ami) {
87
+ throw new Error("Bastion config must include vpcId, subnetId, sgId, and ami in inputs");
88
+ }
89
+ }
90
+ }
91
+ exports.BastionFactory = BastionFactory;
@@ -0,0 +1,334 @@
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.BedrockFactory = void 0;
37
+ const resourceFactory_1 = require("./resourceFactory");
38
+ const validateBedrockConfig_1 = require("./validateBedrockConfig");
39
+ const aws = __importStar(require("@pulumi/aws"));
40
+ const pulumi = __importStar(require("@pulumi/pulumi"));
41
+ class BedrockFactory extends resourceFactory_1.ResourceFactory {
42
+ async createResource(config) {
43
+ this.validateConfig(config);
44
+ const { foundationModel, knowledgeBases, agents, guardrails, monitoring, security, costOptimization } = config.configuration;
45
+ const { modelId, region, enableModelAccess = true, crossRegionInference = false } = foundationModel;
46
+ const current = aws.getCallerIdentity({});
47
+ const currentRegion = aws.getRegion({});
48
+ const accountId = current.then(acc => acc.accountId);
49
+ const deploymentRegion = region || currentRegion.then(r => r.name);
50
+ const modelArn = pulumi.interpolate `arn:aws:bedrock:${deploymentRegion}:${accountId}:inference-profile/${modelId}`;
51
+ const bedrockServiceRole = new aws.iam.Role(`${config.id}-bedrock-role`, {
52
+ assumeRolePolicy: JSON.stringify({
53
+ Version: "2012-10-17",
54
+ Statement: [
55
+ {
56
+ Effect: "Allow",
57
+ Principal: {
58
+ Service: "bedrock.amazonaws.com"
59
+ },
60
+ Action: "sts:AssumeRole"
61
+ }
62
+ ]
63
+ }),
64
+ tags: {
65
+ Purpose: "Bedrock Service Role",
66
+ ModelId: modelId
67
+ }
68
+ });
69
+ const bedrockPolicy = new aws.iam.Policy(`${config.id}-bedrock-pol`, {
70
+ policy: pulumi.all([modelArn]).apply(([arn]) => JSON.stringify({
71
+ Version: "2012-10-17",
72
+ Statement: [
73
+ {
74
+ Effect: "Allow",
75
+ Action: [
76
+ "bedrock:InvokeModel",
77
+ "bedrock:InvokeModelWithResponseStream",
78
+ "bedrock:GetFoundationModel",
79
+ "bedrock:ListFoundationModels",
80
+ "bedrock:GetModelInvocationLoggingConfiguration",
81
+ "bedrock:PutModelInvocationLoggingConfiguration"
82
+ ],
83
+ Resource: arn
84
+ },
85
+ {
86
+ Effect: "Allow",
87
+ Action: [
88
+ "bedrock:RetrieveAndGenerate",
89
+ "bedrock:Retrieve",
90
+ "bedrock:InvokeAgent"
91
+ ],
92
+ Resource: "*"
93
+ }
94
+ ]
95
+ }))
96
+ });
97
+ new aws.iam.RolePolicyAttachment(`${config.id}-bedrock-pol-att`, {
98
+ role: bedrockServiceRole.name,
99
+ policyArn: bedrockPolicy.arn
100
+ });
101
+ let outputs = {
102
+ modelArn: modelArn,
103
+ modelId,
104
+ region: pulumi.output(deploymentRegion),
105
+ iamRoleArn: bedrockServiceRole.arn
106
+ };
107
+ if (monitoring?.enableCloudWatchLogs) {
108
+ const logGroup = new aws.cloudwatch.LogGroup(`${config.id}-bedrock-logs`, {
109
+ name: monitoring.logGroupName || `/aws/bedrock/${config.id}`,
110
+ retentionInDays: 365,
111
+ tags: {
112
+ Purpose: "Bedrock Monitoring",
113
+ ModelId: modelId
114
+ }
115
+ });
116
+ outputs.logGroupArn = logGroup.arn;
117
+ const cloudWatchPolicy = new aws.iam.Policy(`${config.id}-cw-pol`, {
118
+ policy: pulumi.all([logGroup.arn]).apply(([logGroupArn]) => JSON.stringify({
119
+ Version: "2012-10-17",
120
+ Statement: [
121
+ {
122
+ Effect: "Allow",
123
+ Action: [
124
+ "logs:CreateLogGroup",
125
+ "logs:CreateLogStream",
126
+ "logs:PutLogEvents",
127
+ "logs:DescribeLogGroups",
128
+ "logs:DescribeLogStreams"
129
+ ],
130
+ Resource: [
131
+ logGroupArn,
132
+ `${logGroupArn}:*`
133
+ ]
134
+ }
135
+ ]
136
+ }))
137
+ });
138
+ new aws.iam.RolePolicyAttachment(`${config.id}-cw-pol-att`, {
139
+ role: bedrockServiceRole.name,
140
+ policyArn: cloudWatchPolicy.arn
141
+ });
142
+ }
143
+ if (security?.enableEncryption) {
144
+ const kmsKey = new aws.kms.Key(`${config.id}-bedrock-kms`, {
145
+ description: `KMS key for Bedrock ${config.id} encryption`,
146
+ policy: pulumi.all([accountId]).apply(([accId]) => JSON.stringify({
147
+ Version: "2012-10-17",
148
+ Statement: [
149
+ {
150
+ Sid: "Enable IAM User Permissions",
151
+ Effect: "Allow",
152
+ Principal: {
153
+ AWS: `arn:aws:iam::${accId}:root`
154
+ },
155
+ Action: "kms:*",
156
+ Resource: "*"
157
+ },
158
+ {
159
+ Sid: "Allow Bedrock service",
160
+ Effect: "Allow",
161
+ Principal: {
162
+ Service: "bedrock.amazonaws.com"
163
+ },
164
+ Action: [
165
+ "kms:Decrypt",
166
+ "kms:GenerateDataKey",
167
+ "kms:DescribeKey"
168
+ ],
169
+ Resource: "*"
170
+ }
171
+ ]
172
+ })),
173
+ tags: {
174
+ Purpose: "Bedrock Encryption",
175
+ ModelId: modelId
176
+ }
177
+ });
178
+ const kmsAlias = new aws.kms.Alias(`${config.id}-kms-alias`, {
179
+ name: `alias/bedrock-${config.id}`,
180
+ targetKeyId: kmsKey.keyId
181
+ });
182
+ outputs.kmsKeyArn = kmsKey.arn;
183
+ }
184
+ if (knowledgeBases && knowledgeBases.length > 0) {
185
+ const knowledgeBaseArns = [];
186
+ const knowledgeBaseIds = [];
187
+ for (const kbConfig of knowledgeBases) {
188
+ if (kbConfig.vectorDatabase.type === 'opensearch') {
189
+ const opensearchRole = new aws.iam.Role(`${config.id}-os-${kbConfig.name}`, {
190
+ assumeRolePolicy: JSON.stringify({
191
+ Version: "2012-10-17",
192
+ Statement: [
193
+ {
194
+ Effect: "Allow",
195
+ Principal: {
196
+ Service: "bedrock.amazonaws.com"
197
+ },
198
+ Action: "sts:AssumeRole"
199
+ }
200
+ ]
201
+ })
202
+ });
203
+ if (kbConfig.dataSource?.type === 's3') {
204
+ const bucketArn = kbConfig.dataSource.s3Configuration?.bucketArn || "";
205
+ const s3Policy = new aws.iam.Policy(`${config.id}-s3-${kbConfig.name}`, {
206
+ policy: pulumi.output(bucketArn).apply(arn => JSON.stringify({
207
+ Version: "2012-10-17",
208
+ Statement: [
209
+ {
210
+ Effect: "Allow",
211
+ Action: [
212
+ "s3:GetObject",
213
+ "s3:ListBucket"
214
+ ],
215
+ Resource: [
216
+ arn,
217
+ `${arn}/*`
218
+ ]
219
+ }
220
+ ]
221
+ }))
222
+ });
223
+ new aws.iam.RolePolicyAttachment(`${config.id}-s3-att-${kbConfig.name}`, {
224
+ role: opensearchRole.name,
225
+ policyArn: s3Policy.arn
226
+ });
227
+ }
228
+ }
229
+ }
230
+ outputs.knowledgeBaseArns = knowledgeBaseArns;
231
+ outputs.knowledgeBaseIds = knowledgeBaseIds;
232
+ }
233
+ if (agents && agents.length > 0) {
234
+ const agentArns = [];
235
+ const agentIds = [];
236
+ const agentAliasArns = [];
237
+ for (const agentConfig of agents) {
238
+ const agentRole = new aws.iam.Role(`${config.id}-ag-${agentConfig.name}`, {
239
+ assumeRolePolicy: JSON.stringify({
240
+ Version: "2012-10-17",
241
+ Statement: [
242
+ {
243
+ Effect: "Allow",
244
+ Principal: {
245
+ Service: "bedrock.amazonaws.com"
246
+ },
247
+ Action: "sts:AssumeRole"
248
+ }
249
+ ]
250
+ })
251
+ });
252
+ const agentModelArn = pulumi.interpolate `arn:aws:bedrock:${deploymentRegion}:${accountId}:inference-profile/${agentConfig.foundationModel}`;
253
+ const agentModelPolicy = new aws.iam.Policy(`${config.id}-mod-${agentConfig.name}`, {
254
+ policy: pulumi.all([agentModelArn]).apply(([arn]) => JSON.stringify({
255
+ Version: "2012-10-17",
256
+ Statement: [
257
+ {
258
+ Effect: "Allow",
259
+ Action: [
260
+ "bedrock:InvokeModel"
261
+ ],
262
+ Resource: arn
263
+ }
264
+ ]
265
+ }))
266
+ });
267
+ new aws.iam.RolePolicyAttachment(`${config.id}-mod-att-${agentConfig.name}`, {
268
+ role: agentRole.name,
269
+ policyArn: agentModelPolicy.arn
270
+ });
271
+ }
272
+ outputs.agentArns = agentArns;
273
+ outputs.agentIds = agentIds;
274
+ outputs.agentAliasArns = agentAliasArns;
275
+ }
276
+ if (guardrails && guardrails.length > 0) {
277
+ const guardrailArns = [];
278
+ const guardrailIds = [];
279
+ outputs.guardrailArns = guardrailArns;
280
+ outputs.guardrailIds = guardrailIds;
281
+ }
282
+ if (security?.enableVpcEndpoint && security.vpcEndpointConfig && config.inputs?.vpcId) {
283
+ const vpcEndpoint = new aws.ec2.VpcEndpoint(`${config.id}-vpc-endpoint`, {
284
+ vpcId: config.inputs.vpcId,
285
+ serviceName: pulumi.interpolate `com.amazonaws.${deploymentRegion}.bedrock-runtime`,
286
+ vpcEndpointType: "Interface",
287
+ subnetIds: security.vpcEndpointConfig.subnetIds,
288
+ securityGroupIds: security.vpcEndpointConfig.securityGroupIds,
289
+ tags: {
290
+ Purpose: "Bedrock VPC Endpoint",
291
+ ModelId: modelId
292
+ }
293
+ });
294
+ outputs.vpcEndpointId = vpcEndpoint.id;
295
+ }
296
+ if (costOptimization?.enableProvisionedThroughput) {
297
+ }
298
+ console.log(`Configured Bedrock foundation model: ${modelId}`);
299
+ modelArn.apply(arn => console.log(`Model ARN: ${arn}`));
300
+ console.log(`Region: ${await deploymentRegion}`);
301
+ bedrockServiceRole.arn.apply(arn => console.log(`IAM Role ARN: ${arn}`));
302
+ return outputs;
303
+ }
304
+ getOutputs(resource) {
305
+ return resource;
306
+ }
307
+ validateConfig(config) {
308
+ (0, validateBedrockConfig_1.validateBedrockConfig)(config);
309
+ if (!config.configuration.foundationModel.modelId) {
310
+ throw new Error("Foundation model ID is required");
311
+ }
312
+ if (!config.configuration.foundationModel.region) {
313
+ throw new Error("Region is required for foundation model");
314
+ }
315
+ if (config.configuration.knowledgeBases) {
316
+ for (const kb of config.configuration.knowledgeBases) {
317
+ if (!kb.name || !kb.vectorDatabase.type) {
318
+ throw new Error("Knowledge base name and vector database type are required");
319
+ }
320
+ if (kb.vectorDatabase.type === 'opensearch' && !kb.vectorDatabase.opensearchConfiguration) {
321
+ throw new Error("OpenSearch configuration is required when using OpenSearch vector database");
322
+ }
323
+ }
324
+ }
325
+ if (config.configuration.agents) {
326
+ for (const agent of config.configuration.agents) {
327
+ if (!agent.name || !agent.foundationModel || !agent.instruction) {
328
+ throw new Error("Agent name, foundation model, and instruction are required");
329
+ }
330
+ }
331
+ }
332
+ }
333
+ }
334
+ exports.BedrockFactory = BedrockFactory;
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BudgetFactory = void 0;
4
+ const resourceFactory_1 = require("./resourceFactory");
5
+ const transformBudgetNotifications_1 = require("./transformBudgetNotifications");
6
+ const transformBudgetCostFilters_1 = require("./transformBudgetCostFilters");
7
+ const transformBudgetPlannedLimits_1 = require("./transformBudgetPlannedLimits");
8
+ const createAwsBudget_1 = require("./createAwsBudget");
9
+ class BudgetFactory extends resourceFactory_1.ResourceFactory {
10
+ async createResource(config) {
11
+ this.validateConfig(config);
12
+ const cfgArr = config.configuration ? config.configuration : config;
13
+ const budgets = [];
14
+ for (const item of cfgArr) {
15
+ const notifications = (0, transformBudgetNotifications_1.transformBudgetNotifications)(item.notifications);
16
+ const costFilters = (0, transformBudgetCostFilters_1.transformBudgetCostFilters)(item.costFilters);
17
+ const plannedLimits = (0, transformBudgetPlannedLimits_1.transformBudgetPlannedLimits)(item.plannedLimits);
18
+ const hasPlannedLimits = Array.isArray(plannedLimits) && plannedLimits.length > 0;
19
+ let autoAdjustData = item.autoAdjustData;
20
+ if (autoAdjustData && typeof autoAdjustData === 'object' && 'lastAutoAdjustTime' in autoAdjustData) {
21
+ const { lastAutoAdjustTime, ...rest } = autoAdjustData;
22
+ autoAdjustData = rest;
23
+ }
24
+ const args = {
25
+ name: item.name,
26
+ namePrefix: item.namePrefix,
27
+ budgetType: item.budgetType || "COST",
28
+ timeUnit: item.timeUnit || "MONTHLY",
29
+ costFilters,
30
+ notifications,
31
+ tags: item.tags,
32
+ costTypes: item.costTypes,
33
+ plannedLimits: hasPlannedLimits ? plannedLimits : undefined,
34
+ autoAdjustData: autoAdjustData,
35
+ timePeriodStart: item.timePeriodStart,
36
+ timePeriodEnd: item.timePeriodEnd,
37
+ accountId: item.accountId,
38
+ };
39
+ if (!hasPlannedLimits) {
40
+ args.limitAmount = item.limit !== undefined ? item.limit.toString() : undefined;
41
+ args.limitUnit = item.limitUnit || "USD";
42
+ }
43
+ budgets.push((0, createAwsBudget_1.createAwsBudget)(item, args));
44
+ }
45
+ return budgets;
46
+ }
47
+ getOutputs(resources) {
48
+ return {
49
+ budgetNames: resources.map(r => r.name),
50
+ };
51
+ }
52
+ validateConfig(config) {
53
+ const cfgArr = config.configuration ? config.configuration : config;
54
+ if (!Array.isArray(cfgArr) || cfgArr.length === 0) {
55
+ throw new Error("Budget config must include non-empty configuration array");
56
+ }
57
+ for (const item of cfgArr) {
58
+ if (!item.name && !item.namePrefix) {
59
+ throw new Error("Each budget must have name or namePrefix");
60
+ }
61
+ }
62
+ }
63
+ }
64
+ exports.BudgetFactory = BudgetFactory;