Skip to content

Commit 7fb1d0d

Browse files
committed
Merge branch 'master' into xray-gettingstarted
2 parents 438f854 + 923c3cc commit 7fb1d0d

File tree

5 files changed

+81
-50
lines changed

5 files changed

+81
-50
lines changed

README.md

Lines changed: 61 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# Scorekeep
2-
Scorekeep is a RESTful web API implemented in Java that uses Spring to provide an HTTP interface for creating and managing game sessions and users. This project includes the scorekeep API and a frontend web app that consumes it. The frontend and API can run on the same server and domain or separately, with the API running in Elastic Beanstalk and the frontend served statically by a CDN.
2+
Scorekeep is a RESTful web API implemented in Java that uses Spring to provide an HTTP interface for creating and managing game sessions and users. This project includes the Scorekeep API and a frontend web app that consumes it. The frontend and API can run on the same server and domain or separately, with the API running in Elastic Beanstalk and the frontend served statically by a CDN.
33

4-
The project shows the use of Spring, Angular, nginx, the AWS SDK for Java, DynamoDB, Gradle, CORS, and Elastic Beanstalk features that let you run both components on the same EC2 instance, create required DynamoDB tables as part of the Elastic Beanstalk environment, and build the API from source on-instance during deployment.
4+
The `master` branch shows the use of Spring, Angular, nginx, the AWS SDK for Java, DynamoDB, Gradle, CORS, and Elastic Beanstalk features that let you run both components on the same EC2 instance, create required DynamoDB and SNS resources as part of the Elastic Beanstalk environment, and build the API from source on-instance during deployment.
5+
6+
Other branches extend the application's functionality and show the use of other AWS services. See the readme in each branch for details about the integration, and instructions for use.
57

68
**Branches**
79
- [`cognito`](https://github.com/awslabs/eb-java-scorekeep/tree/cognito) - Support login and store users in a Cognito user pool.
@@ -10,9 +12,35 @@ The project shows the use of Spring, Angular, nginx, the AWS SDK for Java, Dynam
1012
- [`xray`](https://github.com/awslabs/eb-java-scorekeep/tree/xray) - Use the AWS X-Ray SDK to instrument incoming requests, SDK clients, SQL queries, HTTP clients, and sections of code.
1113
- [`xray-gettingstarted`](https://github.com/awslabs/eb-java-scorekeep/tree/xray-gettingstarted) ([tutorial](https://docs.aws.amazon.com/xray/latest/devguide/xray-gettingstarted.html)) - Use the AWS X-Ray to instrument incoming requests and SDK clients (no additional configuration required).
1214

13-
Use the procedures in the following sections to run the project on AWS Elastic Beanstalk and configure it for local testing and development.
15+
Use the procedures in the following sections to run the project on AWS Elastic Beanstalk and configure it for local testing and development.
16+
17+
**Sections**
18+
- [Prerequisites](#prerequisites)
19+
- [Deploy the application](#deploy-the-application)
20+
- [Configure notifications](#configure-notifications)
21+
- [How it works](#how-it-works)
22+
- [Running the project locally](#running-the-project-locally)
23+
- [Contributing](#contributing)
24+
25+
# Prerequisites
26+
- User permissions - Elastic Beanstalk, IAM*
27+
- Instance profile with permission to use DynamoDB and SNS
28+
- Elastic Beanstalk environment running Java 8
29+
30+
*If you don't have permission to manage permissions in IAM, get someone who does to add DynamoDB and SNS permissions to the default Elastic Beanstalk instance profile.
31+
32+
## Get permission to use Elastic Beanstalk
33+
If you are using an IAM user with limited permissions, good work! Add Elastic Beanstalk permissions to your user account to get started.
34+
35+
*To add Elastic Beanstalk permissions to an IAM user*
36+
37+
1. Sign in to a user or role with administrator permissions.
38+
2. Open the [users page](https://console.aws.amazon.com/iam/home#/users) of the IAM console.
39+
3. Choose a user.
40+
4. Click **Add permissions**.
41+
5. Add the **AWSElasticBeanstalkFullAccess** managed policy.
1442

15-
## Create an AWS Elastic Beanstalk environment
43+
## Create an Elastic Beanstalk environment
1644
Create a Java 8 SE environment in Elastic Beanstalk to host the application.
1745

1846
*To create an Elastic Beanstalk environment running the Java 8 SE platform*
@@ -32,7 +60,7 @@ When the Scorekeep API runs in AWS Elastic Beanstalk, it uses the permissions of
3260
3. Select [AmazonDynamoDBFullAccess](https://console.aws.amazon.com/iam/home#policies/arn:aws:iam::aws:policy/AmazonDynamoDBFullAccess) and click **Attach Policy**.
3361
3. Select [AmazonSNSFullAccess](https://console.aws.amazon.com/iam/home#policies/arn:aws:iam::aws:policy/AmazonSNSFullAccess) and click **Attach Policy**.
3462

35-
## Deploy the application
63+
# Deploy the application
3664
Deploy the source code for the project to your Elastic Beanstalk environment.
3765

3866
*To deploy the source code*
@@ -48,7 +76,7 @@ Deploy the source code for the project to your Elastic Beanstalk environment.
4876

4977
Click through the app to explore its functionality. Use the network console in your browser to see the HTTP requests that it sends to the API to read and write users, sessions, games, moves and game state to DynamoDB via the API.
5078

51-
## Configure Notifications
79+
# Configure notifications
5280
The API uses Amazon SNS to send a notification email when a game ends. To enable notifications, configure your email address in an environment variable.
5381

5482
*To enable notifications*
@@ -158,4 +186,30 @@ When you run both the API and frontend in the same Elastic Beanstalk environment
158186

159187
~/eb-java-scorekeep$ git archive -o scorekeep-v1.zip HEAD
160188

161-
5. Open your environment's Dashboard in the [Elastic Beanstalk Management Console](console.aws.amazon.com/elasticbeanstalk/home) and deploy the updated code.
189+
5. Open your environment's Dashboard in the [Elastic Beanstalk Management Console](console.aws.amazon.com/elasticbeanstalk/home) and deploy the updated code.
190+
191+
# Contributing
192+
193+
This sample application could be better with your help!
194+
195+
- Add a new game!
196+
- Implement game logic in game class. See [TicTacToe.java](https://github.com/awslabs/eb-java-scorekeep/blob/master/src/main/java/scorekeep/TicTacToe.java)
197+
- Add the class to [RulesFactory.java](https://github.com/awslabs/eb-java-scorekeep/blob/master/src/main/java/scorekeep/RulesFactory.java)
198+
- Create your own client frontend!
199+
- Web frameworks - Angular 2, React, ember, etc
200+
- Mobile app
201+
- Desktop application
202+
- Integrate with other AWS services!
203+
- CICD with CodeCommit, CodePipeline, CodeBuild, and CodeDeploy
204+
- Analytics with Kinesis, Athena, EMR, or QuickSight
205+
- Security with VPC
206+
- Performance with ElastiCache
207+
- Scalability with CloudFront
208+
- Portability with ECS or CloudFormation
209+
- Accessibility with Polly
210+
- Write tests!
211+
- Unit tests
212+
- Integration tests
213+
- Functional tests
214+
- Load tests
215+
- File an [issue](https://github.com/awslabs/eb-java-scorekeep/issues) to report a bug or request new features.

src/main/java/scorekeep/GameModel.java

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,16 @@
11
package scorekeep;
22

3-
import java.io.File;
4-
import java.util.Iterator;
5-
import java.util.Map;
6-
import java.util.HashMap;
7-
import java.util.List;
8-
import java.util.Set;
9-
import java.util.HashSet;
10-
11-
import com.amazonaws.auth.AWSCredentials;
12-
import com.amazonaws.auth.profile.ProfileCredentialsProvider;
13-
import com.amazonaws.auth.AWSCredentialsProvider;
3+
import com.amazonaws.regions.Regions;
144
import com.amazonaws.services.dynamodbv2.AmazonDynamoDB;
155
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder;
166
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper;
177
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBQueryExpression;
188
import com.amazonaws.services.dynamodbv2.model.AttributeValue;
19-
import com.amazonaws.regions.Regions;
20-
import com.fasterxml.jackson.core.JsonFactory;
21-
import com.fasterxml.jackson.core.JsonParser;
22-
import com.fasterxml.jackson.databind.JsonNode;
23-
import com.fasterxml.jackson.databind.ObjectMapper;
24-
import com.fasterxml.jackson.databind.node.ObjectNode;
25-
import java.lang.Exception;
26-
import java.lang.Throwable;
9+
10+
import java.util.HashMap;
11+
import java.util.List;
12+
import java.util.Map;
13+
import java.util.Set;
2714

2815
public class GameModel {
2916
/** AWS SDK credentials. */

src/main/java/scorekeep/SessionModel.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
package scorekeep;
22

3-
import java.io.File;
4-
import java.util.Iterator;
5-
import java.util.List;
6-
7-
import com.amazonaws.auth.AWSCredentials;
8-
import com.amazonaws.auth.profile.ProfileCredentialsProvider;
9-
import com.amazonaws.auth.AWSCredentialsProvider;
3+
import com.amazonaws.regions.Regions;
104
import com.amazonaws.services.dynamodbv2.AmazonDynamoDB;
115
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder;
126
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper;
137
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBScanExpression;
14-
import com.amazonaws.regions.Regions;
8+
9+
import java.util.List;
1510

1611
public class SessionModel {
1712

src/main/java/scorekeep/UserFactory.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
package scorekeep;
2-
import java.util.*;
3-
import java.security.SecureRandom;
4-
import java.math.BigInteger;
5-
import java.lang.Exception;
6-
import java.io.InputStream;
7-
import java.io.IOException;
82

3+
import com.fasterxml.jackson.databind.ObjectMapper;
94
import org.apache.http.HttpEntity;
105
import org.apache.http.client.methods.CloseableHttpResponse;
116
import org.apache.http.client.methods.HttpGet;
12-
import org.apache.http.util.EntityUtils;
137
import org.apache.http.impl.client.CloseableHttpClient;
148
import org.apache.http.impl.client.HttpClientBuilder;
9+
import org.apache.http.util.EntityUtils;
1510

16-
import com.fasterxml.jackson.databind.ObjectMapper;
11+
import java.io.IOException;
12+
import java.io.InputStream;
13+
import java.math.BigInteger;
14+
import java.security.SecureRandom;
15+
import java.util.List;
16+
import java.util.Map;
1717

1818
public class UserFactory {
1919
private SecureRandom random = new SecureRandom();

src/main/java/scorekeep/UserModel.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
package scorekeep;
22

3-
import java.io.File;
4-
import java.util.Iterator;
5-
import java.util.List;
6-
7-
import com.amazonaws.auth.AWSCredentials;
8-
import com.amazonaws.auth.profile.ProfileCredentialsProvider;
9-
import com.amazonaws.auth.AWSCredentialsProvider;
3+
import com.amazonaws.regions.Regions;
104
import com.amazonaws.services.dynamodbv2.AmazonDynamoDB;
115
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder;
126
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper;
137
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBScanExpression;
14-
import com.amazonaws.regions.Regions;
8+
9+
import java.util.List;
1510

1611
public class UserModel {
1712
/** AWS SDK credentials. */

0 commit comments

Comments
 (0)