@adobe/helix-deploy 10.3.3 → 10.4.0
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/CHANGELOG.md +7 -0
- package/README.md +2 -1
- package/package.json +1 -1
- package/src/deploy/AWSConfig.js +18 -3
- package/src/deploy/AWSDeployer.js +43 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [10.4.0](https://github.com/adobe/helix-deploy/compare/v10.3.3...v10.4.0) (2024-01-29)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* add support for custom AWS tags which are set on the deployed Lambda. Fixes [#651](https://github.com/adobe/helix-deploy/issues/651) ([#652](https://github.com/adobe/helix-deploy/issues/652)) ([09e2055](https://github.com/adobe/helix-deploy/commit/09e2055928b7f67c70b64034c810a0ff48b5ce59))
|
|
7
|
+
|
|
1
8
|
## [10.3.3](https://github.com/adobe/helix-deploy/compare/v10.3.2...v10.3.3) (2024-01-29)
|
|
2
9
|
|
|
3
10
|
|
package/README.md
CHANGED
|
@@ -132,7 +132,8 @@ AWS Deployment Options
|
|
|
132
132
|
--aws-log-format The lambda log format. Can be either "JSON" or "Text". [string]
|
|
133
133
|
--aws-layers List of layers ARNs to attach to the lambda function. [array]
|
|
134
134
|
--aws-tracing-mode The lambda tracing mode. Can be either "Active" or "PassThrough". [string]
|
|
135
|
-
--aws-extra-permissions A list
|
|
135
|
+
--aws-extra-permissions A list of additional invoke permissions to add to the lambda function in the form <SourceARN>@<Principal>. [array]
|
|
136
|
+
--aws-tags A list of additional tags to attach to the lambda function in the form key=value. To remove a tag, use key= (i.e. without a value).[array]
|
|
136
137
|
|
|
137
138
|
Google Deployment Options
|
|
138
139
|
--google-project-id the Google Cloud project to deploy to. Optional when the key file is a JSON file [string] [default: ""]
|
package/package.json
CHANGED
package/src/deploy/AWSConfig.js
CHANGED
|
@@ -34,6 +34,7 @@ export default class AWSConfig {
|
|
|
34
34
|
layers: undefined,
|
|
35
35
|
tracingMode: undefined,
|
|
36
36
|
extraPermissions: undefined,
|
|
37
|
+
tags: undefined,
|
|
37
38
|
});
|
|
38
39
|
}
|
|
39
40
|
|
|
@@ -56,7 +57,8 @@ export default class AWSConfig {
|
|
|
56
57
|
.withAWSLogFormat(argv.awsLogFormat)
|
|
57
58
|
.withAWSLayers(argv.awsLayers)
|
|
58
59
|
.withAWSTracingMode(argv.awsTracingMode)
|
|
59
|
-
.withAWSExtraPermissions(argv.awsExtraPermissions)
|
|
60
|
+
.withAWSExtraPermissions(argv.awsExtraPermissions)
|
|
61
|
+
.withAWSTags(argv.awsTags);
|
|
60
62
|
}
|
|
61
63
|
|
|
62
64
|
withAWSRegion(value) {
|
|
@@ -152,13 +154,21 @@ export default class AWSConfig {
|
|
|
152
154
|
return this;
|
|
153
155
|
}
|
|
154
156
|
|
|
157
|
+
withAWSTags(value) {
|
|
158
|
+
if (value && !Array.isArray(value)) {
|
|
159
|
+
throw new Error('awsTags must be an array');
|
|
160
|
+
}
|
|
161
|
+
this.tags = value;
|
|
162
|
+
return this;
|
|
163
|
+
}
|
|
164
|
+
|
|
155
165
|
static yarg(yargs) {
|
|
156
166
|
return yargs
|
|
157
167
|
.group(['aws-region', 'aws-api', 'aws-role', 'aws-cleanup-buckets', 'aws-cleanup-integrations',
|
|
158
168
|
'aws-cleanup-versions', 'aws-create-routes', 'aws-create-authorizer', 'aws-attach-authorizer',
|
|
159
169
|
'aws-lambda-format', 'aws-parameter-manager', 'aws-deploy-template', 'aws-arch', 'aws-update-secrets',
|
|
160
170
|
'aws-deploy-bucket', 'aws-identity-source', 'aws-log-format', 'aws-layers',
|
|
161
|
-
'aws-tracing-mode', 'aws-extra-permissions'], 'AWS Deployment Options')
|
|
171
|
+
'aws-tracing-mode', 'aws-extra-permissions', 'aws-tags'], 'AWS Deployment Options')
|
|
162
172
|
.option('aws-region', {
|
|
163
173
|
description: 'the AWS region to deploy lambda functions to',
|
|
164
174
|
type: 'string',
|
|
@@ -245,9 +255,14 @@ export default class AWSConfig {
|
|
|
245
255
|
type: 'string',
|
|
246
256
|
})
|
|
247
257
|
.option('aws-extra-permissions', {
|
|
248
|
-
description: 'A list
|
|
258
|
+
description: 'A list of additional invoke permissions to add to the lambda function in the form <SourceARN>@<Principal>.',
|
|
249
259
|
type: 'string',
|
|
250
260
|
array: true,
|
|
261
|
+
})
|
|
262
|
+
.option('aws-tags', {
|
|
263
|
+
description: 'A list of additional tags to attach to the lambda function in the form key=value. To remove a tag, use key= (i.e. without a value).',
|
|
264
|
+
type: 'array',
|
|
265
|
+
array: true,
|
|
251
266
|
});
|
|
252
267
|
}
|
|
253
268
|
}
|
|
@@ -29,9 +29,9 @@ import {
|
|
|
29
29
|
CreateAliasCommand,
|
|
30
30
|
CreateFunctionCommand, DeleteAliasCommand, DeleteFunctionCommand, GetAliasCommand,
|
|
31
31
|
GetFunctionCommand,
|
|
32
|
-
LambdaClient, ListAliasesCommand, ListVersionsByFunctionCommand,
|
|
33
|
-
PublishVersionCommand,
|
|
34
|
-
UpdateFunctionConfigurationCommand,
|
|
32
|
+
LambdaClient, ListAliasesCommand, ListTagsCommand, ListVersionsByFunctionCommand,
|
|
33
|
+
PublishVersionCommand, TagResourceCommand, UntagResourceCommand, UpdateAliasCommand,
|
|
34
|
+
UpdateFunctionCodeCommand, UpdateFunctionConfigurationCommand,
|
|
35
35
|
} from '@aws-sdk/client-lambda';
|
|
36
36
|
|
|
37
37
|
import {
|
|
@@ -126,6 +126,16 @@ export default class AWSDeployer extends BaseDeployer {
|
|
|
126
126
|
}`;
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
+
get additionalTags() {
|
|
130
|
+
return (this._cfg.tags || []).map((tag) => tag.split('=')).reduce((acc, tagSplit) => {
|
|
131
|
+
if (tagSplit.length >= 2) {
|
|
132
|
+
const [key, ...value] = tagSplit;
|
|
133
|
+
acc[key] = value.join('=');
|
|
134
|
+
}
|
|
135
|
+
return acc;
|
|
136
|
+
}, {});
|
|
137
|
+
}
|
|
138
|
+
|
|
129
139
|
validate() {
|
|
130
140
|
const req = [];
|
|
131
141
|
if (!this._cfg.role) {
|
|
@@ -206,7 +216,7 @@ export default class AWSDeployer extends BaseDeployer {
|
|
|
206
216
|
}
|
|
207
217
|
|
|
208
218
|
async createLambda() {
|
|
209
|
-
const { cfg, functionName } = this;
|
|
219
|
+
const { cfg, functionName, additionalTags } = this;
|
|
210
220
|
const functionVersion = cfg.version.replace(/\./g, '_');
|
|
211
221
|
|
|
212
222
|
const functionConfig = {
|
|
@@ -243,6 +253,13 @@ export default class AWSDeployer extends BaseDeployer {
|
|
|
243
253
|
TracingConfig: this._cfg.tracingMode ? { Mode: this._cfg.tracingMode } : undefined,
|
|
244
254
|
};
|
|
245
255
|
|
|
256
|
+
// add additional tags which are not empty
|
|
257
|
+
Object.entries(additionalTags).forEach(([key, value]) => {
|
|
258
|
+
if (value !== '') {
|
|
259
|
+
functionConfig.Tags[key] = value;
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
|
|
246
263
|
this.log.info(`--: using lambda role "${this._cfg.role}"`);
|
|
247
264
|
|
|
248
265
|
// check if function already exists
|
|
@@ -272,6 +289,28 @@ export default class AWSDeployer extends BaseDeployer {
|
|
|
272
289
|
this.log.info(chalk`--: updating existing Lambda function configuration {yellow ${functionName}}`);
|
|
273
290
|
await this._lambda.send(new UpdateFunctionConfigurationCommand(functionConfig));
|
|
274
291
|
await this.checkFunctionReady(baseARN);
|
|
292
|
+
this.log.info(chalk`--: updating existing Lambda function tags {yellow ${functionName}}`);
|
|
293
|
+
// set all the tags in the current configuration
|
|
294
|
+
await this._lambda.send(new TagResourceCommand({
|
|
295
|
+
Resource: baseARN,
|
|
296
|
+
Tags: functionConfig.Tags,
|
|
297
|
+
}));
|
|
298
|
+
// then remove any tags with a blank value in the configuration (and are currently set),
|
|
299
|
+
// leaving other tags alone
|
|
300
|
+
const tagsToPotentiallyRemove = Object.entries(additionalTags).filter(([_, value]) => value === '').map(([key]) => key);
|
|
301
|
+
if (tagsToPotentiallyRemove.length) {
|
|
302
|
+
const { Tags: currentTags } = await this._lambda.send(new ListTagsCommand({
|
|
303
|
+
Resource: baseARN,
|
|
304
|
+
}));
|
|
305
|
+
const tagsToRemove = tagsToPotentiallyRemove.filter((key) => currentTags[key]);
|
|
306
|
+
if (tagsToRemove.length) {
|
|
307
|
+
await this._lambda.send(new UntagResourceCommand({
|
|
308
|
+
Resource: baseARN,
|
|
309
|
+
TagKeys: tagsToRemove,
|
|
310
|
+
}));
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
await this.checkFunctionReady(baseARN);
|
|
275
314
|
this.log.info('--: updating Lambda function code...');
|
|
276
315
|
await this._lambda.send(new UpdateFunctionCodeCommand({
|
|
277
316
|
FunctionName: functionName,
|