Skip to content

Commit 778af2f

Browse files
authored
chore(all): Switch to use only eu-west-1 in tests and doc (#562)
* chore(all): use eu-west-1 as a region for testing (both unit and e2e) This is to avoid confusion as E2E now runs in both region (logger use eu-central-1 while others use eu-west-1). It will throw an error if contributors did not cdk bootstrap both region properly. In addition, the `tests/resources/contexts/hello-world.ts` file is shared among utilities so we should keep the region consistent * chore(all): replace eu-central-1 with eu-west-1 in tracer and metrics packages * chore(doc): replace eu-central-1 with eu-west-1 in doc * chore(logger): remove .only
1 parent a5801d8 commit 778af2f

File tree

14 files changed

+64
-64
lines changed

14 files changed

+64
-64
lines changed

Diff for: docs/core/logger.md

+12-12
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ This functionality will include the following keys in your structured logs:
9696
Key | Example
9797
------------------------------------------------- | ---------------------------------------------------------------------------------
9898
**cold_start**: `bool` | `false`
99-
**function_name** `string` | `shopping-cart-api-lambda-prod-eu-central-1`
99+
**function_name** `string` | `shopping-cart-api-lambda-prod-eu-west-1`
100100
**function_memory_size**: `number` | `128`
101-
**function_arn**: `string` | `arn:aws:lambda:eu-central-1:123456789012:function:shopping-cart-api-lambda-prod-eu-central-1`
101+
**function_arn**: `string` | `arn:aws:lambda:eu-west-1:123456789012:function:shopping-cart-api-lambda-prod-eu-west-1`
102102
**function_request_id**: `string` | `c6af9ac6-7b61-11e6-9a41-93e812345678`
103103

104104
=== "Manual"
@@ -165,10 +165,10 @@ In each case, the printed log will look like this:
165165
```json hl_lines="2-6"
166166
{
167167
"cold_start": true,
168-
"function_arn": "arn:aws:lambda:eu-central-1:123456789012:function:shopping-cart-api-lambda-prod-eu-central-1",
168+
"function_arn": "arn:aws:lambda:eu-west-1:123456789012:function:shopping-cart-api-lambda-prod-eu-west-1",
169169
"function_memory_size": 128,
170170
"function_request_id": "c6af9ac6-7b61-11e6-9a41-93e812345678",
171-
"function_name": "shopping-cart-api-lambda-prod-eu-central-1",
171+
"function_name": "shopping-cart-api-lambda-prod-eu-west-1",
172172
"level": "INFO",
173173
"message": "This is an INFO log with some context",
174174
"service": "serverlessAirline",
@@ -193,7 +193,7 @@ You can append additional persistent keys and values in the logs generated durin
193193
const logger = new Logger({
194194
persistentLogAttributes: {
195195
aws_account_id: '123456789012',
196-
aws_region: 'eu-central-1',
196+
aws_region: 'eu-west-1',
197197
logger: {
198198
name: '@aws-lambda-powertools/logger',
199199
version: '0.0.1',
@@ -204,7 +204,7 @@ You can append additional persistent keys and values in the logs generated durin
204204
// OR add persistent log keys to an existing Logger instance with the appendKeys method:
205205
// logger.appendKeys({
206206
// aws_account_id: '123456789012',
207-
// aws_region: 'eu-central-1',
207+
// aws_region: 'eu-west-1',
208208
// logger: {
209209
// name: '@aws-lambda-powertools/logger',
210210
// version: '0.0.1',
@@ -234,7 +234,7 @@ You can append additional persistent keys and values in the logs generated durin
234234
"timestamp": "2021-12-12T21:49:58.084Z",
235235
"xray_trace_id": "abcdef123456abcdef123456abcdef123456",
236236
"aws_account_id": "123456789012",
237-
"aws_region": "eu-central-1",
237+
"aws_region": "eu-west-1",
238238
"logger": {
239239
"name": "@aws-lambda-powertools/logger",
240240
"version": "0.0.1"
@@ -247,7 +247,7 @@ You can append additional persistent keys and values in the logs generated durin
247247
"timestamp": "2021-12-12T21:49:58.088Z",
248248
"xray_trace_id": "abcdef123456abcdef123456abcdef123456",
249249
"aws_account_id": "123456789012",
250-
"aws_region": "eu-central-1",
250+
"aws_region": "eu-west-1",
251251
"logger": {
252252
"name": "@aws-lambda-powertools/logger",
253253
"version": "0.0.1"
@@ -666,15 +666,15 @@ This is how the printed log would look:
666666
{
667667
"message": "This is an INFO log",
668668
"service": "serverlessAirline",
669-
"awsRegion": "eu-central-1",
669+
"awsRegion": "eu-west-1",
670670
"correlationIds": {
671671
"awsRequestId": "c6af9ac6-7b61-11e6-9a41-93e812345678",
672672
"xRayTraceId": "abcdef123456abcdef123456abcdef123456",
673673
"myCustomCorrelationId": "foo-bar-baz"
674674
},
675675
"lambdaFunction": {
676-
"name": "shopping-cart-api-lambda-prod-eu-central-1",
677-
"arn": "arn:aws:lambda:eu-central-1:123456789012:function:shopping-cart-api-lambda-prod-eu-central-1",
676+
"name": "shopping-cart-api-lambda-prod-eu-west-1",
677+
"arn": "arn:aws:lambda:eu-west-1:123456789012:function:shopping-cart-api-lambda-prod-eu-west-1",
678678
"memoryLimitInMB": 128,
679679
"version": "$LATEST",
680680
"coldStart": true
@@ -709,7 +709,7 @@ This is a Jest sample that provides the minimum information necessary for Logger
709709
memoryLimitInMB: '128',
710710
logGroupName: '/aws/lambda/foo-bar-function',
711711
logStreamName: '2021/03/09/[$LATEST]abcdef123456abcdef123456abcdef123456',
712-
invokedFunctionArn: 'arn:aws:lambda:eu-central-1:123456789012:function:foo-bar-function',
712+
invokedFunctionArn: 'arn:aws:lambda:eu-west-1:123456789012:function:foo-bar-function',
713713
awsRequestId: 'c6af9ac6-7b61-11e6-9a41-93e812345678',
714714
getRemainingTimeInMillis: () => 1234,
715715
done: () => console.log('Done!'),

Diff for: packages/commons/src/tests/resources/contexts/hello-world.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const helloworldContext: Context = {
77
memoryLimitInMB: '128',
88
logGroupName: '/aws/lambda/foo-bar-function-123456abcdef',
99
logStreamName: '2021/03/09/[$LATEST]abcdef123456abcdef123456abcdef123456',
10-
invokedFunctionArn: 'arn:aws:lambda:eu-central-1:123456789012:function:Example',
10+
invokedFunctionArn: 'arn:aws:lambda:eu-west-1:123456789012:function:Example',
1111
awsRequestId: 'c6af9ac6-7b61-11e6-9a41-93e8deadbeef',
1212
getRemainingTimeInMillis: () => 1234,
1313
done: () => console.log('Done!'),

Diff for: packages/logger/examples/persistent-attributes.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const lambdaHandler: Handler = async () => {
1818
// Add persistent log keys to an existing Logger instance:
1919
logger.appendKeys({
2020
aws_account_id: '123456789012',
21-
aws_region: 'eu-central-1',
21+
aws_region: 'eu-west-1',
2222
logger: {
2323
name: powertool.name,
2424
version: powertool.version,

Diff for: packages/logger/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"test:e2e:nodejs12x": "RUNTIME=nodejs12x jest --group=e2e/logger",
1717
"test:e2e:nodejs14x": "RUNTIME=nodejs14x jest --group=e2e/logger",
1818
"test:e2e": "concurrently \"npm:test:e2e:nodejs12x\" \"npm:test:e2e:nodejs14x\"",
19-
"watch": "jest --watch",
19+
"watch": "jest --watch --group=unit",
2020
"build": "tsc",
2121
"lint": "eslint --ext .ts --fix --no-error-on-unmatched-pattern src tests",
2222
"format": "eslint --fix --ext .ts --fix --no-error-on-unmatched-pattern src tests",

Diff for: packages/logger/tests/helpers/InvocationLogs.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ export class InvocationLogs {
2525
* In each log, each content is separated by '\t'
2626
* [
2727
* 'START RequestId: c6af9ac6-7b61-11e6-9a41-93e812345678 Version: $LATEST',
28-
* '2022-01-27T16:04:39.323Z\tc6af9ac6-7b61-11e6-9a41-93e812345678\tINFO\t{"cold_start":true,"function_arn":"arn:aws:lambda:eu-central-1:561912387782:function:loggerMiddyStandardFeatures-c555a2ec-1121-4586-9c04-185ab36ea34c","function_memory_size":128,"function_name":"loggerMiddyStandardFeatures-c555a2ec-1121-4586-9c04-185ab36ea34c","function_request_id":"7f586697-238a-4c3b-9250-a5f057c1119c","level":"INFO","message":"This is an INFO log with some context and persistent key","service":"logger-e2e-testing","timestamp":"2022-01-27T16:04:39.323Z","persistentKey":"works"}',
29-
* '2022-01-27T16:04:39.323Z\tc6af9ac6-7b61-11e6-9a41-93e812345678\tINFO\t{"cold_start":true,"function_arn":"arn:aws:lambda:eu-central-1:561912387782:function:loggerMiddyStandardFeatures-c555a2ec-1121-4586-9c04-185ab36ea34c","function_memory_size":128,"function_name":"loggerMiddyStandardFeatures-c555a2ec-1121-4586-9c04-185ab36ea34c","function_request_id":"7f586697-238a-4c3b-9250-a5f057c1119c","level":"INFO","message":"This is an INFO log with some context","service":"logger-e2e-testing","timestamp":"2022-01-27T16:04:39.323Z","persistentKey":"works","additionalKey":"additionalValue"}',
30-
* '2022-01-27T16:04:39.323Z\tc6af9ac6-7b61-11e6-9a41-93e812345678\tERROR\t{"cold_start":true,"function_arn":"arn:aws:lambda:eu-central-1:561912387782:function:loggerMiddyStandardFeatures-c555a2ec-1121-4586-9c04-185ab36ea34c","function_memory_size":128,"function_name":"loggerMiddyStandardFeatures-c555a2ec-1121-4586-9c04-185ab36ea34c","function_request_id":"7f586697-238a-4c3b-9250-a5f057c1119c","level":"ERROR","message":"There was an error","service":"logger-e2e-testing","timestamp":"2022-01-27T16:04:39.323Z","persistentKey":"works","error":{"name":"Error","location":"/var/task/index.js:2778","message":"you cannot prevent this","stack":"Error: you cannot prevent this\\n at testFunction (/var/task/index.js:2778:11)\\n at runRequest (/var/task/index.js:2314:36)"}}',
28+
* '2022-01-27T16:04:39.323Z\tc6af9ac6-7b61-11e6-9a41-93e812345678\tINFO\t{"cold_start":true,"function_arn":"arn:aws:lambda:eu-west-1:561912387782:function:loggerMiddyStandardFeatures-c555a2ec-1121-4586-9c04-185ab36ea34c","function_memory_size":128,"function_name":"loggerMiddyStandardFeatures-c555a2ec-1121-4586-9c04-185ab36ea34c","function_request_id":"7f586697-238a-4c3b-9250-a5f057c1119c","level":"INFO","message":"This is an INFO log with some context and persistent key","service":"logger-e2e-testing","timestamp":"2022-01-27T16:04:39.323Z","persistentKey":"works"}',
29+
* '2022-01-27T16:04:39.323Z\tc6af9ac6-7b61-11e6-9a41-93e812345678\tINFO\t{"cold_start":true,"function_arn":"arn:aws:lambda:eu-west-1:561912387782:function:loggerMiddyStandardFeatures-c555a2ec-1121-4586-9c04-185ab36ea34c","function_memory_size":128,"function_name":"loggerMiddyStandardFeatures-c555a2ec-1121-4586-9c04-185ab36ea34c","function_request_id":"7f586697-238a-4c3b-9250-a5f057c1119c","level":"INFO","message":"This is an INFO log with some context","service":"logger-e2e-testing","timestamp":"2022-01-27T16:04:39.323Z","persistentKey":"works","additionalKey":"additionalValue"}',
30+
* '2022-01-27T16:04:39.323Z\tc6af9ac6-7b61-11e6-9a41-93e812345678\tERROR\t{"cold_start":true,"function_arn":"arn:aws:lambda:eu-west-1:561912387782:function:loggerMiddyStandardFeatures-c555a2ec-1121-4586-9c04-185ab36ea34c","function_memory_size":128,"function_name":"loggerMiddyStandardFeatures-c555a2ec-1121-4586-9c04-185ab36ea34c","function_request_id":"7f586697-238a-4c3b-9250-a5f057c1119c","level":"ERROR","message":"There was an error","service":"logger-e2e-testing","timestamp":"2022-01-27T16:04:39.323Z","persistentKey":"works","error":{"name":"Error","location":"/var/task/index.js:2778","message":"you cannot prevent this","stack":"Error: you cannot prevent this\\n at testFunction (/var/task/index.js:2778:11)\\n at runRequest (/var/task/index.js:2314:36)"}}',
3131
* 'END RequestId: c6af9ac6-7b61-11e6-9a41-93e812345678',
3232
* 'REPORT RequestId: c6af9ac6-7b61-11e6-9a41-93e812345678\tDuration: 2.16 ms\tBilled Duration: 3 ms\tMemory Size: 128 MB\tMax Memory Used: 57 MB\t',
3333
* ]

Diff for: packages/logger/tests/helpers/populateEnvironmentVariables.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
process.env._X_AMZN_TRACE_ID = 'abcdef123456abcdef123456abcdef123456';
33
process.env.AWS_LAMBDA_FUNCTION_NAME = 'my-lambda-function';
44
process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE = '128';
5-
process.env.AWS_REGION = 'eu-central-1';
5+
process.env.AWS_REGION = 'eu-west-1';
66

77
// Powertools variables
88
process.env.LOG_LEVEL = 'DEBUG';

Diff for: packages/logger/tests/unit/Logger.test.ts

+15-15
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ describe('Class: Logger', () => {
255255
expect(console[methodOfLogger]).toBeCalledTimes(1);
256256
expect(console[methodOfLogger]).toHaveBeenNthCalledWith(1, JSON.stringify({
257257
cold_start: true,
258-
function_arn: 'arn:aws:lambda:eu-central-1:123456789012:function:foo-bar-function',
258+
function_arn: 'arn:aws:lambda:eu-west-1:123456789012:function:foo-bar-function',
259259
function_memory_size: 128,
260260
function_name: 'foo-bar-function',
261261
function_request_id: 'c6af9ac6-7b61-11e6-9a41-93e812345678',
@@ -368,7 +368,7 @@ describe('Class: Logger', () => {
368368
logLevel: 'DEBUG',
369369
persistentLogAttributes: {
370370
aws_account_id: '123456789012',
371-
aws_region: 'eu-central-1',
371+
aws_region: 'eu-west-1',
372372
},
373373
});
374374

@@ -386,7 +386,7 @@ describe('Class: Logger', () => {
386386
timestamp: '2016-06-20T12:08:10.000Z',
387387
xray_trace_id: 'abcdef123456abcdef123456abcdef123456',
388388
aws_account_id: '123456789012',
389-
aws_region: 'eu-central-1',
389+
aws_region: 'eu-west-1',
390390
}));
391391
});
392392

@@ -446,7 +446,7 @@ describe('Class: Logger', () => {
446446
memoryLimitInMB: '128',
447447
logGroupName: '/aws/lambda/foo-bar-function-with-cold-start',
448448
logStreamName: '2021/03/09/[$LATEST]abcdef123456abcdef123456abcdef123456',
449-
invokedFunctionArn: 'arn:aws:lambda:eu-central-1:123456789012:function:foo-bar-function-with-cold-start',
449+
invokedFunctionArn: 'arn:aws:lambda:eu-west-1:123456789012:function:foo-bar-function-with-cold-start',
450450
awsRequestId: 'c6af9ac6-7b61-11e6-9a41-93e812345678',
451451
getRemainingTimeInMillis: () => 1234,
452452
done: () => console.log('Done!'),
@@ -477,14 +477,14 @@ describe('Class: Logger', () => {
477477
logsSampled: false,
478478
persistentLogAttributes: {},
479479
powertoolLogData: {
480-
awsRegion: 'eu-central-1',
480+
awsRegion: 'eu-west-1',
481481
environment: '',
482482
lambdaContext: {
483483
awsRequestId: 'c6af9ac6-7b61-11e6-9a41-93e812345678',
484484
coldStart: true,
485485
functionName: 'foo-bar-function-with-cold-start',
486486
functionVersion: '$LATEST',
487-
invokedFunctionArn: 'arn:aws:lambda:eu-central-1:123456789012:function:foo-bar-function-with-cold-start',
487+
invokedFunctionArn: 'arn:aws:lambda:eu-west-1:123456789012:function:foo-bar-function-with-cold-start',
488488
memoryLimitInMB: 128,
489489
},
490490
sampleRateValue: undefined,
@@ -544,7 +544,7 @@ describe('Class: Logger', () => {
544544
// Act
545545
logger.appendKeys({
546546
aws_account_id: '123456789012',
547-
aws_region: 'eu-central-1',
547+
aws_region: 'eu-west-1',
548548
logger: {
549549
name: 'aws-lambda-powertool-typescript',
550550
version: '0.2.4',
@@ -555,7 +555,7 @@ describe('Class: Logger', () => {
555555
expect(logger).toEqual(expect.objectContaining({
556556
persistentLogAttributes: {
557557
aws_account_id: '123456789012',
558-
aws_region: 'eu-central-1',
558+
aws_region: 'eu-west-1',
559559
logger: {
560560
name: 'aws-lambda-powertool-typescript',
561561
version: '0.2.4',
@@ -708,7 +708,7 @@ describe('Class: Logger', () => {
708708
expect(console['info']).toBeCalledTimes(1);
709709
expect(console['info']).toHaveBeenNthCalledWith(1, JSON.stringify({
710710
cold_start: true,
711-
function_arn: 'arn:aws:lambda:eu-central-1:123456789012:function:foo-bar-function',
711+
function_arn: 'arn:aws:lambda:eu-west-1:123456789012:function:foo-bar-function',
712712
function_memory_size: 128,
713713
function_name: 'foo-bar-function',
714714
function_request_id: 'c6af9ac6-7b61-11e6-9a41-93e812345678',
@@ -751,7 +751,7 @@ describe('Class: Logger', () => {
751751
}));
752752
expect(console['info']).toHaveBeenNthCalledWith(2, JSON.stringify({
753753
cold_start: true,
754-
function_arn: 'arn:aws:lambda:eu-central-1:123456789012:function:foo-bar-function',
754+
function_arn: 'arn:aws:lambda:eu-west-1:123456789012:function:foo-bar-function',
755755
function_memory_size: 128,
756756
function_name: 'foo-bar-function',
757757
function_request_id: 'c6af9ac6-7b61-11e6-9a41-93e812345678',
@@ -798,7 +798,7 @@ describe('Class: Logger', () => {
798798
}));
799799
expect(console['info']).toHaveBeenNthCalledWith(2, JSON.stringify({
800800
cold_start: true,
801-
function_arn: 'arn:aws:lambda:eu-central-1:123456789012:function:foo-bar-function',
801+
function_arn: 'arn:aws:lambda:eu-west-1:123456789012:function:foo-bar-function',
802802
function_memory_size: 128,
803803
function_name: 'foo-bar-function',
804804
function_request_id: 'c6af9ac6-7b61-11e6-9a41-93e812345678',
@@ -905,7 +905,7 @@ describe('Class: Logger', () => {
905905
logsSampled: false,
906906
persistentLogAttributes: {},
907907
powertoolLogData: {
908-
awsRegion: 'eu-central-1',
908+
awsRegion: 'eu-west-1',
909909
environment: '',
910910
sampleRateValue: undefined,
911911
serviceName: 'hello-world',
@@ -929,7 +929,7 @@ describe('Class: Logger', () => {
929929
extra: 'This is an attribute that will be logged only by the child logger',
930930
},
931931
powertoolLogData: {
932-
awsRegion: 'eu-central-1',
932+
awsRegion: 'eu-west-1',
933933
environment: '',
934934
sampleRateValue: undefined,
935935
serviceName: 'hello-world',
@@ -951,7 +951,7 @@ describe('Class: Logger', () => {
951951
logsSampled: true,
952952
persistentLogAttributes: {},
953953
powertoolLogData: {
954-
awsRegion: 'eu-central-1',
954+
awsRegion: 'eu-west-1',
955955
environment: '',
956956
sampleRateValue: 1,
957957
serviceName: 'hello-world',
@@ -973,7 +973,7 @@ describe('Class: Logger', () => {
973973
logsSampled: false,
974974
persistentLogAttributes: {},
975975
powertoolLogData: {
976-
awsRegion: 'eu-central-1',
976+
awsRegion: 'eu-west-1',
977977
environment: '',
978978
sampleRateValue: undefined,
979979
serviceName: 'hello-world',

Diff for: packages/logger/tests/unit/formatter/PowertoolLogFormatter.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe('Class: PowertoolLogFormatter', () => {
2525
const formatter = new PowertoolLogFormatter();
2626
const unformattedAttributes = {
2727
sampleRateValue: undefined,
28-
awsRegion: 'eu-central-1',
28+
awsRegion: 'eu-west-1',
2929
environment: '',
3030
serviceName: 'hello-world',
3131
xRayTraceId: 'abcdef123456abcdef123456abcdef123456',
@@ -59,7 +59,7 @@ describe('Class: PowertoolLogFormatter', () => {
5959
const formatter = new PowertoolLogFormatter();
6060
const unformattedAttributes: UnformattedAttributes = {
6161
sampleRateValue: 0.25,
62-
awsRegion: 'eu-central-1',
62+
awsRegion: 'eu-west-1',
6363
environment: 'prod',
6464
serviceName: 'hello-world',
6565
xRayTraceId: 'abcdef123456abcdef123456abcdef123456',
@@ -72,7 +72,7 @@ describe('Class: PowertoolLogFormatter', () => {
7272
memoryLimitInMB: 123,
7373
functionVersion: '1.23.3',
7474
coldStart: true,
75-
invokedFunctionArn: 'arn:aws:lambda:eu-central-1:123456789012:function:Example',
75+
invokedFunctionArn: 'arn:aws:lambda:eu-west-1:123456789012:function:Example',
7676
awsRequestId: 'abcdefg123456789',
7777
},
7878
};
@@ -83,7 +83,7 @@ describe('Class: PowertoolLogFormatter', () => {
8383
// Assess
8484
expect(value).toEqual({
8585
cold_start: true,
86-
function_arn: 'arn:aws:lambda:eu-central-1:123456789012:function:Example',
86+
function_arn: 'arn:aws:lambda:eu-west-1:123456789012:function:Example',
8787
function_memory_size: 123,
8888
function_name: 'my-lambda-function',
8989
function_request_id: 'abcdefg123456789',

0 commit comments

Comments
 (0)