carlin 1.19.8 → 1.19.9

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 (73) hide show
  1. package/package.json +2 -2
  2. package/dist/cli.js +0 -232
  3. package/dist/config.js +0 -10
  4. package/dist/deploy/addDefaults.cloudFormation.js +0 -138
  5. package/dist/deploy/baseStack/command.js +0 -9
  6. package/dist/deploy/baseStack/config.js +0 -30
  7. package/dist/deploy/baseStack/deployBaseStack.js +0 -59
  8. package/dist/deploy/baseStack/getBaseStackResource.js +0 -26
  9. package/dist/deploy/baseStack/getBucket.template.js +0 -44
  10. package/dist/deploy/baseStack/getLambdaImageBuilder.template.js +0 -186
  11. package/dist/deploy/baseStack/getLambdaLayerBuilder.template.js +0 -140
  12. package/dist/deploy/baseStack/getVpc.template.js +0 -169
  13. package/dist/deploy/cicd/cicd.template.js +0 -922
  14. package/dist/deploy/cicd/command.js +0 -27
  15. package/dist/deploy/cicd/command.options.js +0 -71
  16. package/dist/deploy/cicd/config.js +0 -8
  17. package/dist/deploy/cicd/deployCicd.js +0 -93
  18. package/dist/deploy/cicd/ecsTaskReportCommand.js +0 -51
  19. package/dist/deploy/cicd/getCicdStackName.js +0 -11
  20. package/dist/deploy/cicd/getTriggerPipelineObjectKey.js +0 -11
  21. package/dist/deploy/cicd/lambdas/cicdApiV1.handler.js +0 -124
  22. package/dist/deploy/cicd/lambdas/ecsTaskReport.handler.js +0 -126
  23. package/dist/deploy/cicd/lambdas/executeTasks.js +0 -67
  24. package/dist/deploy/cicd/lambdas/getProcessEnvVariable.js +0 -10
  25. package/dist/deploy/cicd/lambdas/githubWebhooksApiV1.handler.js +0 -146
  26. package/dist/deploy/cicd/lambdas/imageUpdaterSchedule.handler.js +0 -44
  27. package/dist/deploy/cicd/lambdas/index.js +0 -13
  28. package/dist/deploy/cicd/lambdas/pipelines.handler.js +0 -134
  29. package/dist/deploy/cicd/lambdas/putApprovalResultManualTask.js +0 -52
  30. package/dist/deploy/cicd/lambdas/shConditionalCommands.js +0 -30
  31. package/dist/deploy/cicd/pipelines.js +0 -76
  32. package/dist/deploy/cicd/readSSHKey.js +0 -10
  33. package/dist/deploy/cloudFormation.core.js +0 -300
  34. package/dist/deploy/cloudFormation.js +0 -182
  35. package/dist/deploy/command.js +0 -185
  36. package/dist/deploy/lambda/buildLambdaSingleFile.js +0 -30
  37. package/dist/deploy/lambda/deployLambdaCode.js +0 -41
  38. package/dist/deploy/lambda/deployLambdaLayers.js +0 -34
  39. package/dist/deploy/lambda/uploadCodeToECR.js +0 -53
  40. package/dist/deploy/lambda/uploadCodeToS3.js +0 -31
  41. package/dist/deploy/lambdaLayer/command.js +0 -48
  42. package/dist/deploy/lambdaLayer/deployLambdaLayer.js +0 -140
  43. package/dist/deploy/readDockerfile.js +0 -18
  44. package/dist/deploy/s3.js +0 -165
  45. package/dist/deploy/stackName.js +0 -78
  46. package/dist/deploy/staticApp/command.js +0 -79
  47. package/dist/deploy/staticApp/deployStaticApp.js +0 -64
  48. package/dist/deploy/staticApp/findDefaultBuildFolder.js +0 -27
  49. package/dist/deploy/staticApp/getOriginShieldRegion.js +0 -30
  50. package/dist/deploy/staticApp/getStaticAppBucket.js +0 -19
  51. package/dist/deploy/staticApp/invalidateCloudFront.js +0 -42
  52. package/dist/deploy/staticApp/removeOldVersions.js +0 -43
  53. package/dist/deploy/staticApp/staticApp.template.js +0 -303
  54. package/dist/deploy/staticApp/uploadBuiltAppToS3.js +0 -27
  55. package/dist/deploy/utils.js +0 -29
  56. package/dist/generateEnv/generateEnv.js +0 -46
  57. package/dist/generateEnv/generateEnvCommand.js +0 -9
  58. package/dist/index.js +0 -5
  59. package/dist/utils/addGroupToOptions.js +0 -11
  60. package/dist/utils/cloudFormationTemplate.js +0 -132
  61. package/dist/utils/codeBuild.js +0 -50
  62. package/dist/utils/environmentVariables.js +0 -11
  63. package/dist/utils/exec.js +0 -22
  64. package/dist/utils/formatCode.js +0 -12
  65. package/dist/utils/getAwsAccountId.js +0 -10
  66. package/dist/utils/getCurrentBranch.js +0 -33
  67. package/dist/utils/getEnvironment.js +0 -6
  68. package/dist/utils/getIamPath.js +0 -6
  69. package/dist/utils/getProjectName.js +0 -35
  70. package/dist/utils/index.js +0 -17
  71. package/dist/utils/packageJson.js +0 -25
  72. package/dist/utils/readCloudFormationTemplate.js +0 -33
  73. package/dist/utils/readObjectFile.js +0 -46
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carlin",
3
- "version": "1.19.8",
3
+ "version": "1.19.9",
4
4
  "description": "",
5
5
  "license": "GPL-3.0",
6
6
  "author": "Pedro Arantes <arantespp@gmail.com> (https://twitter.com/arantespp)",
@@ -71,5 +71,5 @@
71
71
  "publishConfig": {
72
72
  "registry": "https://registry.npmjs.org/"
73
73
  },
74
- "gitHead": "5624791e118681b8ecbe2372bbc61806442df71b"
74
+ "gitHead": "c198401df0152f9dcfd6094b181996eb6fb08a09"
75
75
  }
package/dist/cli.js DELETED
@@ -1,232 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.options = void 0;
4
- const tslib_1 = require("tslib");
5
- /* eslint-disable no-param-reassign */
6
- const yargs = tslib_1.__importStar(require("yargs"));
7
- const config_1 = require("./config");
8
- const utils_1 = require("./utils");
9
- const change_case_1 = require("change-case");
10
- const command_1 = require("./deploy/command");
11
- const ecsTaskReportCommand_1 = require("./deploy/cicd/ecsTaskReportCommand");
12
- const generateEnvCommand_1 = require("./generateEnv/generateEnvCommand");
13
- const aws_sdk_1 = tslib_1.__importDefault(require("aws-sdk"));
14
- const deep_equal_1 = tslib_1.__importDefault(require("deep-equal"));
15
- const deepmerge_1 = tslib_1.__importDefault(require("deepmerge"));
16
- const find_up_1 = tslib_1.__importDefault(require("find-up"));
17
- const path_1 = tslib_1.__importDefault(require("path"));
18
- const coerceSetEnvVar = (env) => (value) => {
19
- if (value) {
20
- (0, utils_1.setEnvVar)(env, value);
21
- }
22
- return value;
23
- };
24
- exports.options = {
25
- branch: {
26
- coerce: coerceSetEnvVar('BRANCH'),
27
- require: false,
28
- type: 'string',
29
- },
30
- config: {
31
- alias: 'c',
32
- describe: 'Path to config file. You can create a config file and set all options there. Valid extensions: .js, .json, .ts, .yml, or .yaml.',
33
- require: false,
34
- type: 'string',
35
- },
36
- environment: {
37
- alias: ['e', 'env'],
38
- coerce: coerceSetEnvVar('ENVIRONMENT'),
39
- type: 'string',
40
- },
41
- environments: {},
42
- project: {
43
- coerce: coerceSetEnvVar('PROJECT'),
44
- require: false,
45
- type: 'string',
46
- },
47
- region: {
48
- alias: 'r',
49
- // coerce: coerceSetEnvVar('REGION'),
50
- default: config_1.AWS_DEFAULT_REGION,
51
- describe: 'AWS region.',
52
- type: 'string',
53
- },
54
- };
55
- /**
56
- * You can also provide the options creating a property name `carlin`
57
- * inside your `package.json`. [See Yargs reference](https://yargs.js.org/docs/#api-reference-pkgconfkey-cwd).
58
- */
59
- const getPkgConfig = () => config_1.NAME;
60
- /**
61
- * All options can be passed as environment variables matching the prefix
62
- * `CARLIN`. See [Yargs reference](https://yargs.js.org/docs/#api-reference-envprefix).
63
- * Example, we may use `carlin deploy --stack-name StackName` or
64
- * `CARLIN_STACK_NAME=StackName carlin deploy`.
65
- */
66
- const getEnv = () => {
67
- return (0, change_case_1.constantCase)(config_1.NAME);
68
- };
69
- /**
70
- * Transformed to method because finalConfig was failing the tests.
71
- */
72
- const cli = () => {
73
- /**
74
- * All config files merged.
75
- */
76
- let finalConfig;
77
- /**
78
- * If `--config` isn't provided, the algorithm will search for any of these
79
- * files and use it to retrieve the options:
80
- *
81
- * - `carlin.js`
82
- * - `carlin.ts`
83
- * - `carlin.yaml`
84
- * - `carlin.yml`
85
- * - `carlin.json`
86
- *
87
- * The algorithm also make a find up path to search for other config files
88
- * that may exist in parent directories. If find more than one file, they'll
89
- * be merged, in such a way that the files nearest from `process.cwd()` will
90
- * take the precedence at the merging.
91
- *
92
- * This is useful if you have a monorepo and have shared and specific
93
- * configuration. For instance, you may have a config inside `packages/app/`
94
- * folder with the config below:
95
- *
96
- * ```yaml
97
- * stackName: MyMonorepoApp
98
- * region: us-east-2
99
- * ```
100
- *
101
- * And on the root of your monorepo:
102
- *
103
- * ```yaml
104
- * awsAccountId: 123456789012
105
- * region: us-east-1
106
- * ```
107
- *
108
- * The result options that will be passed to the commands executed on
109
- * `packages/app/` will be:
110
- *
111
- * ```yaml
112
- * awsAccountId: 123456789012
113
- * stackName: MyMonorepoApp
114
- * region: us-east-2
115
- * ```
116
- */
117
- const getConfig = () => {
118
- const names = ['js', 'yml', 'yaml', 'json', 'ts'].map((ext) => `${config_1.NAME}.${ext}`);
119
- const paths = [];
120
- let currentPath = process.cwd();
121
- let findUpPath;
122
- do {
123
- findUpPath = find_up_1.default.sync(names, { cwd: currentPath });
124
- if (findUpPath) {
125
- currentPath = path_1.default.resolve(findUpPath, '../..');
126
- paths.push(findUpPath);
127
- }
128
- } while (findUpPath);
129
- const configs = paths.map((p) => (0, utils_1.readObjectFile)({ path: p }) || {});
130
- /**
131
- * Using configs.reverser() to get the most far config first. This way the
132
- * nearest configs will replace others.
133
- */
134
- finalConfig = deepmerge_1.default.all(configs.reverse());
135
- return finalConfig;
136
- };
137
- return (yargs
138
- /**
139
- * It can't be full strict because options may overlap among carlin config
140
- * files.
141
- */
142
- .strictCommands()
143
- .scriptName(config_1.NAME)
144
- .env(getEnv())
145
- .options((0, utils_1.addGroupToOptions)(exports.options, 'Common Options'))
146
- .middleware(((argv, { parsed }) => {
147
- const { environment, environments } = argv;
148
- /**
149
- * Create final options with environment and environments.
150
- */
151
- if (environment &&
152
- environments &&
153
- environments[environment]) {
154
- Object.entries(environments[environment]).forEach(([key, value]) => {
155
- /**
156
- * The case where argv[key] must not have the environment value is
157
- * when such value is passed as option via CLI. For instance,
158
- *
159
- * $ carlin deploy --stack-name SomeName
160
- *
161
- * SomeName must be used as stack name independently of the
162
- * environment values https://github.com/ttoss/carlin/issues/13.
163
- *
164
- * Three cases set argv:
165
- *
166
- * 1. Default.
167
- * 2. Config file.
168
- * 3. CLI
169
- *
170
- * - Case 1 we determine if the parsed.defaulted is true.
171
- * - Case 2 we determine if `argv[key] === finalConfig[key]`.
172
- * - Case 3 if the two above are falsy.
173
- */
174
- const isKeyFromCli = (() => {
175
- var _a;
176
- const paramCaseKey = (0, change_case_1.paramCase)(key);
177
- /**
178
- * Case 1.
179
- * Fixes #16 https://github.com/ttoss/carlin/issues/16
180
- */
181
- if ((_a = parsed === null || parsed === void 0 ? void 0 : parsed.defaulted) === null || _a === void 0 ? void 0 : _a[paramCaseKey]) {
182
- return false;
183
- }
184
- /**
185
- * Case 2.
186
- *
187
- * Fixes #13 https://github.com/ttoss/carlin/issues/13
188
- *
189
- * Deep equal because arg can be an array or object.
190
- */
191
- if ((0, deep_equal_1.default)(argv[key], finalConfig[key])) {
192
- return false;
193
- }
194
- return true;
195
- })();
196
- if (!isKeyFromCli) {
197
- argv[key] = value;
198
- }
199
- });
200
- }
201
- }))
202
- /**
203
- * Sometimes "environments" can be written as "environment" on config file.
204
- */
205
- .middleware(({ environment }) => {
206
- if (!['string', 'undefined'].includes(typeof environment)) {
207
- throw new Error(`environment type is invalid. The value: ${JSON.stringify(environment)}`);
208
- }
209
- })
210
- /**
211
- * Set AWS region.
212
- */
213
- .middleware(({ region }) => {
214
- aws_sdk_1.default.config.region = region;
215
- (0, utils_1.setEnvVar)('REGION', region);
216
- })
217
- .pkgConf(getPkgConfig())
218
- .config(getConfig())
219
- .config('config', (configPath) => (0, utils_1.readObjectFile)({ path: configPath }))
220
- .command({
221
- command: 'print-args',
222
- describe: false,
223
- // eslint-disable-next-line no-console
224
- handler: (argv) => console.log(JSON.stringify(argv, null, 2)),
225
- })
226
- .command(command_1.deployCommand)
227
- .command(ecsTaskReportCommand_1.ecsTaskReportCommand)
228
- .command(generateEnvCommand_1.generateEnvCommand)
229
- .epilogue('For more information, find our manual at https://carlin.ttoss.dev')
230
- .help());
231
- };
232
- exports.default = cli;
package/dist/config.js DELETED
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CLOUDFRONT_REGION = exports.AWS_DEFAULT_REGION = exports.NAME = void 0;
4
- exports.NAME = 'carlin';
5
- exports.AWS_DEFAULT_REGION = 'us-east-1';
6
- /**
7
- * CloudFront triggers can be only in US East (N. Virginia) Region.
8
- * https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-requirements-limits.html#lambda-requirements-cloudfront-triggers
9
- */
10
- exports.CLOUDFRONT_REGION = 'us-east-1';
@@ -1,138 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addDefaults = void 0;
4
- const config_1 = require("../config");
5
- const utils_1 = require("../utils");
6
- const addDefaultsParametersAndTagsToParams = async (params) => {
7
- const branchName = await (0, utils_1.getCurrentBranch)();
8
- const environment = await (0, utils_1.getEnvironment)();
9
- const packageName = await (0, utils_1.getPackageName)();
10
- const packageVersion = await (0, utils_1.getPackageVersion)();
11
- const projectName = await (0, utils_1.getProjectName)();
12
- return {
13
- ...params,
14
- Parameters: [
15
- ...(params.Parameters || []),
16
- ...(environment
17
- ? [{ ParameterKey: 'Environment', ParameterValue: environment }]
18
- : []),
19
- { ParameterKey: 'Project', ParameterValue: projectName },
20
- ],
21
- Tags: [
22
- ...(params.Tags || []),
23
- { Key: 'Branch', Value: branchName },
24
- ...(environment ? [{ Key: 'Environment', Value: environment }] : []),
25
- { Key: 'Package', Value: packageName },
26
- { Key: 'Project', Value: projectName },
27
- { Key: 'Version', Value: packageVersion },
28
- ].filter(({ Value }) => !!Value),
29
- };
30
- };
31
- const addDefaultParametersToTemplate = async (template) => {
32
- const [environment, projectName] = await Promise.all([
33
- (0, utils_1.getEnvironment)(),
34
- (0, utils_1.getProjectName)(),
35
- ]);
36
- const newParameters = {
37
- Project: { Default: projectName, Type: 'String' },
38
- };
39
- if (environment) {
40
- newParameters.Environment = { Default: environment, Type: 'String' };
41
- }
42
- const newTemplate = {
43
- ...template,
44
- Parameters: { ...newParameters, ...template.Parameters },
45
- };
46
- return newTemplate;
47
- };
48
- const addLogGroupToResources = (template) => {
49
- const { Resources } = template;
50
- const resourcesEntries = Object.entries(Resources);
51
- resourcesEntries.forEach(([key, resource]) => {
52
- if (['AWS::Lambda::Function', 'AWS::Serverless::Function'].includes(resource.Type)) {
53
- /**
54
- * Check if exist a resource on template whose LogGroupName
55
- * Properties includes the Lambda logical id.
56
- */
57
- const logGroup = resourcesEntries.find(([, resource2]) => {
58
- var _a, _b;
59
- const logGroupNameStr = JSON.stringify(((_b = (_a = resource2.Properties) === null || _a === void 0 ? void 0 : _a.LogGroupName) === null || _b === void 0 ? void 0 : _b['Fn::Join']) || '');
60
- return logGroupNameStr.includes(key);
61
- });
62
- if (!logGroup) {
63
- Resources[`${key}LogsLogGroup`] = {
64
- Type: 'AWS::Logs::LogGroup',
65
- DeletionPolicy: 'Delete',
66
- Properties: {
67
- LogGroupName: { 'Fn::Join': ['/', ['/aws/lambda', { Ref: key }]] },
68
- },
69
- };
70
- }
71
- }
72
- });
73
- return template;
74
- };
75
- const addEnvironmentsToLambdaResources = async (template) => {
76
- const environment = (0, utils_1.getEnvironment)();
77
- const { Resources } = template;
78
- const resourcesEntries = Object.entries(Resources);
79
- resourcesEntries.forEach(([, resource]) => {
80
- if (resource.Type === 'AWS::Lambda::Function') {
81
- const { Properties } = resource;
82
- /**
83
- * Lambda@Edege does not support environment variables.
84
- * https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-requirements-limits.html#lambda-requirements-lambda-function-configuration
85
- * Then every function that has "Lambda@Edge" in its description will not
86
- * have the variables passed to Environment.Variables.
87
- */
88
- if ((Properties.Description || '').includes('Lambda@Edge')) {
89
- return;
90
- }
91
- if (!environment) {
92
- return;
93
- }
94
- if (!Properties.Environment) {
95
- Properties.Environment = {};
96
- }
97
- if (!Properties.Environment.Variables) {
98
- Properties.Environment.Variables = {};
99
- }
100
- Properties.Environment.Variables.ENVIRONMENT = environment;
101
- }
102
- });
103
- return template;
104
- };
105
- const addAppSyncApiOutputs = async (template) => {
106
- const newTemplate = { ...template };
107
- Object.entries(template.Resources).forEach(([key, resource]) => {
108
- if (resource.Type === 'AWS::AppSync::GraphQLApi') {
109
- newTemplate.Outputs = {
110
- [key]: {
111
- Description: `Automatically added by ${config_1.NAME}`,
112
- Value: { 'Fn::GetAtt': [key, 'GraphQLUrl'] },
113
- Export: {
114
- Name: {
115
- 'Fn::Join': [':', [{ Ref: 'AWS::StackName' }, 'GraphQLApiUrl']],
116
- },
117
- },
118
- },
119
- ...newTemplate.Outputs,
120
- };
121
- }
122
- });
123
- return newTemplate;
124
- };
125
- const addDefaults = async ({ params, template, }) => {
126
- const newTemplate = await [
127
- addDefaultParametersToTemplate,
128
- addLogGroupToResources,
129
- addEnvironmentsToLambdaResources,
130
- addAppSyncApiOutputs,
131
- ].reduce(async (acc, addFn) => addFn(await acc), Promise.resolve(template));
132
- const response = {
133
- params: await addDefaultsParametersAndTagsToParams(params),
134
- template: newTemplate,
135
- };
136
- return response;
137
- };
138
- exports.addDefaults = addDefaults;
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.deployBaseStackCommand = void 0;
4
- const deployBaseStack_1 = require("./deployBaseStack");
5
- exports.deployBaseStackCommand = {
6
- command: 'base-stack',
7
- describe: 'Create base resources.',
8
- handler: deployBaseStack_1.deployBaseStack,
9
- };
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BASE_STACK_VPC_PUBLIC_SUBNET_2_EXPORTED_NAME = exports.BASE_STACK_VPC_PUBLIC_SUBNET_1_EXPORTED_NAME = exports.BASE_STACK_VPC_PUBLIC_SUBNET_0_EXPORTED_NAME = exports.BASE_STACK_VPC_DEFAULT_SECURITY_GROUP_EXPORTED_NAME = exports.BASE_STACK_VPC_ID_EXPORTED_NAME = exports.BASE_STACK_LAMBDA_LAYER_BUILDER_LOGICAL_NAME = exports.BASE_STACK_LAMBDA_IMAGE_BUILDER_EXPORTED_NAME = exports.BASE_STACK_LAMBDA_IMAGE_BUILDER_LOGICAL_NAME = exports.BASE_STACK_BUCKET_NAME_EXPORTED_NAME = exports.BASE_STACK_BUCKET_LOGICAL_NAME = exports.BASE_STACK_BUCKET_TEMPLATES_FOLDER = exports.BASE_STACK_NAME = void 0;
4
- const change_case_1 = require("change-case");
5
- const config_1 = require("../../config");
6
- const pascalCaseName = (0, change_case_1.pascalCase)(config_1.NAME);
7
- exports.BASE_STACK_NAME = `${pascalCaseName}BaseStack`;
8
- exports.BASE_STACK_BUCKET_TEMPLATES_FOLDER = 'cloudformation-templates';
9
- /**
10
- * S3 Bucket.
11
- */
12
- exports.BASE_STACK_BUCKET_LOGICAL_NAME = `${pascalCaseName}Bucket`;
13
- exports.BASE_STACK_BUCKET_NAME_EXPORTED_NAME = `${pascalCaseName}BucketNameExportedName`;
14
- /**
15
- * Lambda image builder.
16
- */
17
- exports.BASE_STACK_LAMBDA_IMAGE_BUILDER_LOGICAL_NAME = `${pascalCaseName}LambdaImageBuilder`;
18
- exports.BASE_STACK_LAMBDA_IMAGE_BUILDER_EXPORTED_NAME = `${pascalCaseName}LambdaImageBuilderExportedName`;
19
- /**
20
- * Lambda layer builder.
21
- */
22
- exports.BASE_STACK_LAMBDA_LAYER_BUILDER_LOGICAL_NAME = `${pascalCaseName}LambdaLayerBuilder`;
23
- /**
24
- * VPC
25
- */
26
- exports.BASE_STACK_VPC_ID_EXPORTED_NAME = `${pascalCaseName}VPCIDExportedName`;
27
- exports.BASE_STACK_VPC_DEFAULT_SECURITY_GROUP_EXPORTED_NAME = `${pascalCaseName}DefaultSecurityGroupExportedName`;
28
- exports.BASE_STACK_VPC_PUBLIC_SUBNET_0_EXPORTED_NAME = `${pascalCaseName}VPCPublicSubnet0ExportedName`;
29
- exports.BASE_STACK_VPC_PUBLIC_SUBNET_1_EXPORTED_NAME = `${pascalCaseName}VPCPublicSubnet1ExportedName`;
30
- exports.BASE_STACK_VPC_PUBLIC_SUBNET_2_EXPORTED_NAME = `${pascalCaseName}VPCPublicSubnet2ExportedName`;
@@ -1,59 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.deployBaseStack = exports.baseStackTemplate = void 0;
4
- const tslib_1 = require("tslib");
5
- const config_1 = require("./config");
6
- const cloudFormation_core_1 = require("../cloudFormation.core");
7
- const getBucket_template_1 = require("./getBucket.template");
8
- const getLambdaImageBuilder_template_1 = require("./getLambdaImageBuilder.template");
9
- const getLambdaLayerBuilder_template_1 = require("./getLambdaLayerBuilder.template");
10
- const getVpc_template_1 = require("./getVpc.template");
11
- const utils_1 = require("../utils");
12
- const deepmerge_1 = tslib_1.__importDefault(require("deepmerge"));
13
- const logPrefix = 'base-stack';
14
- exports.baseStackTemplate = deepmerge_1.default.all([
15
- (0, getBucket_template_1.getBucketTemplate)(),
16
- (0, getLambdaImageBuilder_template_1.getLambdaImageBuilderTemplate)(),
17
- (0, getLambdaLayerBuilder_template_1.getLambdaLayerBuilderTemplate)(),
18
- (0, getVpc_template_1.getVpcTemplate)(),
19
- ]);
20
- /**
21
- * Base Stack is a set of auxiliary resources that will be used to help at the
22
- * deployment time. The resources that will be created are listed below.
23
- *
24
- * - **S3 bucket**. Deployment may need an auxiliary bucket to succeed. For
25
- * instance, to deploy resources that contain a
26
- * [Lambda](https://carlin.ttoss.dev/docs/commands/deploy#lambda), we need a S3
27
- * bucket to upload the zipped code. Or if the CloudFormation template has a
28
- * size greater than [the limit](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cloudformation-limits.html),
29
- * we need to upload the template to a S3 bucket in order to create/update the
30
- * stack.
31
- *
32
- * - **Lambda Layer builder**. This resource is a CodeBuild project that is
33
- * used to create Lambda Layers when [--lambda-externals](/docs/api-reference/deploy#lambda-externals)
34
- * has values.
35
- *
36
- * - **Lambda Image builder**. This resource is a CodeBuild project that builds
37
- * Docker Images if Lambda is going to use them.
38
- *
39
- * - **VPC**. This resource is used when some network infrastructure is
40
- * required. For example, CICD needs a VPC to execute the [Fargate](https://aws.amazon.com/fargate/)
41
- * operations.
42
- */
43
- const deployBaseStack = async () => {
44
- try {
45
- const { stackName } = await (0, utils_1.handleDeployInitialization)({
46
- logPrefix,
47
- stackName: config_1.BASE_STACK_NAME,
48
- });
49
- await (0, cloudFormation_core_1.deploy)({
50
- template: exports.baseStackTemplate,
51
- params: { StackName: stackName },
52
- terminationProtection: true,
53
- });
54
- }
55
- catch (error) {
56
- (0, utils_1.handleDeployError)({ error, logPrefix });
57
- }
58
- };
59
- exports.deployBaseStack = deployBaseStack;
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getBaseStackResource = exports.getBaseStackOutput = void 0;
4
- const cloudFormation_core_1 = require("../cloudFormation.core");
5
- const config_1 = require("./config");
6
- const getBaseStackOutput = async (outputKey) => {
7
- const output = await (0, cloudFormation_core_1.getStackOutput)({
8
- stackName: config_1.BASE_STACK_NAME,
9
- outputKey,
10
- });
11
- return output.OutputValue;
12
- };
13
- exports.getBaseStackOutput = getBaseStackOutput;
14
- const resourcesKeys = {
15
- BASE_STACK_BUCKET_LOGICAL_NAME: config_1.BASE_STACK_BUCKET_LOGICAL_NAME,
16
- BASE_STACK_LAMBDA_IMAGE_BUILDER_LOGICAL_NAME: config_1.BASE_STACK_LAMBDA_IMAGE_BUILDER_LOGICAL_NAME,
17
- BASE_STACK_LAMBDA_LAYER_BUILDER_LOGICAL_NAME: config_1.BASE_STACK_LAMBDA_LAYER_BUILDER_LOGICAL_NAME,
18
- };
19
- const resources = {};
20
- const getBaseStackResource = async (resource) => {
21
- if (!resources[resource]) {
22
- resources[resource] = await (0, exports.getBaseStackOutput)(resourcesKeys[resource]);
23
- }
24
- return resources[resource];
25
- };
26
- exports.getBaseStackResource = getBaseStackResource;
@@ -1,44 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getBucketTemplate = void 0;
4
- const config_1 = require("./config");
5
- const getBucketTemplate = () => ({
6
- AWSTemplateFormatVersion: '2010-09-09',
7
- Resources: {
8
- [config_1.BASE_STACK_BUCKET_LOGICAL_NAME]: {
9
- Type: 'AWS::S3::Bucket',
10
- DeletionPolicy: 'Retain',
11
- Properties: {
12
- LifecycleConfiguration: {
13
- Rules: [
14
- {
15
- ExpirationInDays: 1,
16
- Prefix: config_1.BASE_STACK_BUCKET_TEMPLATES_FOLDER,
17
- Status: 'Enabled',
18
- },
19
- {
20
- NoncurrentVersionExpirationInDays: 3,
21
- Status: 'Enabled',
22
- },
23
- ],
24
- },
25
- /**
26
- * This is necessary because if we update Lambda code without change
27
- * CloudFormation template, the Lambda will not be updated.
28
- */
29
- VersioningConfiguration: {
30
- Status: 'Enabled',
31
- },
32
- },
33
- },
34
- },
35
- Outputs: {
36
- [config_1.BASE_STACK_BUCKET_LOGICAL_NAME]: {
37
- Value: { Ref: config_1.BASE_STACK_BUCKET_LOGICAL_NAME },
38
- Export: {
39
- Name: config_1.BASE_STACK_BUCKET_NAME_EXPORTED_NAME,
40
- },
41
- },
42
- },
43
- });
44
- exports.getBucketTemplate = getBucketTemplate;