# [DevAx::Academy][Java][Module 4] for Cathay Bank - Short URL to this page ---> https://pse.is/4mgrmw <----- - Full URL to this page https://hackmd.io/@t-Nm5db5SpqzWkaeZs8sqQ/rkvQ_MIus ## Resources ## ### Dynamodb Operation Lab ### - Lab URL: https://amazon-dynamodb-labs.com/hands-on-labs.html ### Dynamodb Developer Guide ### - https://docs.aws.amazon.com/sdkfornet1/latest/apidocs/html/N_Amazon_DynamoDBv2_DataModel.htm - https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GettingStarted.NET.08.html ## Lab ## ### Lab Document ### - Java: https://workshops.devax.academy/monoliths-to-microservices/module4.html - .Net: https://workshops.devax.academy/monoliths-to-microservices-dotnet/ ### Lab Env ### - https://dashboard.eventengine.run/login?hash=757b-1e09418a74-28 選擇 One-time password (OTP) ![](https://i.imgur.com/Jf3cEhi.png) 設定一個 Team Name (e.g. AWS Jack Hsu) ![](https://i.imgur.com/1QP4COx.png) ![](https://i.imgur.com/eOXYYQQ.png) Login EC2 - https://workshops.devax.academy/monoliths-to-microservices-dotnet/module0/remote_environment/install_cli/provided_account.html ## Information ## ### Windows Environment variable ### ## Information ## ### Windows Environment variable ### 1. Copy from dashboard set AWS_DEFAULT_REGION=<YOUR_AWS_DEFAULT_REGION> set AWS_ACCESS_KEY_ID=<YOUR_AWS_ACCESS_KEY_ID> set AWS_SECRET_ACCESS_KEY=<YOUR_AWS_SECRET_ACCESS_KEY> set AWS_SESSION_TOKEN=<YOUR_AWS_SESSION_TOKEN> 2. AWS CLI profile aws configure set profile.aws-lab-env.region %AWS_DEFAULT_REGION% aws configure set profile.aws-lab-env.aws_access_key_id %AWS_ACCESS_KEY_ID% aws configure set profile.aws-lab-env.aws_secret_access_key %AWS_SECRET_ACCESS_KEY% aws configure set profile.aws-lab-env.aws_session_token %AWS_SESSION_TOKEN% 3. Check CLI profile aws configure get profile.aws-lab-env.region aws configure get profile.aws-lab-env.aws_access_key_id aws configure get profile.aws-lab-env.aws_secret_access_key aws configure get profile.aws-lab-env.aws_session_token ### Lab 4.1.3 command ### * Load Item ``` REM Widnows CMD echo Adding record to DynamoDB aws dynamodb put-item --profile aws-lab-env --table-name TravelBuddyTripSectors --item "{\"date\": {\"N\": \"1610175636000\"},\"originCity\": {\"S\": \"Melbourne\"},\"destinationCity\": {\"S\": \"Sydney\"}}" echo Adding record to DynamoDB aws dynamodb put-item --profile aws-lab-env --table-name TravelBuddyTripSectors --item "{\"date\": {\"N\": \"1610175633000\"},\"originCity\": {\"S\": \"Melbourne\"},\"destinationCity\": {\"S\": \"Perth\"}}" echo Adding record to DynamoDB aws dynamodb put-item --profile aws-lab-env --table-name TravelBuddyTripSectors --item "{\"date\": {\"N\": \"1610190033000\"},\"originCity\": {\"S\": \"Melbourne\"},\"destinationCity\": {\"S\": \"Canberra\"}}" echo Adding record to DynamoDB aws dynamodb put-item --profile aws-lab-env --table-name TravelBuddyTripSectors --item "{\"date\": {\"N\": \"1610294800000\"},\"originCity\": {\"S\": \"Sydney\"},\"destinationCity\": {\"S\": \"Perth\"}}" echo Adding record to DynamoDB aws dynamodb put-item --profile aws-lab-env --table-name TravelBuddyTripSectors --item "{\"date\": {\"N\": \"1610327200000\"},\"originCity\": {\"S\": \"Sydney\"},\"destinationCity\": {\"S\": \"Melbourne\"}}" echo Adding record to DynamoDB aws dynamodb put-item --profile aws-lab-env --table-name TravelBuddyTripSectors --item "{\"date\": {\"N\": \"1610356000000\"},\"originCity\": {\"S\": \"Perth\"},\"destinationCity\": {\"S\": \"Darwin\"}}" echo Adding record to DynamoDB aws dynamodb put-item --profile aws-lab-env --table-name TravelBuddyTripSectors --item "{\"date\": {\"N\": \"1610374000000\"},\"originCity\": {\"S\": \"Perth\"},\"destinationCity\": {\"S\": \"Singapore\"}}" echo Adding record to DynamoDB aws dynamodb put-item --profile aws-lab-env --table-name TravelBuddyTripSectors --item "{\"date\": {\"N\": \"1610402800000\"},\"originCity\": {\"S\": \"Perth\"},\"destinationCity\": {\"S\": \"Sydney\"}}" echo Adding record to DynamoDB aws dynamodb put-item --profile aws-lab-env --table-name TravelBuddyTripSectors --item "{\"date\": {\"N\": \"1610446000000\"},\"originCity\": {\"S\": \"Melbourne\"},\"destinationCity\": {\"S\": \"Sydney\"}}" echo Adding record to DynamoDB aws dynamodb put-item --profile aws-lab-env --table-name TravelBuddyTripSectors --item "{\"date\": {\"N\": \"1610500000000\"},\"originCity\": {\"S\": \"Darwin\"},\"destinationCity\": {\"S\": \"Sydney\"}}" echo Done! ``` ### Lab 4.2.2 Git User Name & Password ### CloudFormation -> mod-xxxxxx -> Output GitUserName GitPassword ![](https://i.imgur.com/RYBNDFB.png) ### Lab 4.3.3 Replace Java code command ### rm -rf C:\Users\Administrator\git\dev-tripsearch\src rm -rf C:\Users\Administrator\git\dev-tripsearch\target copy TripSearchFromCity.zip/src to C:\Users\Administrator\git\dev-tripsearch\src copy TripSearchFromCity.zip/buildspec.yml C:\Users\Administrator\git\dev-tripsearch\. copy TripSearchFromCity.zip/.gitignore C:\Users\Administrator\git\dev-tripsearch\. copy TripSearchFromCity.zip/pom.xml C:\Users\Administrator\git\dev-tripsearch\. copy TripSearchFromCity.zip/swagger.yml C:\Users\Administrator\git\dev-tripsearch\. copy TripSearchFromCity.zip/template.yml C:\Users\Administrator\git\dev-tripsearch\. ``` #copy copy_files.sh rm -rf $1/src/* cp -r src/* $1/src rm -rf $1/target cp buildspec.yml $1/. cp .gitignore $1/. cp pom.xml $1/. cp swagger.yml $1/. cp template.yml $1/. [ -f "$1/README.md" ] && rm "$1/README.md" ``` ### Lab 4.3.1 置換 swagger.yml 的 Region & Account ID ### 使用下列兩個關鍵字分別置換內容如下 <font color=blue>REPLACE_AWS_REGION</font> => <font color=red>ap-northeast-1</font> <font color=blue>REPLACE_AWS_ACCOUNTID</font> => <font color=red>從 Console 右上角取得 AWS Account ID</font> ![](https://i.imgur.com/ilkHtwV.png) 置換內容範本 arn:aws:apigateway:<font color=blue>REPLACE_AWS_REGION</font>:lambda:path/2015-03-31/functions/arn:aws:lambda:<font color=blue>REPLACE_AWS_REGION</font>:<font color=blue>REPLACE_AWS_ACCOUNTID</font>:function:${stageVariables.LambdaTrips}/invocations uri: 'arn:aws:apigateway:<font color=red>ap-northeast-1</font>:lambda:path/2015-03-31/functions/arn:aws:lambda:<font color=red>ap-northeast-1</font>:<font color=red>200314396804</font>:function:${stageVariables.LambdaTripsFromCity}/invocations>:<font color=red>200314396804</font>:function:${stageVariables.LambdaTripsFromCity}/invocations' ### Lab 4.3.2 Update the IAM Polices ### IAM 設定參考畫面 ![](https://i.imgur.com/cvKi9VF.png) ## CAST 課程滿意度調查 ## Full URL - https://survey.immersionday.com/cARTqHc4R ```