Skip to content

Commit 2b8fda2

Browse files
committed
Merge branch 'master' into lambda
2 parents f6d3bdf + 923c3cc commit 2b8fda2

File tree

5 files changed

+82
-49
lines changed

5 files changed

+82
-49
lines changed

README.md

Lines changed: 61 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,11 @@ The Scorekeep API integration is implemented in the following files-
5858
- `build.gradle` - Adds the Lambda module of the AWS SDK to the Gradle build.
5959

6060
# Scorekeep
61-
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.
61+
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.
6262

63-
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.
63+
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.
64+
65+
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.
6466

6567
**Branches**
6668
- [`cognito`](https://github.com/awslabs/eb-java-scorekeep/tree/cognito) - Support login and store users in a Cognito user pool.
@@ -69,9 +71,35 @@ The project shows the use of Spring, Angular, nginx, the AWS SDK for Java, Dynam
6971
- [`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.
7072
- [`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).
7173

72-
Use the procedures in the following sections to run the project on AWS Elastic Beanstalk and configure it for local testing and development.
74+
Use the procedures in the following sections to run the project on AWS Elastic Beanstalk and configure it for local testing and development.
75+
76+
**Sections**
77+
- [Prerequisites](#prerequisites)
78+
- [Deploy the application](#deploy-the-application)
79+
- [Configure notifications](#configure-notifications)
80+
- [How it works](#how-it-works)
81+
- [Running the project locally](#running-the-project-locally)
82+
- [Contributing](#contributing)
83+
84+
# Prerequisites
85+
- User permissions - Elastic Beanstalk, IAM*
86+
- Instance profile with permission to use DynamoDB and SNS
87+
- Elastic Beanstalk environment running Java 8
88+
89+
*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.
90+
91+
## Get permission to use Elastic Beanstalk
92+
If you are using an IAM user with limited permissions, good work! Add Elastic Beanstalk permissions to your user account to get started.
93+
94+
*To add Elastic Beanstalk permissions to an IAM user*
95+
96+
1. Sign in to a user or role with administrator permissions.
97+
2. Open the [users page](https://console.aws.amazon.com/iam/home#/users) of the IAM console.
98+
3. Choose a user.
99+
4. Click **Add permissions**.
100+
5. Add the **AWSElasticBeanstalkFullAccess** managed policy.
73101

74-
## Create an AWS Elastic Beanstalk environment
102+
## Create an Elastic Beanstalk environment
75103
Create a Java 8 SE environment in Elastic Beanstalk to host the application.
76104

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

94-
## Deploy the application
122+
# Deploy the application
95123
Deploy the source code for the project to your Elastic Beanstalk environment.
96124

97125
*To deploy the source code*
@@ -107,7 +135,7 @@ Deploy the source code for the project to your Elastic Beanstalk environment.
107135

108136
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.
109137

110-
## Configure Notifications
138+
# Configure notifications
111139
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.
112140

113141
*To enable notifications*
@@ -217,4 +245,30 @@ When you run both the API and frontend in the same Elastic Beanstalk environment
217245

218246
~/eb-java-scorekeep$ git archive -o scorekeep-v1.zip HEAD
219247

220-
5. Open your environment's Dashboard in the [Elastic Beanstalk Management Console](console.aws.amazon.com/elasticbeanstalk/home) and deploy the updated code.
248+
5. Open your environment's Dashboard in the [Elastic Beanstalk Management Console](console.aws.amazon.com/elasticbeanstalk/home) and deploy the updated code.
249+
250+
# Contributing
251+
252+
This sample application could be better with your help!
253+
254+
- Add a new game!
255+
- Implement game logic in game class. See [TicTacToe.java](https://github.com/awslabs/eb-java-scorekeep/blob/master/src/main/java/scorekeep/TicTacToe.java)
256+
- Add the class to [RulesFactory.java](https://github.com/awslabs/eb-java-scorekeep/blob/master/src/main/java/scorekeep/RulesFactory.java)
257+
- Create your own client frontend!
258+
- Web frameworks - Angular 2, React, ember, etc
259+
- Mobile app
260+
- Desktop application
261+
- Integrate with other AWS services!
262+
- CICD with CodeCommit, CodePipeline, CodeBuild, and CodeDeploy
263+
- Analytics with Kinesis, Athena, EMR, or QuickSight
264+
- Security with VPC
265+
- Performance with ElastiCache
266+
- Scalability with CloudFront
267+
- Portability with ECS or CloudFormation
268+
- Accessibility with Polly
269+
- Write tests!
270+
- Unit tests
271+
- Integration tests
272+
- Functional tests
273+
- Load tests
274+
- 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: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +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;
10+
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;
1517

1618
import com.fasterxml.jackson.databind.ObjectMapper;
1719
import com.amazonaws.services.lambda.AWSLambda;

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)