@datadog/datadog-ci 0.17.8 → 0.17.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 (35) hide show
  1. package/dist/commands/lambda/__tests__/fixtures.d.ts +42 -0
  2. package/dist/commands/lambda/__tests__/fixtures.js +73 -0
  3. package/dist/commands/lambda/__tests__/{function.test.d.ts → functions/commons.test.d.ts} +0 -0
  4. package/dist/commands/lambda/__tests__/functions/commons.test.js +171 -0
  5. package/dist/commands/lambda/__tests__/functions/instrument.test.d.ts +1 -0
  6. package/dist/commands/lambda/__tests__/{function.test.js → functions/instrument.test.js} +355 -417
  7. package/dist/commands/lambda/__tests__/functions/uninstrument.test.d.ts +1 -0
  8. package/dist/commands/lambda/__tests__/functions/uninstrument.test.js +298 -0
  9. package/dist/commands/lambda/__tests__/instrument.test.js +270 -163
  10. package/dist/commands/lambda/__tests__/loggroup.test.js +98 -34
  11. package/dist/commands/lambda/__tests__/tags.test.js +107 -31
  12. package/dist/commands/lambda/__tests__/uninstrument.test.d.ts +1 -0
  13. package/dist/commands/lambda/__tests__/uninstrument.test.js +223 -0
  14. package/dist/commands/lambda/constants.d.ts +1 -0
  15. package/dist/commands/lambda/constants.js +2 -1
  16. package/dist/commands/lambda/functions/commons.d.ts +71 -0
  17. package/dist/commands/lambda/functions/commons.js +170 -0
  18. package/dist/commands/lambda/functions/instrument.d.ts +16 -0
  19. package/dist/commands/lambda/{function.js → functions/instrument.js} +42 -102
  20. package/dist/commands/lambda/functions/uninstrument.d.ts +6 -0
  21. package/dist/commands/lambda/functions/uninstrument.js +110 -0
  22. package/dist/commands/lambda/index.js +2 -1
  23. package/dist/commands/lambda/instrument.d.ts +4 -3
  24. package/dist/commands/lambda/instrument.js +85 -40
  25. package/dist/commands/lambda/interfaces.d.ts +54 -0
  26. package/dist/commands/lambda/loggroup.d.ts +4 -7
  27. package/dist/commands/lambda/loggroup.js +27 -4
  28. package/dist/commands/lambda/tags.d.ts +3 -4
  29. package/dist/commands/lambda/tags.js +19 -3
  30. package/dist/commands/lambda/uninstrument.d.ts +11 -0
  31. package/dist/commands/lambda/uninstrument.js +127 -0
  32. package/dist/helpers/__tests__/ci.test.js +23 -0
  33. package/dist/helpers/ci.js +13 -6
  34. package/package.json +1 -1
  35. package/dist/commands/lambda/function.d.ts +0 -43
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.getSubscriptionFilterState = exports.hasLogGroup = exports.calculateLogGroupUpdateRequest = exports.applyLogGroupConfig = exports.SubscriptionState = void 0;
12
+ exports.getSubscriptionFilters = exports.getSubscriptionFilterState = exports.hasLogGroup = exports.calculateLogGroupRemoveRequest = exports.calculateLogGroupUpdateRequest = exports.applyLogGroupConfig = exports.SubscriptionState = void 0;
13
13
  const constants_1 = require("./constants");
14
14
  var SubscriptionState;
15
15
  (function (SubscriptionState) {
@@ -18,8 +18,8 @@ var SubscriptionState;
18
18
  SubscriptionState[SubscriptionState["WrongDestinationOwned"] = 2] = "WrongDestinationOwned";
19
19
  SubscriptionState[SubscriptionState["WrongDestinationUnowned"] = 3] = "WrongDestinationUnowned";
20
20
  })(SubscriptionState = exports.SubscriptionState || (exports.SubscriptionState = {}));
21
- const applyLogGroupConfig = (logs, configuration) => __awaiter(void 0, void 0, void 0, function* () {
22
- const { createLogGroupRequest, deleteSubscriptionFilterRequest, subscriptionFilterRequest } = configuration;
21
+ const applyLogGroupConfig = (logs, config) => __awaiter(void 0, void 0, void 0, function* () {
22
+ const { createLogGroupRequest, deleteSubscriptionFilterRequest, subscriptionFilterRequest } = config;
23
23
  if (createLogGroupRequest !== undefined) {
24
24
  yield logs.createLogGroup(createLogGroupRequest).promise();
25
25
  }
@@ -60,6 +60,21 @@ const calculateLogGroupUpdateRequest = (logs, logGroupName, forwarderARN) => __a
60
60
  return config;
61
61
  });
62
62
  exports.calculateLogGroupUpdateRequest = calculateLogGroupUpdateRequest;
63
+ const calculateLogGroupRemoveRequest = (logs, logGroupName, forwarderARN) => __awaiter(void 0, void 0, void 0, function* () {
64
+ const config = {
65
+ logGroupName,
66
+ };
67
+ const subscriptionFilters = yield exports.getSubscriptionFilters(logs, logGroupName);
68
+ const subscriptionToRemove = subscriptionFilters === null || subscriptionFilters === void 0 ? void 0 : subscriptionFilters.find((subscription) => subscription.destinationArn === forwarderARN || subscription.filterName === constants_1.SUBSCRIPTION_FILTER_NAME);
69
+ if (subscriptionToRemove) {
70
+ config.deleteSubscriptionFilterRequest = {
71
+ filterName: subscriptionToRemove.filterName,
72
+ logGroupName,
73
+ };
74
+ }
75
+ return config;
76
+ });
77
+ exports.calculateLogGroupRemoveRequest = calculateLogGroupRemoveRequest;
63
78
  const hasLogGroup = (logs, logGroupName) => __awaiter(void 0, void 0, void 0, function* () {
64
79
  const args = {
65
80
  logGroupNamePrefix: logGroupName,
@@ -73,7 +88,7 @@ const hasLogGroup = (logs, logGroupName) => __awaiter(void 0, void 0, void 0, fu
73
88
  });
74
89
  exports.hasLogGroup = hasLogGroup;
75
90
  const getSubscriptionFilterState = (logs, logGroupName, forwarderARN) => __awaiter(void 0, void 0, void 0, function* () {
76
- const { subscriptionFilters } = yield logs.describeSubscriptionFilters({ logGroupName }).promise();
91
+ const subscriptionFilters = yield exports.getSubscriptionFilters(logs, logGroupName);
77
92
  if (subscriptionFilters === undefined || subscriptionFilters.length === 0) {
78
93
  return SubscriptionState.Empty;
79
94
  }
@@ -87,3 +102,11 @@ const getSubscriptionFilterState = (logs, logGroupName, forwarderARN) => __await
87
102
  return SubscriptionState.WrongDestinationUnowned;
88
103
  });
89
104
  exports.getSubscriptionFilterState = getSubscriptionFilterState;
105
+ const getSubscriptionFilters = (logs, logGroupName) => __awaiter(void 0, void 0, void 0, function* () {
106
+ const subscriptionFiltersRequest = {
107
+ logGroupName,
108
+ };
109
+ const { subscriptionFilters } = yield logs.describeSubscriptionFilters(subscriptionFiltersRequest).promise();
110
+ return subscriptionFilters;
111
+ });
112
+ exports.getSubscriptionFilters = getSubscriptionFilters;
@@ -1,7 +1,6 @@
1
1
  import { Lambda } from 'aws-sdk';
2
- export interface TagConfiguration {
3
- tagResourceRequest?: Lambda.TagResourceRequest;
4
- }
5
- export declare const applyTagConfig: (lambda: Lambda, configuration: TagConfiguration) => Promise<void>;
2
+ import { TagConfiguration } from './interfaces';
3
+ export declare const applyTagConfig: (lambda: Lambda, config: TagConfiguration) => Promise<void>;
6
4
  export declare const calculateTagUpdateRequest: (lambda: Lambda, functionARN: string) => Promise<TagConfiguration | undefined>;
5
+ export declare const calculateTagRemoveRequest: (lambda: Lambda, functionARN: string) => Promise<TagConfiguration | undefined>;
7
6
  export declare const hasVersionTag: (lambda: Lambda, functionARN: string) => Promise<boolean>;
@@ -12,16 +12,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.hasVersionTag = exports.calculateTagUpdateRequest = exports.applyTagConfig = void 0;
15
+ exports.hasVersionTag = exports.calculateTagRemoveRequest = exports.calculateTagUpdateRequest = exports.applyTagConfig = void 0;
16
16
  const path_1 = __importDefault(require("path"));
17
17
  const constants_1 = require("./constants");
18
18
  // tslint:disable-next-line
19
19
  const { version } = require(path_1.default.join(__dirname, '../../../package.json'));
20
- const applyTagConfig = (lambda, configuration) => __awaiter(void 0, void 0, void 0, function* () {
21
- const { tagResourceRequest } = configuration;
20
+ const applyTagConfig = (lambda, config) => __awaiter(void 0, void 0, void 0, function* () {
21
+ const { tagResourceRequest, untagResourceRequest } = config;
22
22
  if (tagResourceRequest !== undefined) {
23
23
  yield lambda.tagResource(tagResourceRequest).promise();
24
24
  }
25
+ if (untagResourceRequest !== undefined) {
26
+ yield lambda.untagResource(untagResourceRequest).promise();
27
+ }
25
28
  });
26
29
  exports.applyTagConfig = applyTagConfig;
27
30
  const calculateTagUpdateRequest = (lambda, functionARN) => __awaiter(void 0, void 0, void 0, function* () {
@@ -39,6 +42,19 @@ const calculateTagUpdateRequest = (lambda, functionARN) => __awaiter(void 0, voi
39
42
  return;
40
43
  });
41
44
  exports.calculateTagUpdateRequest = calculateTagUpdateRequest;
45
+ const calculateTagRemoveRequest = (lambda, functionARN) => __awaiter(void 0, void 0, void 0, function* () {
46
+ const config = {};
47
+ const versionTagPresent = yield exports.hasVersionTag(lambda, functionARN);
48
+ if (versionTagPresent) {
49
+ config.untagResourceRequest = {
50
+ Resource: functionARN,
51
+ TagKeys: [constants_1.TAG_VERSION_NAME],
52
+ };
53
+ return config;
54
+ }
55
+ return;
56
+ });
57
+ exports.calculateTagRemoveRequest = calculateTagRemoveRequest;
42
58
  const hasVersionTag = (lambda, functionARN) => __awaiter(void 0, void 0, void 0, function* () {
43
59
  const args = {
44
60
  Resource: functionARN,
@@ -0,0 +1,11 @@
1
+ import { Command } from 'clipanion';
2
+ export declare class UninstrumentCommand extends Command {
3
+ private config;
4
+ private configPath?;
5
+ private dryRun;
6
+ private forwarder?;
7
+ private functions;
8
+ private region?;
9
+ execute(): Promise<1 | 0>;
10
+ private printPlannedActions;
11
+ }
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.UninstrumentCommand = void 0;
13
+ const aws_sdk_1 = require("aws-sdk");
14
+ const chalk_1 = require("chalk");
15
+ const clipanion_1 = require("clipanion");
16
+ const utils_1 = require("../../helpers/utils");
17
+ const commons_1 = require("./functions/commons");
18
+ const uninstrument_1 = require("./functions/uninstrument");
19
+ class UninstrumentCommand extends clipanion_1.Command {
20
+ constructor() {
21
+ super(...arguments);
22
+ this.config = {
23
+ functions: [],
24
+ region: process.env.AWS_DEFAULT_REGION,
25
+ };
26
+ this.dryRun = false;
27
+ this.functions = [];
28
+ }
29
+ execute() {
30
+ return __awaiter(this, void 0, void 0, function* () {
31
+ const lambdaConfig = { lambda: this.config };
32
+ this.config = (yield utils_1.parseConfigFile(lambdaConfig, this.configPath)).lambda;
33
+ const hasSpecifiedFuntions = this.functions.length !== 0 || this.config.functions.length !== 0;
34
+ if (!hasSpecifiedFuntions) {
35
+ this.context.stdout.write('No functions specified for un-instrumentation.\n');
36
+ return 1;
37
+ }
38
+ const functionGroups = commons_1.collectFunctionsByRegion(this.functions.length !== 0 ? this.functions : this.config.functions, this.region || this.config.region);
39
+ if (functionGroups === undefined) {
40
+ return 1;
41
+ }
42
+ const configGroups = [];
43
+ // Fetch lambda function configurations that are
44
+ // available to be un-instrumented.
45
+ for (const [region, functionList] of Object.entries(functionGroups)) {
46
+ const lambda = new aws_sdk_1.Lambda({ region });
47
+ const cloudWatchLogs = new aws_sdk_1.CloudWatchLogs({ region });
48
+ try {
49
+ const configs = yield uninstrument_1.getFunctionConfigs(lambda, cloudWatchLogs, functionList, this.forwarder);
50
+ configGroups.push({ configs, lambda, cloudWatchLogs });
51
+ }
52
+ catch (err) {
53
+ this.context.stdout.write(`${chalk_1.red('[Error]')} Couldn't fetch lambda functions. ${err}\n`);
54
+ return 1;
55
+ }
56
+ }
57
+ const configList = configGroups.map((group) => group.configs).reduce((a, b) => a.concat(b));
58
+ this.printPlannedActions(configList);
59
+ if (this.dryRun || configList.length === 0) {
60
+ return 0;
61
+ }
62
+ // Un-instrument functions.
63
+ const promises = Object.values(configGroups).map((group) => {
64
+ commons_1.updateLambdaFunctionConfigs(group.lambda, group.cloudWatchLogs, group.configs);
65
+ });
66
+ try {
67
+ yield Promise.all(promises);
68
+ }
69
+ catch (err) {
70
+ this.context.stdout.write(`${chalk_1.red('[Error]')} Failure during un-instrumentation. ${err}`);
71
+ return 1;
72
+ }
73
+ return 0;
74
+ });
75
+ }
76
+ printPlannedActions(configs) {
77
+ var _a;
78
+ const prefix = this.dryRun ? chalk_1.bold(chalk_1.cyan('[Dry Run] ')) : '';
79
+ let anyUpdates = false;
80
+ for (const config of configs) {
81
+ if (config.updateRequest !== undefined ||
82
+ ((_a = config.logGroupConfiguration) === null || _a === void 0 ? void 0 : _a.deleteSubscriptionFilterRequest) !== undefined ||
83
+ (config === null || config === void 0 ? void 0 : config.tagConfiguration) !== undefined) {
84
+ anyUpdates = true;
85
+ break;
86
+ }
87
+ }
88
+ if (!anyUpdates) {
89
+ this.context.stdout.write(`${prefix}No updates will be applied\n`);
90
+ return;
91
+ }
92
+ this.context.stdout.write(`${prefix}Will apply the following updates:\n`);
93
+ for (const config of configs) {
94
+ if (config.updateRequest) {
95
+ this.context.stdout.write(`UpdateFunctionConfiguration -> ${config.functionARN}\n${JSON.stringify(config.updateRequest, undefined, 2)}\n`);
96
+ }
97
+ const { logGroupConfiguration, tagConfiguration } = config;
98
+ if (tagConfiguration === null || tagConfiguration === void 0 ? void 0 : tagConfiguration.untagResourceRequest) {
99
+ this.context.stdout.write(`UntagResource -> ${tagConfiguration.untagResourceRequest.Resource}\n${JSON.stringify(tagConfiguration.untagResourceRequest.TagKeys, undefined, 2)}\n`);
100
+ }
101
+ if (logGroupConfiguration === null || logGroupConfiguration === void 0 ? void 0 : logGroupConfiguration.deleteSubscriptionFilterRequest) {
102
+ this.context.stdout.write(`DeleteSubscriptionFilter -> ${logGroupConfiguration.logGroupName}\n${JSON.stringify(logGroupConfiguration.deleteSubscriptionFilterRequest, undefined, 2)}\n`);
103
+ }
104
+ }
105
+ }
106
+ }
107
+ exports.UninstrumentCommand = UninstrumentCommand;
108
+ UninstrumentCommand.addPath('lambda', 'uninstrument');
109
+ UninstrumentCommand.addOption('functions', clipanion_1.Command.Array('-f,--function'));
110
+ UninstrumentCommand.addOption('region', clipanion_1.Command.String('-r,--region'));
111
+ UninstrumentCommand.addOption('configPath', clipanion_1.Command.String('--config'));
112
+ UninstrumentCommand.addOption('dryRun', clipanion_1.Command.Boolean('-d,--dry'));
113
+ UninstrumentCommand.addOption('forwarder', clipanion_1.Command.String('--forwarder'));
114
+ /**
115
+ * Commands that are not really in use, but to
116
+ * make uninstrumentation easier for the user.
117
+ */
118
+ UninstrumentCommand.addOption('extensionVersion', clipanion_1.Command.String('-e,--extensionVersion', { hidden: true }));
119
+ UninstrumentCommand.addOption('layerVersion', clipanion_1.Command.String('-v,--layerVersion', { hidden: true }));
120
+ UninstrumentCommand.addOption('tracing', clipanion_1.Command.String('--tracing', { hidden: true }));
121
+ UninstrumentCommand.addOption('mergeXrayTraces', clipanion_1.Command.String('--mergeXrayTraces', { hidden: true }));
122
+ UninstrumentCommand.addOption('flushMetricsToLogs', clipanion_1.Command.String('--flushMetricsToLogs', { hidden: true }));
123
+ UninstrumentCommand.addOption('logLevel', clipanion_1.Command.String('--logLevel', { hidden: true }));
124
+ UninstrumentCommand.addOption('service', clipanion_1.Command.String('--service', { hidden: true }));
125
+ UninstrumentCommand.addOption('environment', clipanion_1.Command.String('--env', { hidden: true }));
126
+ UninstrumentCommand.addOption('version', clipanion_1.Command.String('--version', { hidden: true }));
127
+ UninstrumentCommand.addOption('extraTags', clipanion_1.Command.String('--extra-tags', { hidden: true }));
@@ -75,6 +75,7 @@ describe('getCIMetadata', () => {
75
75
  GITHUB_REF: branch,
76
76
  GITHUB_REPOSITORY: 'DataDog/datadog-ci',
77
77
  GITHUB_RUN_ID: '42',
78
+ GITHUB_SERVER_URL: 'https://github.com',
78
79
  GITHUB_SHA: commit,
79
80
  };
80
81
  const expectedPipelineURL = 'https://github.com/DataDog/datadog-ci/actions/runs/42';
@@ -89,6 +90,28 @@ describe('getCIMetadata', () => {
89
90
  },
90
91
  });
91
92
  });
93
+ test('github actions with run attempt is recognized', () => {
94
+ process.env = {
95
+ GITHUB_ACTIONS: 'true',
96
+ GITHUB_REF: branch,
97
+ GITHUB_REPOSITORY: 'DataDog/datadog-ci',
98
+ GITHUB_RUN_ATTEMPT: '2',
99
+ GITHUB_RUN_ID: '42',
100
+ GITHUB_SERVER_URL: 'https://github.com',
101
+ GITHUB_SHA: commit,
102
+ };
103
+ const expectedPipelineURL = 'https://github.com/DataDog/datadog-ci/actions/runs/42/attempts/2';
104
+ expect(ci_1.getCIMetadata()).toEqual({
105
+ ci: {
106
+ pipeline: { url: expectedPipelineURL },
107
+ provider: { name: ci_1.CI_ENGINES.GITHUB },
108
+ },
109
+ git: {
110
+ branch,
111
+ commitSha: commit,
112
+ },
113
+ });
114
+ });
92
115
  test('jenkins is recognized', () => {
93
116
  process.env = {
94
117
  BUILD_URL: pipelineURL,
@@ -125,13 +125,17 @@ const getCISpanTags = () => {
125
125
  };
126
126
  }
127
127
  if (env.GITHUB_ACTIONS || env.GITHUB_ACTION) {
128
- const { GITHUB_RUN_ID, GITHUB_WORKFLOW, GITHUB_RUN_NUMBER, GITHUB_WORKSPACE, GITHUB_HEAD_REF, GITHUB_REF, GITHUB_SHA, GITHUB_REPOSITORY, } = env;
129
- const repositoryUrl = `https://github.com/${GITHUB_REPOSITORY}.git`;
130
- const pipelineURL = `https://github.com/${GITHUB_REPOSITORY}/commit/${GITHUB_SHA}/checks`;
128
+ const { GITHUB_RUN_ID, GITHUB_WORKFLOW, GITHUB_RUN_NUMBER, GITHUB_WORKSPACE, GITHUB_HEAD_REF, GITHUB_REF, GITHUB_SHA, GITHUB_REPOSITORY, GITHUB_SERVER_URL, } = env;
129
+ const repositoryUrl = `${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git`;
130
+ let pipelineURL = `${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}`;
131
+ // Some older versions of enterprise might not have this yet.
132
+ if (env.GITHUB_RUN_ATTEMPT) {
133
+ pipelineURL += `/attempts/${env.GITHUB_RUN_ATTEMPT}`;
134
+ }
131
135
  const ref = GITHUB_HEAD_REF || GITHUB_REF || '';
132
136
  const refKey = ref.includes('tags') ? tags_1.GIT_TAG : tags_1.GIT_BRANCH;
133
137
  tags = {
134
- [tags_1.CI_JOB_URL]: pipelineURL,
138
+ [tags_1.CI_JOB_URL]: `${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/commit/${GITHUB_SHA}/checks`,
135
139
  [tags_1.CI_PIPELINE_ID]: GITHUB_RUN_ID,
136
140
  [tags_1.CI_PIPELINE_NAME]: GITHUB_WORKFLOW,
137
141
  [tags_1.CI_PIPELINE_NUMBER]: GITHUB_RUN_NUMBER,
@@ -339,8 +343,11 @@ const getCIMetadata = () => {
339
343
  };
340
344
  }
341
345
  if (env.GITHUB_ACTIONS) {
342
- const { GITHUB_REF, GITHUB_SHA, GITHUB_REPOSITORY, GITHUB_RUN_ID } = env;
343
- const pipelineURL = `https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}`;
346
+ const { GITHUB_REF, GITHUB_SHA, GITHUB_REPOSITORY, GITHUB_RUN_ID, GITHUB_SERVER_URL } = env;
347
+ let pipelineURL = `${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}`;
348
+ if (env.GITHUB_RUN_ATTEMPT) {
349
+ pipelineURL += `/attempts/${env.GITHUB_RUN_ATTEMPT}`;
350
+ }
344
351
  return {
345
352
  ci: {
346
353
  pipeline: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datadog/datadog-ci",
3
- "version": "0.17.8",
3
+ "version": "0.17.9",
4
4
  "description": "Run datadog actions from the CI.",
5
5
  "main": "dist/index.js",
6
6
  "repository": "https://github.com/DataDog/datadog-ci",
@@ -1,43 +0,0 @@
1
- import { CloudWatchLogs, Lambda } from 'aws-sdk';
2
- import { Runtime } from './constants';
3
- import { LogGroupConfiguration } from './loggroup';
4
- import { TagConfiguration } from './tags';
5
- export interface FunctionConfiguration {
6
- functionARN: string;
7
- lambdaConfig: Lambda.FunctionConfiguration;
8
- lambdaLibraryLayerArn: string;
9
- logGroupConfiguration?: LogGroupConfiguration;
10
- tagConfiguration?: TagConfiguration;
11
- updateRequest?: Lambda.UpdateFunctionConfigurationRequest;
12
- }
13
- interface InstrumentationTags {
14
- environment?: string;
15
- extraTags?: string;
16
- service?: string;
17
- version?: string;
18
- }
19
- export interface InstrumentationSettings extends InstrumentationTags {
20
- extensionVersion?: number;
21
- flushMetricsToLogs: boolean;
22
- forwarderARN?: string;
23
- layerAWSAccount?: string;
24
- layerVersion?: number;
25
- logLevel?: string;
26
- mergeXrayTraces: boolean;
27
- tracingEnabled: boolean;
28
- }
29
- export declare const getLambdaConfigs: (lambda: Lambda, cloudWatch: CloudWatchLogs, region: string, functionARNs: string[], settings: InstrumentationSettings) => Promise<FunctionConfiguration[]>;
30
- export declare const getLambdaConfigsFromRegEx: (lambda: Lambda, cloudWatch: CloudWatchLogs, region: string, pattern: string, settings: InstrumentationSettings) => Promise<FunctionConfiguration[]>;
31
- export declare const updateLambdaConfigs: (lambda: Lambda, cloudWatch: CloudWatchLogs, configurations: FunctionConfiguration[]) => Promise<void>;
32
- export declare const getFunctionConfiguration: (lambda: Lambda, cloudWatch: CloudWatchLogs, config: Lambda.FunctionConfiguration, region: string, settings: InstrumentationSettings) => Promise<{
33
- functionARN: string;
34
- lambdaConfig: Lambda.FunctionConfiguration;
35
- lambdaLibraryLayerArn: string;
36
- logGroupConfiguration: LogGroupConfiguration | undefined;
37
- tagConfiguration: TagConfiguration | undefined;
38
- updateRequest: Lambda.UpdateFunctionConfigurationRequest | undefined;
39
- }>;
40
- export declare const getLayerArn: (runtime: Runtime, settings: InstrumentationSettings, region: string) => string;
41
- export declare const getExtensionArn: (settings: InstrumentationSettings, region: string) => string;
42
- export declare const calculateUpdateRequest: (config: Lambda.FunctionConfiguration, settings: InstrumentationSettings, lambdaLibraryLayerArn: string, lambdaExtensionLayerArn: string, runtime: Runtime) => Lambda.UpdateFunctionConfigurationRequest | undefined;
43
- export {};