├── .devcontainer
├── Dockerfile
└── devcontainer.json
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── LISENCE
├── README.md
├── config.toml
├── content
├── 00_prerequisites
│ ├── 00_aws_account
│ │ ├── _index.en.md
│ │ └── _index.ja.md
│ ├── 20_install_and_configs
│ │ ├── _index.en.md
│ │ └── _index.ja.md
│ ├── _index.en.md
│ └── _index.ja.md
├── 100_supplemental_resource
│ ├── 10_cloud9
│ │ ├── _index.en.md
│ │ └── _index.ja.md
│ ├── 30_IAM_policy
│ │ ├── _index.en.md
│ │ └── _index.ja.md
│ ├── _index.en.md
│ └── _index.ja.md
├── 10_getting_started
│ ├── 00_what_you_build
│ │ ├── _index.en.md
│ │ └── _index.ja.md
│ ├── _index.en.md
│ └── _index.ja.md
├── 30_mock
│ ├── 00_bootstrap
│ │ ├── _index.en.md
│ │ └── _index.ja.md
│ ├── 10_auth
│ │ ├── _index.en.md
│ │ └── _index.ja.md
│ ├── 20_post_back_end
│ │ ├── _index.en.md
│ │ └── _index.ja.md
│ ├── 25_post_back_end_key
│ │ ├── _index.en.md
│ │ └── _index.ja.md
│ ├── 30_post_front_end
│ │ ├── _index.en.files
│ │ │ ├── AllPosts.js
│ │ │ ├── App.js
│ │ │ ├── PostList.js
│ │ │ ├── PostsBySpecifiedUser.js
│ │ │ └── Sidebar.js
│ │ ├── _index.en.md
│ │ ├── _index.ja.files
│ │ │ ├── AllPosts.js
│ │ │ ├── App.js
│ │ │ ├── PostList.js
│ │ │ ├── PostsBySpecifiedUser.js
│ │ │ └── Sidebar.js
│ │ └── _index.ja.md
│ ├── _index.en.md
│ └── _index.ja.md
├── 40_hosting
│ ├── 00_manual_deployment
│ │ ├── _index.en.md
│ │ └── _index.ja.md
│ ├── _index.en.md
│ └── _index.ja.md
├── 50_follow_timeline
│ ├── 00_follow_back_end
│ │ ├── _index.en.md
│ │ └── _index.ja.md
│ ├── 10_follow_front_end
│ │ ├── _index.en.files
│ │ │ └── PostsBySpecifiedUser.js
│ │ ├── _index.en.md
│ │ ├── _index.ja.files
│ │ │ └── PostsBySpecifiedUser.js
│ │ └── _index.ja.md
│ ├── 20_timeline_back_end
│ │ ├── _index.en.md
│ │ └── _index.ja.md
│ ├── 30_function_directive
│ │ ├── _index.en.files
│ │ │ ├── index.js
│ │ │ └── schema.graphql
│ │ ├── _index.en.md
│ │ ├── _index.ja.files
│ │ │ ├── index.js
│ │ │ └── schema.graphql
│ │ └── _index.ja.md
│ ├── 50_timeline_front_end
│ │ ├── _index.en.files
│ │ │ ├── App.js
│ │ │ ├── Sidebar.js
│ │ │ └── Timeline.js
│ │ ├── _index.en.md
│ │ ├── _index.ja.files
│ │ │ ├── App.js
│ │ │ ├── Sidebar.js
│ │ │ └── Timeline.js
│ │ └── _index.ja.md
│ ├── _index.en.md
│ └── _index.ja.md
├── 60_full_text_search
│ ├── 00_searchable_back_end
│ │ ├── _index.en.files
│ │ │ └── schema.graphql
│ │ ├── _index.en.md
│ │ ├── _index.ja.files
│ │ │ └── schema.graphql
│ │ └── _index.ja.md
│ ├── 10_searchable_front_end
│ │ ├── _index.en.files
│ │ │ ├── App.js
│ │ │ ├── Search.js
│ │ │ └── Sidebar.js
│ │ ├── _index.en.md
│ │ ├── _index.ja.files
│ │ │ ├── App.js
│ │ │ ├── Search.js
│ │ │ └── Sidebar.js
│ │ └── _index.ja.md
│ ├── _index.en.md
│ └── _index.ja.md
├── 70_multi_env
│ ├── 00_add_env
│ │ ├── _index.en.md
│ │ └── _index.ja.md
│ ├── 10_amplify_console
│ │ ├── connect_github.en.md
│ │ ├── connect_github.ja.md
│ │ ├── create_cicd.en.md
│ │ └── create_cicd.ja.md
│ ├── 20_branch_autodetection
│ │ ├── _index.en.md
│ │ └── _index.ja.md
│ ├── 30_preview_autodetection
│ │ ├── _index.en.md
│ │ └── _index.ja.md
│ ├── _index.en.md
│ └── _index.ja.md
├── 80_e2e_test
│ ├── 00_ cypress
│ │ ├── _index.en.md
│ │ └── _index.ja.md
│ ├── _index.en.md
│ └── _index.ja.md
├── 90_summary
│ ├── 10_clean_up
│ │ ├── _index.en.md
│ │ └── _index.ja.md
│ ├── _index.en.md
│ └── _index.ja.md
├── _index.en.md
├── _index.ja.md
└── final_app_image.png
├── layouts
├── index.json
└── partials
│ └── custom-footer.html
├── static
├── images
│ ├── 00_prequisites
│ │ ├── add_authentication.png
│ │ ├── add_hosting.png
│ │ ├── addingtags.jpg
│ │ ├── amplify-configure-new-iam.png
│ │ ├── amplify_publish.png
│ │ ├── attachingpolicy.jpg
│ │ ├── cloud9-tmp-credential-off.png
│ │ ├── confirmationcode.jpg
│ │ ├── createnewaccount.jpg
│ │ ├── creatingiamuser.jpg
│ │ ├── creatinguserconfirmation.jpg
│ │ ├── iam-1-create-user.png
│ │ ├── iam-2-attach-policy.png
│ │ ├── iam-3-create-user.png
│ │ ├── iam-4-save-url.png
│ │ ├── inputcredentials.jpg
│ │ ├── management-console-cloud9-1.png
│ │ ├── management-console-cloud9-2.png
│ │ ├── management-console-cloud9-3.png
│ │ ├── management-console-cloud9-4.png
│ │ ├── management-console-cloud9-5.png
│ │ ├── management-console-cloud9-6.png
│ │ ├── open_new_window.png
│ │ ├── preview_runnning_application.png
│ │ ├── signin.jpg
│ │ ├── signinsignout.mov.gif
│ │ ├── signupform.jpg
│ │ ├── terminal.png
│ │ ├── usercreated.jpg
│ │ └── vue-router.gif
│ ├── 07_multi_env
│ │ ├── .png
│ │ ├── Screen Shot 2020-05-15 at 16.32.06.png
│ │ ├── access_control.png
│ │ ├── add_ssh_key.png
│ │ ├── amplify_console.png
│ │ ├── branch_name_prefix_settings.png
│ │ ├── build_settings.png
│ │ ├── compare.png
│ │ ├── complete_deploy.png
│ │ ├── confirm.png
│ │ ├── connect_develop-branch.png
│ │ ├── connect_github.png
│ │ ├── copy_ssh_git_url.png
│ │ ├── create_build_settings.png
│ │ ├── create_new_repository.png
│ │ ├── design_env.png
│ │ ├── e2e.png
│ │ ├── edit_app.png
│ │ ├── enable_basic_auth.png
│ │ ├── enable_preview.png
│ │ ├── general_settings.png
│ │ ├── install_preview.png
│ │ ├── install_preview_dialog.png
│ │ ├── master_env.png
│ │ ├── multi_env.png
│ │ ├── new_repository.png
│ │ ├── open_pull_request.png
│ │ ├── preview_settings.png
│ │ ├── previews_detail.png
│ │ ├── previews_pr_list.png
│ │ ├── production_user_not_exist.png
│ │ ├── pull_request_amplify_link.png
│ │ ├── re_deploy.png
│ │ ├── rebuild.png
│ │ ├── select_branch_env.png
│ │ ├── select_branch_env.png_design.png
│ │ ├── select_branch_env_design.png
│ │ ├── select_preview_branch.png
│ │ ├── setting_basic_auth_pass.png
│ │ ├── share_multi_backend.png
│ │ ├── staging_confirm.png
│ │ ├── staging_confirm_design.png
│ │ ├── staging_env.png
│ │ ├── start-autodetect-branch.png
│ │ ├── start_build.png
│ │ ├── success_to_create_design.png
│ │ ├── success_to_create_staging.png
│ │ ├── success_to_deploy_preview.png
│ │ ├── success_to_push.png
│ │ └── sync_github_account.png
│ ├── 10_getting_started
│ │ ├── c9_new_terminal.png
│ │ ├── final_architecture.png
│ │ ├── pop_browser_new_window.png
│ │ └── preview_running_application.png
│ ├── 30_mock
│ │ ├── .png
│ │ ├── architecture.png
│ │ ├── architecture_api.png
│ │ ├── architecture_auth.png
│ │ ├── auth.png
│ │ ├── confirm.png
│ │ ├── getPost.png
│ │ ├── graphql_1.png
│ │ ├── graphql_2.png
│ │ ├── graphql_change_auth.png
│ │ ├── key.png
│ │ ├── listPosts.png
│ │ └── npm_start.png
│ ├── 40_hosting
│ │ └── architecture_hosting.png
│ ├── 50_follow_timeline
│ │ ├── architecture.png
│ │ ├── architecture_follow.png
│ │ ├── architecture_lambda.png
│ │ ├── architecture_timeline.png
│ │ ├── createPostAndTimeline.png
│ │ ├── createPostAndTimeline_error.png
│ │ ├── createTimeline.png
│ │ ├── follow_confirm.png
│ │ ├── follow_mutation.png
│ │ ├── listFollower.png
│ │ ├── listTimelines.png
│ │ └── listTimelines_2.png
│ ├── 60_full_text_search
│ │ ├── architecture.png
│ │ ├── front.png
│ │ └── searchPosts.png
│ ├── 80_e2e
│ │ ├── amplifyyml_dl.png
│ │ ├── build_settings.png
│ │ ├── failed_to_authenticator_test.png
│ │ ├── play_test_video.png
│ │ ├── success_to_authenticator_test.png
│ │ ├── success_to_e2e.png
│ │ └── test_flow.png
│ ├── 90_summary
│ │ └── delete_cloud9.png
│ ├── Peccy.png
│ ├── apn-logo.jpg
│ └── aws-open-source.jpg
└── js
│ └── kinesis.js
└── themes
└── learn
├── .editorconfig
├── .gitignore
├── .grenrc.yml
├── CHANGELOG.md
├── LICENSE.md
├── README.md
├── archetypes
├── chapter.md
└── default.md
├── i18n
├── ar.toml
├── de.toml
├── en.toml
├── es.toml
├── fr.toml
├── hi.toml
├── id.toml
├── nl.toml
├── pt.toml
└── tr.toml
├── images
├── screenshot.png
└── tn.png
├── layouts
├── 404.html
├── _default
│ ├── list.html
│ └── single.html
├── index.html
├── index.json
├── partials
│ ├── custom-comments.html
│ ├── custom-footer.html
│ ├── custom-header.html
│ ├── favicon.html
│ ├── footer.html
│ ├── header.html
│ ├── logo.html
│ ├── menu-footer.html
│ ├── menu.html
│ ├── meta.html
│ ├── search.html
│ ├── tags.html
│ └── toc.html
└── shortcodes
│ ├── attachments.html
│ ├── button.html
│ ├── children.html
│ ├── expand.html
│ ├── img.html
│ ├── mermaid.html
│ ├── notice.html
│ ├── ref.html
│ ├── relref.html
│ ├── siteparam.html
│ └── siteurl.html
├── static
├── css
│ ├── atom-one-dark-reasonable.css
│ ├── auto-complete.css
│ ├── featherlight.min.css
│ ├── fontawesome-all.min.css
│ ├── hugo-theme.css
│ ├── hybrid.css
│ ├── nucleus.css
│ ├── perfect-scrollbar.min.css
│ ├── tags.css
│ ├── theme-aws.css
│ ├── theme-blue.css
│ ├── theme-green.css
│ ├── theme-red.css
│ └── theme.css
├── fonts
│ ├── Inconsolata.eot
│ ├── Inconsolata.svg
│ ├── Inconsolata.ttf
│ ├── Inconsolata.woff
│ ├── Novecentosanswide-Normal-webfont.eot
│ ├── Novecentosanswide-Normal-webfont.svg
│ ├── Novecentosanswide-Normal-webfont.ttf
│ ├── Novecentosanswide-Normal-webfont.woff
│ ├── Novecentosanswide-Normal-webfont.woff2
│ ├── Novecentosanswide-UltraLight-webfont.eot
│ ├── Novecentosanswide-UltraLight-webfont.svg
│ ├── Novecentosanswide-UltraLight-webfont.ttf
│ ├── Novecentosanswide-UltraLight-webfont.woff
│ ├── Novecentosanswide-UltraLight-webfont.woff2
│ ├── Work_Sans_200.eot
│ ├── Work_Sans_200.svg
│ ├── Work_Sans_200.ttf
│ ├── Work_Sans_200.woff
│ ├── Work_Sans_200.woff2
│ ├── Work_Sans_300.eot
│ ├── Work_Sans_300.svg
│ ├── Work_Sans_300.ttf
│ ├── Work_Sans_300.woff
│ ├── Work_Sans_300.woff2
│ ├── Work_Sans_500.eot
│ ├── Work_Sans_500.svg
│ ├── Work_Sans_500.ttf
│ ├── Work_Sans_500.woff
│ └── Work_Sans_500.woff2
├── images
│ ├── clippy.svg
│ └── logo.png
├── js
│ ├── auto-complete.js
│ ├── clipboard.min.js
│ ├── featherlight.min.js
│ ├── highlight.pack.js
│ ├── html5shiv-printshiv.min.js
│ ├── hugo-learn.js
│ ├── jquery-3.3.1.min.js
│ ├── jquery.sticky.js
│ ├── learn.js
│ ├── lunr.min.js
│ ├── modernizr.custom-3.6.0.js
│ ├── perfect-scrollbar.jquery.min.js
│ ├── perfect-scrollbar.min.js
│ └── search.js
└── mermaid
│ ├── mermaid.css
│ ├── mermaid.dark.css
│ ├── mermaid.forest.css
│ └── mermaid.js
└── theme.toml
/.devcontainer/Dockerfile:
--------------------------------------------------------------------------------
1 | # Update the NODE_VERSION arg in docker-compose.yml to pick a Node version: 10, 12, 14
2 | ARG NODE_VERSION=14
3 | FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:${NODE_VERSION}
4 |
5 | # VARIANT can be either 'hugo' for the standard version or 'hugo_extended' for the extended version.
6 | ARG VARIANT=hugo
7 | # VERSION can be either 'latest' or a specific version number
8 | ARG VERSION=0.87.0
9 |
10 | # Download Hugo
11 | RUN apt-get update && apt-get install -y ca-certificates openssl git curl && \
12 | rm -rf /var/lib/apt/lists/* && \
13 | case ${VERSION} in \
14 | latest) \
15 | export VERSION=$(curl -s https://api.github.com/repos/gohugoio/hugo/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4)}') ;;\
16 | esac && \
17 | echo ${VERSION} && \
18 | case $(uname -m) in \
19 | aarch64) \
20 | export ARCH=ARM64 ;; \
21 | *) \
22 | export ARCH=64bit ;; \
23 | esac && \
24 | echo ${ARCH} && \
25 | wget -O ${VERSION}.tar.gz https://github.com/gohugoio/hugo/releases/download/v${VERSION}/${VARIANT}_${VERSION}_Linux-${ARCH}.tar.gz && \
26 | tar xf ${VERSION}.tar.gz && \
27 | mv hugo /usr/bin/hugo
28 |
29 | # Hugo dev server port
30 | EXPOSE 1313
--------------------------------------------------------------------------------
/.devcontainer/devcontainer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Hugo (Community)",
3 | "build": {
4 | "dockerfile": "Dockerfile",
5 | "args": {
6 | // Settings are based on https://github.com/microsoft/vscode-dev-containers/tree/main/containers/hugo.
7 | // Update VARIANT to pick hugo variant.
8 | // Example variants: hugo, hugo_extended
9 | // Rebuild the container if it already exists to update.
10 | "VARIANT": "hugo",
11 | // Update VERSION to pick a specific hugo version.
12 | // Example versions: latest, 0.73.0, 0,71.1
13 | // Rebuild the container if it already exists to update.
14 | // v0.87.0 is used in Amplify Social Network Workshop CI/CD pipeline.
15 | "VERSION": "0.87.0",
16 | // Update NODE_VERSION to pick the Node.js version: 12, 14
17 | "NODE_VERSION": "14",
18 | }
19 | },
20 |
21 | // Mount .gitconfig to push and pull changes from devcontainer
22 | "mounts": [
23 | "source=${localEnv:HOME}/.gitconfig,target=/home/node/.gitconfig,type=bind,consistency=cached",
24 | "source=${localEnv:HOME}/.ssh,target=/home/node/.ssh,type=bind,consistency=cached"
25 | ],
26 |
27 | // Set *default* container specific settings.json values on container create.
28 | "settings": {
29 | "html.format.templating": true,
30 | },
31 |
32 | // Add the IDs of extensions you want installed when the container is created.
33 | "extensions": [
34 | "bungcip.better-toml",
35 | "davidanson.vscode-markdownlint"
36 | ],
37 |
38 | // Use 'forwardPorts' to make a list of ports inside the container available locally.
39 | "forwardPorts": [
40 | 1313
41 | ],
42 |
43 | // Use 'postCreateCommand' to run commands after the container is created.
44 | // "postCreateCommand": "uname -a",
45 |
46 | // Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
47 | "remoteUser": "node"
48 |
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | ## Code of Conduct
2 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
3 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
4 | opensource-codeofconduct@amazon.com with any additional questions or comments.
--------------------------------------------------------------------------------
/LISENCE:
--------------------------------------------------------------------------------
1 | MIT No Attribution
2 |
3 | Copyright 2021 Amazon.com, Inc. or its affiliates.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Amplify Social Network App (SNS) Workshop
2 | This repository is soucrce code for [Amplify Social Network App (SNS) Workshop](https://amplify-sns.workshop.aws/)
3 | In this workshop, you will learn about AWS Amplify in hands-on way through the development of twitter-like social media applications.
4 |
5 | ## CONTRIBUTION
6 | See [CONTRIBUTING](CONTRIBUTING.md) for more information.
7 |
8 | ## Security
9 |
10 | See [Security issue notifications](CONTRIBUTING.md#security-issue-notifications) for more information.
11 |
12 | ## License
13 |
14 | This library is licensed under the MIT-0 License. See the [LICENSE](LISENCE) file.
--------------------------------------------------------------------------------
/config.toml:
--------------------------------------------------------------------------------
1 | # baseURL
2 | baseURL = ""
3 | languageCode = "en-EN"
4 | defaultContentLanguage = "en"
5 |
6 | # title
7 | title = "title"
8 | theme = "learn"
9 | metaDataFormat = "yaml"
10 | defaultContentLanguageInSubdir= true
11 |
12 | uglyurls = true
13 | sectionPagesMenu = "main"
14 | pygmentsCodeFences = true
15 | pygmentsStyle = "monokai"
16 |
17 | [params]
18 | # editURL
19 | # editURL = "editURL"
20 | # description
21 | description = ""
22 | # author
23 | author = "author"
24 | disableBreadcrumb = false
25 | disableNextPrev = false
26 | themeVariant = "aws"
27 | disableSearch = false
28 | disableAssetsBusting = true
29 | disableLanguageSwitchingButton = false
30 | disableShortcutsTitle = true
31 | disableInlineCopyToClipBoard = true
32 | ordersectionsby = "weight"
33 |
34 | [[menu.shortcuts]]
35 | name = " Souce code (Issues/PRs)"
36 | identifier = "fb"
37 | url = "https://github.com/aws-samples/aws-amplify-social-network-app-workshop"
38 | weight = 0
39 |
40 | [outputs]
41 | home = [ "HTML", "RSS", "JSON"]
42 |
43 | [blackfriday]
44 | plainIDAnchors = true
45 | hrefTargetBlank = true
46 |
47 | [Languages]
48 | [Languages.ja]
49 | title = "Amplify SNS Workshop"
50 | weight = 10
51 | languageName = "日本語"
52 |
53 | [Languages.en]
54 | title = "Amplify Social Network App Workshop"
55 | weight = 1
56 | languageName = "English"
57 |
--------------------------------------------------------------------------------
/content/00_prerequisites/00_aws_account/_index.en.md:
--------------------------------------------------------------------------------
1 | +++
2 |
3 | title = "Create AWS Account"
4 | date = 2020-03-18T10:09:42+09:00
5 |
6 | weight = 1
7 |
8 | pre = "1.1. "
9 |
10 | +++
11 |
12 |
13 |
14 | {{% notice warning%}}
15 | An AWS account is required for this workshop.
16 | If you have not created one, please refer to the following content to create an account.
17 | [How do I create and activate a new Amazon Web Services account?](https://aws.amazon.com/premiumsupport/knowledge-center/create-and-activate-aws-account/?nc1=h_ls)
18 | {{% /notice%}}
--------------------------------------------------------------------------------
/content/00_prerequisites/00_aws_account/_index.ja.md:
--------------------------------------------------------------------------------
1 | +++
2 | title = "AWSアカウントの作成"
3 | date = 2020-03-18T10:09:42+09:00
4 | weight = 1
5 | pre = "1.1. "
6 | +++
7 |
8 | {{% notice warning%}}
9 | 本ワークショップにはAWSのアカウントが必要になります。
10 | 作成されていない方は以下を参考にアカウントを作成してください。
11 | [AWS Hands-on for Beginners ハンズオンはじめの一歩: AWS アカウントの作り方 & IAM 基本のキ](https://pages.awscloud.com/event_JAPAN_Ondemand_Hands-on-for-Beginners-1st-Step_LP.html)
12 | {{% /notice %}}
13 |
--------------------------------------------------------------------------------
/content/00_prerequisites/_index.en.md:
--------------------------------------------------------------------------------
1 | +++
2 | title = "Prerequisites"
3 | date = 2020-03-18T10:09:41+09:00
4 | weight = 1
5 | chapter = true
6 | pre = "1. "
7 | +++
8 |
9 | In this chapter, you prepare the necessary environment for this workshop.
10 |
11 | {{% children showhidden="false"%}} {{% /children%}}
--------------------------------------------------------------------------------
/content/00_prerequisites/_index.ja.md:
--------------------------------------------------------------------------------
1 | +++
2 | title = "前提条件"
3 | date = 2020-03-18T10:09:41+09:00
4 | weight = 1
5 | chapter = true
6 | pre = "1. "
7 | +++
8 |
9 | 本章ではワークショップの実施にあたって必要な準備を行います。
10 |
11 | {{% children showhidden="false" %}}{{% /children%}}
--------------------------------------------------------------------------------
/content/100_supplemental_resource/10_cloud9/_index.en.md:
--------------------------------------------------------------------------------
1 | +++
2 | title="Set up Cloud9"
3 | date = 2020-03-18T20:09:42+09:00
4 | weight = 2
5 | pre = "10.1. "
6 | +++
7 |
8 | {{% notice info%}}
9 | We recommend you to run this workshop on **local environment**.
10 | If you have difficulty setting up `Node.js` or `npm` in your local environment, you can use [AWS Cloud9](https://aws.amazon.com/jp/cloud9/); the cloud-based integrated development environment (IDE) provided by AWS .
11 | For more information, see [10.1. Set up Cloud9](/100_supplemental_resource/10_cloud9.html).
12 | However, for Amplify Mocking, port 20002 must be available and may not be available in some Cloud IDEs.
13 | Please understand in advance.
14 | {{% /notice%}}
15 |
16 | ### Setting Up Cloud9
17 |
18 | [AWS Cloud9](https://aws.amazon.com/cloud9/?nc1=h_ls) is a cloud-based integrated development environment (IDE)
19 | Log in to the AWS Management Console and launch an instance of Cloud9 that you use to develop in this workshop.
20 |
21 | 1. Choose Cloud9 from the AWS Management Console.
22 | 2. Click on the "Create environment" button.
23 | 
24 | 1. In Name, enter a name for the environment. (e.g. amplify-handson-{date}, etc.)
"Description" is optional. Please enter a descriptive text that is easy to understand.
25 | 
26 | 4. For Instance Type, choose m5.large.
27 | If you use other size, it may run out of memory during build.
28 | Leave the default for the other items and click "Next step".
29 | 
30 | 5. Confirm the settings and click "Create Environment".
31 | 
32 | 6. Wait a while and if the following screen appears, it is successful.
33 | 
34 |
35 | ### Resize EBS
36 |
37 | [Elastic Block Store(EBS)](https://aws.amazon.com/jp/ebs) is attatched to the EC2 instance used by Cloud9.
38 | `no space left on device, write` error may be caused by insufficient storage space.
39 | We recommend you to increase volume size of EBS.
40 |
41 | ```shell
42 | INSTANCE_ID=$(curl -s http://169.254.169.254/latest/meta-data/instance-id)
43 |
44 | VOLUME_ID=$(aws ec2 describe-volumes \
45 | --query "Volumes[?Attachments[?InstanceId=='$INSTANCE_ID']].{ID:VolumeId}" \
46 | --output text)
47 |
48 | aws ec2 modify-volume --volume-id $VOLUME_ID --size 32
49 | ```
50 |
51 | {{% notice info%}}
52 | `INSTANCE_ID...` calls [EC2 instance metadata](https://docs.aws.amazon.com/ja_jp/AWSEC2/latest/UserGuide/ec2-instance-metadata.html) endpoint to fetch Instance ID of EC2 instance use by Cloud9.
53 | `VOLUME_ID...` fetches EBS volume ID using EC2 instance ID.
54 | `aws ec2...` increases volume size to 32 GiB
55 | {{% /notice %}}
56 |
57 | Confirm Cloud9 uses newly added storage.
58 | ```
59 | sudo growpart /dev/nvme0n1 1
60 |
61 | sudo xfs_growfs -d /
62 | ```
63 |
64 | ### Disable AWS Managed Temporary Credentials
65 |
66 | AWS Cloud9 creates managed temporary AWS credentials the first time you open the console.
67 |
68 | In the following steps, you disable the AWS Cloud9 temporary credentials in order to use another credential at after steps.
69 |
70 | AWS Cloud9 > Preferences > AWS SETTINGS > Toggle "AWS managed temporary credentials:" Off to the default.
71 | 
--------------------------------------------------------------------------------
/content/100_supplemental_resource/10_cloud9/_index.ja.md:
--------------------------------------------------------------------------------
1 | +++
2 | title = "Cloud9のセットアップ"
3 | date = 2020-03-18T20:09:42+09:00
4 | weight = 2
5 | pre = "10.1. "
6 | +++
7 |
8 | {{% notice info%}}
9 | 本ワークショップは**ローカル環境での実施を推奨**します。
10 | ローカル環境での`node.js`や`npm`のセットアップが困難な方は、AWS が提供するクラウドベースの統合開発環境 (IDE)である[AWS Cloud9](https://aws.amazon.com/jp/cloud9/)をお使いください。
11 | ただし、Amplify Mocking(手元での動作確認)には20002番ポートが利用可能である必要があり、一部の Cloud IDE では利用できないことがあります。
12 | あらかじめご了承ください。
13 | {{% /notice %}}
14 |
15 |
16 | ---
17 |
18 |
19 | ### Cloud9 のセットアップ
20 |
21 | Amplify ワークショップではクラウドベースの統合開発環境 (IDE)である[AWS Cloud9](https://aws.amazon.com/jp/cloud9/)上で開発を行います。AWS マネジメントコンソールにログインし、今回開発に使用する Cloud9 のインスタンスを起動します。
22 |
23 | 1.マネジメントコンソールから Cloud9 を選択 
24 |
2.「Create environment」ボタンを押下 
25 |
26 |
27 | 1. 「Name」に環境名を入力します。(例 amplify-handson-<日付> 等)
「Description」は任意項目です。わかりやすい説明文を入力してください。 
28 |
4.「Instance Type」に m5.large を選択します。小さいサイズを選択するとビルド時にメモリが不足する可能性があります。他の項目はデフォルトのままで「Next step」を押下します。
29 | 
30 |
5.設定内容を確認し、「Create Environment」を押下します。
31 | 
32 |
6.しばらく待って以下のような画面が表示されれば成功です。
33 |
34 | 
35 |
36 |
37 |
38 | ### EBS(ストレージ)のリサイズ
39 | Cloud9はEC2インスタンス上に環境を作成します。
40 | そのEC2インスタンスには[Elastic Block Store(EBS)](https://aws.amazon.com/jp/ebs)がアタッチされています。
41 | デフォルトで今回立ち上げたCloud9の作業環境に割り当てられたEBSでは`no space left on device, write`エラーが発生する場合があります。
42 | そこで、次のスクリプトを実行してEBSボリュームのサイズを引き上げます。
43 |
44 | ```shell
45 | INSTANCE_ID=$(curl -s http://169.254.169.254/latest/meta-data/instance-id)
46 |
47 | VOLUME_ID=$(aws ec2 describe-volumes \
48 | --query "Volumes[?Attachments[?InstanceId=='$INSTANCE_ID']].{ID:VolumeId}" \
49 | --output text)
50 |
51 | aws ec2 modify-volume --volume-id $VOLUME_ID --size 32
52 | ```
53 |
54 | {{% notice info%}}
55 | 最初のコマンド(`INSTANCE_ID...`)では、[EC2 instance metadata](https://docs.aws.amazon.com/ja_jp/AWSEC2/latest/UserGuide/ec2-instance-metadata.html) のエンドポイントをコールして、Cloud9が使用するEC2インスタンスのインスタンスIDを取得しています。
56 | 次のコマンド(`VOLUME_ID...`)では、AWS CLIを用いてEBSボリュームのIDを取得しています。
57 | 最後のコマンド(`aws ec2...`)では、EBSボリュームのサイズを32GiBに引き上げています。
58 | {{% /notice %}}
59 |
60 | 最後に、割り当てたストレージ領域をCloud9が利用していることを確認しましょう。
61 | ```
62 | sudo growpart /dev/nvme0n1 1
63 |
64 | sudo xfs_growfs -d /
65 | ```
66 |
67 | ### AWS 管理の一時認証情報 の無効化
68 |
69 | Cloud9 では最初にコンソールを開いたときに AWS 管理の一時認証情報が作成されます。
70 | 以降の手順では、Amplify CLI で発行するユーザの権限を使用するため、Cloud9 の一時認証情報を無効化します。
71 |
72 | AWS Cloud9 > Preferences > AWS SETTINGS > 「AWS managed temporary credentials:」 のトグルを Off にします。 
73 |
--------------------------------------------------------------------------------
/content/100_supplemental_resource/_index.en.md:
--------------------------------------------------------------------------------
1 | +++
2 | title = "Supplemental Resources"
3 | date = 2020-03-18T20:09:42+09:00
4 | weight = 100
5 | pre = "10. "
6 | +++
7 |
8 | {{% children showhidden="false" %}}{{% /children%}}
--------------------------------------------------------------------------------
/content/100_supplemental_resource/_index.ja.md:
--------------------------------------------------------------------------------
1 | +++
2 | title = "補足"
3 | date = 2020-03-18T20:09:42+09:00
4 | weight = 100
5 | pre = "10. "
6 | +++
7 |
8 | {{% children showhidden="false" %}}{{% /children%}}
--------------------------------------------------------------------------------
/content/10_getting_started/00_what_you_build/_index.en.md:
--------------------------------------------------------------------------------
1 | +++
2 | title = "The goal of this workshop"
3 | date = 2020-03-18T10:09:44+09:00
4 | weight = 1
5 | pre = "2.1. "
6 | +++
7 |
8 | ### Final Architecture
9 | 
10 |
11 |
12 | ### Tools Used
13 | * [AWS Amplify CLI](https://github.com/aws-amplify/amplify-cli): quickly provision backend resources on AWS.
14 |
15 | * [AWS Amplify JavaScript library] (https://aws-amplify.github.io/): front-end React application invokes backend resources.
16 |
17 | * [Amazon Cognito](https://aws.amazon.com/cognito/): authenticate users.
18 |
19 | * [Amazon DynamoDB](https://aws.amazon.com/dynamodb/): store the posts, follow relationships and timelines.
20 |
21 | * [AWS AppSync](https://aws.amazon.com/appsync/): host a managed GraphQL API.
22 |
23 | * [AWS Lambda](https://aws.amazon.com/lambda/): implement complicated business logics on server-side.
24 |
25 | * [Amazon Elasticsearch Service](https://aws.amazon.com/elasticsearch-service): implement full-text search.
--------------------------------------------------------------------------------
/content/10_getting_started/00_what_you_build/_index.ja.md:
--------------------------------------------------------------------------------
1 | +++
2 | title = "本ワークショップのゴール"
3 | date = 2020-03-18T10:09:44+09:00
4 | weight = 1
5 | pre = "2.1. "
6 | +++
7 |
8 | ### 最終的な構成
9 | 
10 |
11 | ### 使用ツール
12 | * [AWS Amplify CLI](https://github.com/aws-amplify/amplify-cli)を利用して、バックエンドのAWS上のリソースを高速にプロビジョニングします。
13 |
14 | * [AWS Amplify JavaScript library](https://aws-amplify.github.io/)を利用して、フロントエンドのReactアプリケーションからバックエンドのリソースを呼び出します。
15 |
16 | * [Amazon Cognito](https://aws.amazon.com/cognito/)を利用して、サービスを利用するユーザーの認証を行います。
17 |
18 | * [Amazon DynamoDB](https://aws.amazon.com/dynamodb/)を利用して、投稿やフォロー関係、タイムラインなどを保存します。
19 |
20 | * [AWS AppSync](https://aws.amazon.com/appsync/)を利用して、マネージドにGraphQL APIをホストします。
21 |
22 | * [AWS Lambda](https://aws.amazon.com/lambda/)を利用して、サーバーサイドで複雑なビジネスロジックを実装します。
23 |
24 | * [Amazon Elasticsearch Service](https://aws.amazon.com/elasticsearch-service)を利用して、全文検索機能を実装します。
--------------------------------------------------------------------------------
/content/10_getting_started/_index.en.md:
--------------------------------------------------------------------------------
1 | +++
2 | title = "Introduction"
3 | date = 2020-03-18T10:09:44+09:00
4 | weight = 2
5 | chapter = true
6 | pre = "2. "
7 | +++
8 |
9 |
10 | {{% children showhidden="false"%}} {{% /children%}}
--------------------------------------------------------------------------------
/content/10_getting_started/_index.ja.md:
--------------------------------------------------------------------------------
1 | +++
2 | title = "はじめに"
3 | date = 2020-03-18T10:09:44+09:00
4 | weight = 2
5 | chapter = true
6 | pre = "2. "
7 | +++
8 |
9 | {{% children showhidden="false" %}}{{% /children%}}
--------------------------------------------------------------------------------
/content/30_mock/00_bootstrap/_index.ja.md:
--------------------------------------------------------------------------------
1 | +++
2 | title = "Bootstrap"
3 | date = 2020-03-18T10:09:45+09:00
4 | weight = 1
5 | pre = "3.1. "
6 | +++
7 |
8 | ### 作業ディレクトリの作成
9 | 任意のディレクトリに移動していただいた後、次のコマンドを実行し、本ワークショップの作業を行うディレクトリを作成します。
10 |
11 | ```
12 | mkdir amplify-sns-workshop
13 | cd amplify-sns-workshop
14 | ```
15 |
16 | {{% notice info %}}
17 | 後ほど見返した時に何のワークショップで作成したかわかりやすいようにしています
18 | {{% /notice %}}
19 |
20 | ### Creating a React app
21 | Reactのcreate-react-appコマンドを利用して、Reactウェブアプリケーションの雛形を作成していきます。
22 |
23 | {{% notice tip %}}
24 | create-react-appコマンドについての詳細は次のリンクご参照ください。[https://github.com/facebook/create-react-app](https://github.com/facebook/create-react-app).
25 | {{% /notice %}}
26 |
27 | ```bash
28 | npx create-react-app boyaki
29 | cd boyaki
30 | ```
31 |
32 | ### Amplifyの初期化
33 | 先ほど`$ cd boyaki`で移動したReactのプロジェクトルートディレクトリ(`boyaki`)のトップで `amplify init` コマンドを実行します。
34 |
35 | ```bash
36 | amplify init
37 | ```
38 |
39 | 途中いくつか質問をされます。以下の選択肢に注意して他はデフォルトでOKです。
40 |
41 | - environment name : `production`
42 | - Choose your default editor: `Vim (via Terminal, Mac OS only)` (お好きなエディタを選択してください)
43 | - Please choose the profile you want to use `amplify-handson` (1.3.でAmplify用に作成されたProfileを選択してください)
44 |
45 | 以下は全質問への解答例です。
46 |
47 | - Enter a name for the project `boyaki`
48 | - Enter a name for the environment `production`
49 | - Choose your default editor: `Vim (via Terminal, Mac OS only)`
50 | - Choose the type of app that you're building `javascript`
51 | - What javascript framework are you using `react`
52 | - Source Directory Path: `src`
53 | - Distribution Directory Path: `build`
54 | - Build Command: `npm run-script build`
55 | - Start Command: `npm run-script start`
56 | - Do you want to use an AWS profile? `Yes`
57 | - Please choose the profile you want to use `amplify-handson`
58 |
59 |
60 | {{% notice info %}}
61 | 事前準備で `amplify configure` を正しく完了していない場合、途中で `? Setup new user` と出て新しいユーザーをセットアップするか聞かれます。
62 | その場合、`Y` と答えると、ブラウザで AWS マネジメントコンソールが立ち上がるので、マネジメントコンソールにログインし、その後のガイドに従ってください。
63 | {{% /notice %}}
64 |
65 | {{% notice tip %}}
66 | Amplify CLIではYes/Noで回答する質問の際に`Y/n`や`y/N`と表示されます。
67 | こうした質問では`yes`や`no`に加え、`y`や`n`で回答することができます。
68 | また、`Y/n`であればYes、`y/N`であればNoがデフォルトの回答になりますので、デフォルトの回答でよければそのままEnterキーを押していただくこともできます。
69 | {{% /notice %}}
70 |
71 | Profile の選択が終わると、バックエンドの初期化を開始します。AWS CloudFormation によって、アプリケーションのバックエンドに必要な基礎的な AWS リソース(IAM Role、Amazon S3 バケットなど)が自動的に作成されます。
72 |
73 | ### 環境のテスト
74 | コードの変更反映をリアルタイムで確認できるよう、development serverを立ち上げてブラウザで確認してみましょう。
75 |
76 | ```bash
77 | npm start
78 | ```
79 |
80 | development serverが立ち上がると、自動的にブラウザで`http://localhost:3000`が開かれます。
81 | 自動的に開かない場合はブラウザの検索窓に`http://localhost:3000`と入力してからEnterを押し、アクセスしましょう。
82 |
83 | 
84 |
85 | 確認ができましたら、`$ npm start`を実行中のターミナルのタブはそのままに、新しくタブを開いて作業を進めていきます。
86 |
87 | {{% notice info%}}
88 | 以下はCloud9を利用している方の手順になります。Cloud9を使用していない方は次へお進みください。
89 | なお、繰り返しになりますが本ワークショップではローカル環境での実施を推奨しております。
90 | {{% /notice %}}
91 |
92 | Cloud9のPreviewメニューをクリックし、Preview Running Applicationを選択しましょう。
93 |
94 | 
95 |
96 | お好みで、新しいタブでPreviewを表示していただくことができます。
97 |
98 | 
99 |
100 | 最後に、追加でターミナルのタブを開きましょう。元のターミナルはそのままにしておき、development serverを立ち上げたままにします。このとき、`cd boyaki`を実行しておきます。
101 |
102 | 
103 |
104 |
--------------------------------------------------------------------------------
/content/30_mock/30_post_front_end/_index.en.files/AllPosts.js:
--------------------------------------------------------------------------------
1 | import React, { useState, useEffect, useReducer } from 'react';
2 |
3 | import {API, graphqlOperation } from 'aws-amplify';
4 |
5 | import { listPostsSortedByTimestamp } from '../graphql/queries';
6 | import { onCreatePost } from '../graphql/subscriptions';
7 |
8 | import PostList from '../components/PostList';
9 | import Sidebar from './Sidebar';
10 |
11 | const SUBSCRIPTION = 'SUBSCRIPTION';
12 | const INITIAL_QUERY = 'INITIAL_QUERY';
13 | const ADDITIONAL_QUERY = 'ADDITIONAL_QUERY';
14 |
15 | const reducer = (state, action) => {
16 | switch (action.type) {
17 | case INITIAL_QUERY:
18 | return action.posts;
19 | case ADDITIONAL_QUERY:
20 | return [...state, ...action.posts]
21 | case SUBSCRIPTION:
22 | return [action.post, ...state]
23 | default:
24 | return state;
25 | }
26 | };
27 |
28 | export default function AllPosts() {
29 | const [posts, dispatch] = useReducer(reducer, []);
30 | const [nextToken, setNextToken] = useState(null);
31 | const [isLoading, setIsLoading] = useState(true);
32 |
33 | const getPosts = async (type, nextToken = null) => {
34 | const res = await API.graphql(graphqlOperation(listPostsSortedByTimestamp, {
35 | type: "post",
36 | sortDirection: 'DESC',
37 | limit: 20, //default = 10
38 | nextToken: nextToken,
39 | }));
40 | console.log(res);
41 | dispatch({ type: type, posts: res.data.listPostsSortedByTimestamp.items })
42 | setNextToken(res.data.listPostsSortedByTimestamp.nextToken);
43 | setIsLoading(false);
44 | }
45 |
46 | const getAdditionalPosts = () => {
47 | if (nextToken === null) return; //Reached the last page
48 | getPosts(ADDITIONAL_QUERY, nextToken);
49 | }
50 |
51 | useEffect(() => {
52 | getPosts(INITIAL_QUERY);
53 |
54 | const subscription = API.graphql(graphqlOperation(onCreatePost)).subscribe({
55 | next: (msg) => {
56 | console.log('allposts subscription fired')
57 | const post = msg.value.data.onCreatePost;
58 | dispatch({ type: SUBSCRIPTION, post: post });
59 | }
60 | });
61 | return () => subscription.unsubscribe();
62 | }, []);
63 |
64 |
65 | return (
66 |
4 |
5 |