Skip to content

Commit fee6734

Browse files
sthulbdreamorosi
andcommitted
chore(ci): add step to publish docs to S3 (#1468)
* add required steps and permissions * update permissions for doc launching * adds environment to the workflow file * Update .github/workflows/reusable-publish-docs.yml --------- Co-authored-by: Andrea Amorosi <[email protected]>
1 parent 792bd9e commit fee6734

File tree

8 files changed

+126
-111
lines changed

8 files changed

+126
-111
lines changed

Diff for: .github/workflows/on_doc_merge.yml

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ jobs:
1313
permissions:
1414
contents: write
1515
pages: write
16+
id-token: write
1617
uses: ./.github/workflows/reusable-publish-docs.yml
1718
with:
1819
version: main

Diff for: .github/workflows/publish_layer.yml

+4
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ jobs:
104104
105105
release-docs:
106106
needs: [ deploy-prod, prepare_docs_alias ]
107+
permissions:
108+
contents: write
109+
pages: write
110+
id-token: write
107111
uses: ./.github/workflows/reusable-publish-docs.yml
108112
with:
109113
version: ${{ inputs.latest_published_version }}

Diff for: .github/workflows/rebuild-latest-docs.yml

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
permissions:
1919
contents: write
2020
pages: write
21+
id-token: write
2122
uses: ./.github/workflows/reusable-publish-docs.yml
2223
with:
2324
version: ${{ inputs.latest_published_version }}

Diff for: .github/workflows/reusable-publish-docs.yml

+31
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,15 @@ on:
2222
default: false
2323
type: boolean
2424

25+
permissions:
26+
contents: write
27+
id-token: write
28+
pages: write
29+
2530
jobs:
2631
publish-docs:
2732
runs-on: ubuntu-latest
33+
environment: Docs
2834
steps:
2935
- name: Checkout code
3036
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
@@ -87,3 +93,28 @@ jobs:
8793
publish_dir: ./api
8894
keep_files: true
8995
destination_dir: latest/api
96+
97+
- name: Configure AWS credentials
98+
uses: aws-actions/configure-aws-credentials@e1e17a757e536f70e52b5a12b2e8d1d1c60e04ef # v2.0.0
99+
with:
100+
aws-region: us-east-1
101+
role-to-assume: ${{ secrets.AWS_DOCS_ROLE_ARN }}
102+
- name: Copy API Docs
103+
run: |
104+
cp -r api site/
105+
- name: Deploy Docs (Version)
106+
env:
107+
VERSION: ${{ inputs.version }}
108+
ALIAS: ${{ inputs.alias }}
109+
run: |
110+
aws s3 sync \
111+
site/ \
112+
s3://${{ secrets.AWS_DOCS_BUCKET }}/lambda-test/${{ env.VERSION }}/
113+
- name: Deploy Docs (Alias)
114+
env:
115+
VERSION: ${{ inputs.version }}
116+
ALIAS: ${{ inputs.alias }}
117+
run: |
118+
aws s3 sync \
119+
site/ \
120+
s3://${{ secrets.AWS_DOCS_BUCKET }}/lambda-test/${{ env.ALIAS }}/

Diff for: docs/core/logger.md

+28-28
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ These settings will be used across all logs emitted:
6868
ShoppingCartApiFunction:
6969
Type: AWS::Serverless::Function
7070
Properties:
71-
Runtime: nodejs16.x
71+
Runtime: nodejs18.x
7272
Environment:
7373
Variables:
7474
LOG_LEVEL: WARN
@@ -112,7 +112,7 @@ This functionality will include the following keys in your structured logs:
112112
You can install Middy by running `npm i @middy/core`.
113113
Learn more about [its usage and lifecycle in the official Middy documentation](https://middy.js.org/docs/intro/getting-started){target="_blank"}.
114114

115-
```typescript hl_lines="1-2 13"
115+
```typescript hl_lines="1 13"
116116
--8<-- "docs/snippets/logger/middy.ts"
117117
```
118118

@@ -402,7 +402,7 @@ The `createChild` method allows you to create a child instance of the Logger, wh
402402

403403
=== "Example CloudWatch Logs excerpt"
404404

405-
```json hl_lines="15-21"
405+
```json hl_lines="21"
406406
{
407407
"level": "INFO",
408408
"message": "This is an INFO log, from the parent logger",
@@ -590,31 +590,31 @@ This is how the printed log would look:
590590
=== "Example CloudWatch Logs excerpt"
591591

592592
```json
593-
{
594-
"message": "This is an INFO log",
595-
"service": "serverlessAirline",
596-
"awsRegion": "eu-west-1",
597-
"correlationIds": {
598-
"awsRequestId": "c6af9ac6-7b61-11e6-9a41-93e812345678",
599-
"xRayTraceId": "abcdef123456abcdef123456abcdef123456",
600-
"myCustomCorrelationId": "foo-bar-baz"
601-
},
602-
"lambdaFunction": {
603-
"name": "shopping-cart-api-lambda-prod-eu-west-1",
604-
"arn": "arn:aws:lambda:eu-west-1:123456789012:function:shopping-cart-api-lambda-prod-eu-west-1",
605-
"memoryLimitInMB": 128,
606-
"version": "$LATEST",
607-
"coldStart": true
608-
},
609-
"logLevel": "INFO",
610-
"timestamp": "2021-12-12T23:13:53.404Z",
611-
"logger": {
612-
"sampleRateValue": "0.5",
613-
"name": "aws-lambda-powertools-typescript",
614-
"version": "0.0.1"
615-
},
616-
"awsAccountId": "123456789012"
617-
}
593+
{
594+
"message": "This is an INFO log",
595+
"service": "serverlessAirline",
596+
"awsRegion": "eu-west-1",
597+
"correlationIds": {
598+
"awsRequestId": "c6af9ac6-7b61-11e6-9a41-93e812345678",
599+
"xRayTraceId": "abcdef123456abcdef123456abcdef123456",
600+
"myCustomCorrelationId": "foo-bar-baz"
601+
},
602+
"lambdaFunction": {
603+
"name": "shopping-cart-api-lambda-prod-eu-west-1",
604+
"arn": "arn:aws:lambda:eu-west-1:123456789012:function:shopping-cart-api-lambda-prod-eu-west-1",
605+
"memoryLimitInMB": 128,
606+
"version": "$LATEST",
607+
"coldStart": true
608+
},
609+
"logLevel": "INFO",
610+
"timestamp": "2021-12-12T23:13:53.404Z",
611+
"logger": {
612+
"sampleRateValue": "0.5",
613+
"name": "aws-lambda-powertools-typescript",
614+
"version": "0.0.1"
615+
},
616+
"awsAccountId": "123456789012"
617+
}
618618
```
619619

620620
!!! tip "Custom Log formatter and Child loggers"

Diff for: docs/core/metrics.md

+52-74
Original file line numberDiff line numberDiff line change
@@ -251,25 +251,21 @@ See below an example of how to automatically flush metrics with the Middy-compat
251251

252252
=== "Example CloudWatch Logs excerpt"
253253

254-
```json hl_lines="2 7 10 15 22"
254+
```json
255255
{
256256
"successfulBooking": 1.0,
257257
"_aws": {
258-
"Timestamp": 1592234975665,
259-
"CloudWatchMetrics": [
260-
{
261-
"Namespace": "serverlessAirline",
262-
"Dimensions": [
263-
[
264-
"service"
265-
]
266-
],
267-
"Metrics": [
268-
{
269-
"Name": "successfulBooking",
270-
"Unit": "Count"
271-
}
272-
]
258+
"Timestamp": 1592234975665,
259+
"CloudWatchMetrics": [{
260+
"Namespace": "serverlessAirline",
261+
"Dimensions": [
262+
[ "service" ]
263+
],
264+
"Metrics": [{
265+
"Name": "successfulBooking",
266+
"Unit": "Count"
267+
}]
268+
}]
273269
},
274270
"service": "orders"
275271
}
@@ -293,25 +289,21 @@ The `logMetrics` decorator of the metrics utility can be used when your Lambda h
293289

294290
=== "Example CloudWatch Logs excerpt"
295291

296-
```json hl_lines="2 7 10 15 22"
292+
```json
297293
{
298294
"successfulBooking": 1.0,
299295
"_aws": {
300-
"Timestamp": 1592234975665,
301-
"CloudWatchMetrics": [
302-
{
303-
"Namespace": "successfulBooking",
304-
"Dimensions": [
305-
[
306-
"service"
307-
]
308-
],
309-
"Metrics": [
310-
{
311-
"Name": "successfulBooking",
312-
"Unit": "Count"
313-
}
314-
]
296+
"Timestamp": 1592234975665,
297+
"CloudWatchMetrics": [{
298+
"Namespace": "successfulBooking",
299+
"Dimensions": [
300+
[ "service" ]
301+
],
302+
"Metrics": [{
303+
"Name": "successfulBooking",
304+
"Unit": "Count"
305+
}]
306+
}]
315307
},
316308
"service": "orders"
317309
}
@@ -332,27 +324,21 @@ You can manually flush the metrics with `publishStoredMetrics` as follows:
332324

333325
=== "Example CloudWatch Logs excerpt"
334326

335-
```json hl_lines="2 7 10 15 22"
327+
```json
336328
{
337329
"successfulBooking": 1.0,
338330
"_aws": {
339-
"Timestamp": 1592234975665,
340-
"CloudWatchMetrics": [
341-
{
342-
"Namespace": "successfulBooking",
343-
"Dimensions": [
344-
[
345-
"service"
346-
]
347-
],
348-
"Metrics": [
349-
{
350-
"Name": "successfulBooking",
351-
"Unit": "Count"
352-
}
353-
]
354-
}
355-
]
331+
"Timestamp": 1592234975665,
332+
"CloudWatchMetrics": [{
333+
"Namespace": "successfulBooking",
334+
"Dimensions": [
335+
[ "service" ]
336+
],
337+
"Metrics": [{
338+
"Name": "successfulBooking",
339+
"Unit": "Count"
340+
}]
341+
}]
356342
},
357343
"service": "orders"
358344
}
@@ -410,35 +396,27 @@ You can add high-cardinality data as part of your Metrics log with the `addMetad
410396

411397
=== "Example CloudWatch Logs excerpt"
412398

413-
```json hl_lines="23"
399+
```json hl_lines="31"
414400
{
415401
"successfulBooking": 1.0,
416402
"_aws": {
417-
"Timestamp": 1592234975665,
418-
"CloudWatchMetrics": [
419-
{
420-
"Namespace": "serverlessAirline",
421-
"Dimensions": [
422-
[
423-
"service"
424-
]
425-
],
426-
"Metrics": [
427-
{
428-
"Namespace": "exampleApplication",
403+
"Timestamp": 1592234975665,
404+
"CloudWatchMetrics": [{
405+
"Namespace": "serverlessAirline",
429406
"Dimensions": [
430-
[
431-
"service"
432-
]
407+
[ "service" ]
433408
],
434-
"Metrics": [
435-
{
436-
"Name": "successfulBooking",
437-
"Unit": "Count"
438-
}
439-
]
440-
}
441-
]
409+
"Metrics": [{
410+
"Namespace": "exampleApplication",
411+
"Dimensions": [
412+
[ "service" ]
413+
],
414+
"Metrics": [{
415+
"Name": "successfulBooking",
416+
"Unit": "Count"
417+
}]
418+
}]
419+
}]
442420
},
443421
"service": "orders",
444422
"bookingId": "7051cd10-6283-11ec-90d6-0242ac120003"

Diff for: docs/core/tracer.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ The `Tracer` utility is instantiated outside of the Lambda handler. In doing thi
7272
HelloWorldFunction:
7373
Type: AWS::Serverless::Function
7474
Properties:
75-
Runtime: nodejs16.x
75+
Runtime: nodejs18.x
7676
Tracing: Active
7777
Environment:
7878
Variables:
@@ -89,7 +89,7 @@ You can quickly start by importing the `Tracer` class, initialize it outside the
8989
You can install Middy by running `npm i @middy/core`.
9090
Learn more about [its usage and lifecycle in the official Middy documentation](https://middy.js.org/docs/intro/getting-started){target="_blank"}.
9191

92-
```typescript hl_lines="1-2 14 16"
92+
```typescript hl_lines="1 14 16"
9393
--8<-- "docs/snippets/tracer/middy.ts"
9494
```
9595

0 commit comments

Comments
 (0)