Skip to content

Commit 8117c12

Browse files
authored
Migration to Workshop Studio guide format (#98)
Complete re-format of all doc pages to remove references to hugo and format for Workshop Studio.
1 parent ccdd24b commit 8117c12

File tree

125 files changed

+572
-758
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+572
-758
lines changed

.github/scripts/build-assets.py

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import os
2+
import re
23
import sys
4+
import time
35
import glob
46
import shutil
57
import ntpath
8+
import tempfile
69
import subprocess
710
from pathlib import Path
811
from zipfile import ZipFile
@@ -69,4 +72,46 @@
6972
workshop_zip.write(python_script, tail)
7073
shutil.move(os.path.join(os.getcwd(), zip_file_name), os.path.join(dest_root, 'assets', zip_file_name))
7174

72-
exit()
75+
# Check build
76+
77+
preview_build = os.path.join(pkg_root, 'preview_build')
78+
shell_out = tempfile.NamedTemporaryFile(mode='w')
79+
try:
80+
proc = subprocess.Popen([preview_build,"-disable-refresh"],
81+
stdout=shell_out, stderr=shell_out, cwd=pkg_root)
82+
except FileNotFoundError as err:
83+
proc = subprocess.Popen(["preview_build", "-disable-refresh"],
84+
stdout=shell_out, stderr=shell_out, cwd=pkg_root)
85+
86+
87+
time.sleep(10)
88+
proc.kill()
89+
build_result_error = r'.*(Build complete with [0-9].*)'
90+
build_result_success = r'.*(Build succeeded.*)'
91+
status = None
92+
status_message = None
93+
count = 0
94+
with open(shell_out.name) as f:
95+
for line in f:
96+
if count > 10000:
97+
break
98+
count += 1
99+
if status == None:
100+
match_error = re.search(build_result_error, line)
101+
match_success = re.search(build_result_success, line)
102+
if match_error:
103+
status_message = match_error.group(1)
104+
status = 1
105+
print("Discovered an error in the build process.\n{}".format(status_message))
106+
elif match_success:
107+
status_message = match_success.group(1)
108+
status = 0
109+
print("Success. Build result is: \n{}".format(status_message))
110+
elif status == 1:
111+
err_match = re.search(r'^.*ERR(.*)', line)
112+
err_ignore = re.search(r'^.*Error hosting local preview site.*', line)
113+
if err_match and err_ignore is None:
114+
print("{}".format(err_match.group(1)))
115+
116+
shell_out.close()
117+
exit(status)

.github/workflows/main.yml

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,47 +3,36 @@ name: PushToProd
33
permissions:
44
id-token: write
55
on:
6-
workflow_dispatch:
7-
inputs:
8-
website:
9-
description: 'Name of the S3 bucket aka website to publish to'
10-
required: true
11-
default: 'amazon-dynamodb-labs.com'
12-
options:
13-
- 'test.amazon-dynamodb-labs.com'
14-
- 'amazon-dynamodb-labs.com'
6+
push:
7+
branches:
8+
- master
159

1610
jobs:
1711
buildAndDeploy:
1812
runs-on: ubuntu-latest
1913
env:
20-
STEP_S3_BUCKET: ${{ github.event.inputs.website }}
14+
STEP_S3_BUCKET: amazon-dynamodb-labs.com
2115
steps:
2216
- name: Checkout
2317
uses: actions/checkout@v3
2418
with:
2519
submodules: 'recursive'
2620
fetch-depth: '0'
27-
- name: Setup Hugo
28-
uses: peaceiris/actions-hugo@v2
29-
with:
30-
hugo-version: '0.102.3'
31-
# extended: true
3221
- name: Setup Python
3322
uses: actions/setup-python@v4
3423
with:
3524
python-version: '3.10'
36-
- name: Build Hugo
37-
run: hugo --buildFuture
3825
- name: Configure AWS Credentials
3926
uses: aws-actions/configure-aws-credentials@v1
4027
with:
4128
aws-region: us-east-1
4229
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
30+
- name: Pull preview build
31+
run: aws s3 sync s3://amazon-dynamodb-labs-static/build/ . && chmod +x preview_build
4332
- name: Build Assets
4433
run: python3 ./.github/scripts/build-assets.py
4534
- name: S3Sync
46-
run: aws s3 sync public s3://$STEP_S3_BUCKET --delete
35+
run: aws s3 sync public/assets/ s3://$STEP_S3_BUCKET/assets/ --delete
4736
- name: SetS3Acl
4837
run: aws s3api put-object-acl --grant-read uri=http://acs.amazonaws.com/groups/global/AllUsers --bucket $STEP_S3_BUCKET --key assets/lab.yaml
4938
- name: SetS3Acl

.github/workflows/pull-request.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: ValidatePR
2+
3+
permissions:
4+
id-token: write
5+
on:
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
buildAndVerify:
11+
runs-on: ubuntu-latest
12+
env:
13+
STEP_S3_BUCKET: 'test.amazon-dynamodb-labs.com'
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v3
17+
with:
18+
submodules: 'recursive'
19+
fetch-depth: '0'
20+
- name: Setup Python
21+
uses: actions/setup-python@v4
22+
with:
23+
python-version: '3.10'
24+
- name: Configure AWS Credentials
25+
uses: aws-actions/configure-aws-credentials@v1
26+
with:
27+
aws-region: us-east-1
28+
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
29+
- name: Pull preview build
30+
run: aws s3 sync s3://amazon-dynamodb-labs-static/build/ . && chmod +x preview_build
31+
- name: Build Assets
32+
run: python3 ./.github/scripts/build-assets.py

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[submodule "themes/learn"]
22
path = themes/learn
33
url = https://github.com/switch180/hugo-theme-learn.git
4-
branch = aws
4+
branch = aws

README.md

Lines changed: 12 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,25 @@
11
# Amazon DynamoDB Labs
2+
The repo for https://catalog.workshops.aws/dynamodb-labs/en-US , formerly https://amazon-dynamodb-labs.com
23

3-
### Setup:
4+
### Dev:
45

5-
#### Install Hugo:
6-
On a mac:
7-
8-
`brew install hugo`
9-
10-
On Linux:
11-
- Download from the releases page: https://github.com/gohugoio/hugo/releases/tag/v0.102.3
12-
- Extract and save the hugo executable to `/usr/local/bin/`
13-
14-
Note: This workshop is built with [hugo v0.102.3](https://github.com/gohugoio/hugo/releases/tag/v0.102.3). Older versions may produce errors due to the aws theme we use.
6+
#### Local development
7+
You can make code changes and markdown changes, but in order to test the build you need to be an Amazon employee with access to preview_build to compile the documentation and run the site locally. [Amazon employees click here for instructions](https://tiny.amazon.com/16x21plc5).
158

169
#### Clone this repo:
17-
From wherever you checkout repos:
10+
We suggest you make a fork. From wherever you are you can checkout the repo:
1811
`git clone git@github.com:aws-samples/amazon-dynamodb-labs.git` (or your fork)
1912

20-
#### Clone the theme submodule:
21-
`cd amazon-dynamodb-labs`
22-
23-
`git submodule init; git submodule update`
24-
25-
26-
#### Run Hugo locally:
27-
To run hugo in development:
28-
`hugo serve -D`
29-
30-
`hugo` will build your content locally and output to `./public/`
31-
32-
33-
#### View Hugo locally:
34-
Visit http://localhost:1313/ to see the site.
35-
36-
#### Making Edits:
37-
As you save edits to a page, the site will live-reload to show your changes.
13+
#### Making edits:
14+
Amazon employees only: Make changes, run preview_build, check localhost:8080 to see the site locally
15+
Everyone else: make changes, make a pull request, and wait for the automations to run. They will tell you if you have errors in your changes.
3816

39-
#### Auto deploy:
17+
#### Pull requests
18+
Make a pull request with changes. PRs will be automatically checked to make sure their markdown and other files are correct and without error using an automatic GitHub action. With each commit in a PR, the action will run to verify.
4019

41-
Within minutes of a commit to the master branch, a build and deploy using the default hugo grav learn theme will kick off. You can review your change at the following address.
20+
#### On merge to master
4221

43-
https://master.amazon-dynamodb-labs.com
22+
On merge to master, a GitHub action will deploy the assets to amazon-dynamodb-labs.com and verify the build to ensure the markdown and other files are correctly formatted. From there, a maintainer must manually pull the changes and push to https://catalog.workshops.aws/dynamodb-labs/en-US
4423

4524
## License
4625
This project is licensed under the Apache-2.0 License.

config.toml

Lines changed: 0 additions & 64 deletions
This file was deleted.

content/all-content.en.md

Lines changed: 0 additions & 6 deletions
This file was deleted.

content/authors.en.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
---
22
title: "Contributors to Amazon DynamoDB Labs"
3-
hidden: true
3+
hidden: false
44
chapter: true
55
description: "Our editors and hall of fame."
6+
weight: 100
67
---
78

89

@@ -16,12 +17,14 @@ description: "Our editors and hall of fame."
1617

1718
The serverless event driven architecture lab was added in 2023:
1819

19-
1. Lucas Rettenmeier ([@rettenls](https://github.com/rettenls)) - Workshop creator for re:Invent 2021
20-
1. Kirill Bogdanov - ([@kirillsc](https://github.com/kirillsc)) - Workshop creator for re:Invent 2021
21-
1. Sean Shriver - ([@switch180](https://github.com/switch180)) - Presenter of the workshop at re:Invent 2021. Edited and merged the lab to labs.com.
20+
1. Lucas Rettenmeier ([@rettenls](https://github.com/rettenls)) - Workshop creator for re\:Invent 2021
21+
1. Kirill Bogdanov - ([@kirillsc](https://github.com/kirillsc)) - Workshop creator for re\:Invent 2021
22+
1. Sean Shriver - ([@switch180](https://github.com/switch180)) - Presenter of the workshop at re\:Invent 2021. Edited and merged the lab to labs.com.
2223
1. John Terhune - ([@terhunej](https://github.com/terhunej)) - Prepared the lab guide for publshing to labs.com, editing and updating.
2324

25+
The lab guide was migrated from amazon-dynamodb-labs.com to Workshop Studio in December of 2023:
2426

27+
1. Sean Shriver - ([@switch180](https://github.com/switch180)) - Refactored every documentation page for the new Workshop Studio proprietary format.
2528

2629
### 2021 editors
2730

@@ -45,6 +48,6 @@ The following individuals put in hours of their time to revamp the guide to make
4548

4649
### Original version
4750

48-
This lab was built to run on Qwiklabs in 2018. In 2020 it was rewritten and updated to run outside Qwiklabs.
51+
LADV was built to run on Qwiklabs in 2018. In 2020 it was rewritten and updated to run outside Qwiklabs.
4952

50-
A special thanks goes to Regis Gimenis ([regisgimenis](https://github.com/regisgimenis)) who is the original designer of the advanced design patterns. He did one of the most difficult tasks - creating a lab from scratch. Remnants of Regis' work are found throughout the Python files of the workshop and the lab guide. Without him, this site would not exist.
53+
A special thanks goes to Regis Gimenis ([regisgimenis](https://github.com/regisgimenis)) who is the original designer of the advanced design patterns. He did one of the most difficult tasks - creating a lab from scratch. Remnants of Regis' work are found throughout the Python files of the workshop and the lab guide for LADV. Without him, this site would not exist.

content/design-patterns/ex1capacity/Step4.en.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,21 @@ To view the Amazon CloudWatch metrics for your table:
99
1. Navigate to the DynamoDB section of the AWS management console.
1010
2. As shown in the following image, in the navigation pane, choose Tables. Choose the logfile table, and in the right pane, choose the Metrics tab
1111

12-
![Open the CloudWatch metrics for the table](/images/awsnewconsole3.png)
12+
![Open the CloudWatch metrics for the table](/static/images/awsnewconsole3.png)
1313

1414

15-
<!-- ![Open the CloudWatch metrics for the table version 2](/images/awsconsole3v2.png) -->
15+
<!-- ![Open the CloudWatch metrics for the table version 2](/static/images/awsconsole3v2.png) -->
1616

1717
The CloudWatch metrics will look like what you see in the following image.
1818

19-
![The Cloud Watch metrics for the base table](/images/tablelogfile-stats.png)
19+
![The Cloud Watch metrics for the base table](/static/images/tablelogfile-stats.png)
2020

21-
{{% notice note %}}
22-
You might not see provisioned capacity data in your read or write capacity graphs, which are displayed as red lines. It takes time for DynamoDB to generate provisioned capacity CloudWatch metrics, especially for new tables.
23-
{{% /notice %}}
21+
::alert[You might not see provisioned capacity data in your read or write capacity graphs, which are displayed as red lines. It takes time for DynamoDB to generate provisioned capacity CloudWatch metrics, especially for new tables.]
2422

2523
The CloudWatch metrics will look like what you see in the following image for the global secondary index.
2624

2725

28-
![The Cloud Watch metrics for the GSI](/images/GSI-logfile-stats.png)
26+
![The Cloud Watch metrics for the GSI](/static/images/GSI-logfile-stats.png)
2927

3028

3129
**You might be wondering:** Why are there throttling events on the table but not on the global secondary index? The reason is a base table receives the writes immediately and consumes write capacity doing so, whereas a global secondary index's capacity is consumed asynchronously some time after the initial write to the base table succeeds. In order for this system to work inside the DynamoDB service, there is a buffer between a given base DynamoDB table and a global secondary index (GSI). A base table will quickly surface a throttle if capacity is exhausted, whereas only an imbalance over an extended period of time on a GSI will cause the buffer to fill, thereby generating a throttle. In short, a GSI is more forgiving in the case of an imbalanced access pattern.

content/design-patterns/ex1capacity/Step6.en.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,4 @@ row: 2000 in 0.8817043304443359
2121
RowCount: 2000, Total seconds: 17.13607406616211
2222
```
2323

24-
{{% notice note %}}
25-
With the new capacity, the total load time is lower.
26-
{{% /notice %}}
24+
::alert[With the new capacity, the total load time is lower.]

0 commit comments

Comments
 (0)