Skip to content

Commit 3e91b76

Browse files
committed
push it all
1 parent 77be03f commit 3e91b76

File tree

18 files changed

+3743
-107
lines changed

18 files changed

+3743
-107
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
out.deploy
2+
node_modules
3+
worker/node_modules/

backend/Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,4 @@ RUN apt-get install curl -y
1717
# Bundle app source
1818
COPY . .
1919

20-
EXPOSE 8080
2120
CMD [ "node", "server.js" ]

backend/package-lock.json

Lines changed: 1082 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
"author": "First Last <first.last@example.com>",
66
"main": "server.js",
77
"scripts": {
8-
"start": "node server.js"
8+
"start": "node server.js"
99
},
1010
"dependencies": {
11-
"express": "^4.16.1"
11+
"aws-sdk": "^2.985.0",
12+
"express": "^4.16.1"
1213
}
13-
}
14+
}

backend/server.js

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,29 @@
11
'use strict';
22

3-
const express = require('express');
3+
console.log(`region is: ${process.env.AWS_DEFAULT_REGION}`);
44

5-
// Constants
6-
const PORT = 8080;
7-
const HOST = '0.0.0.0';
5+
const aws = require('aws-sdk');
6+
aws.config.update({region: process.env.AWS_DEFAULT_REGION});
7+
const sns = new aws.SNS();
88

9-
// App
10-
const app = express();
11-
app.get('/', (req, res) => {
12-
console.log("received request 24")
13-
res.send('Hello World');
14-
});
9+
function sleep(ms) {
10+
return new Promise(resolve => setTimeout(resolve, ms));
11+
}
1512

16-
app.listen(PORT, HOST);
17-
console.log(`Running on http://${HOST}:${PORT}`);
13+
14+
(async () => {
15+
const {loadtest} = JSON.parse(process.env.COPILOT_SNS_TOPIC_ARNS);
16+
while(true) {
17+
try {
18+
const out = await sns.publish({
19+
Message: 'test',
20+
TopicArn: loadtest,
21+
}).promise();
22+
23+
console.log(`results: ${JSON.stringify(out)}`);
24+
} catch (err) {
25+
console.error(err);
26+
}
27+
await sleep(50);
28+
}
29+
})();

copilot/apprunner/addons/ssm.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
Parameters:
2+
App:
3+
Type: String
4+
Description: Your application's name.
5+
Env:
6+
Type: String
7+
Description: The environment name your service, job, or workflow is being deployed to.
8+
Name:
9+
Type: String
10+
Description: The name of the service, job, or workflow being deployed.
11+
12+
Resources:
13+
SSMAccessPolicy:
14+
Type: AWS::IAM::ManagedPolicy
15+
Properties:
16+
PolicyDocument:
17+
Version: 2012-10-17
18+
Statement:
19+
- Sid: GetParameters
20+
Effect: Allow
21+
Action:
22+
- ssm:GetParameterHistory
23+
- ssm:GetParametersByPath
24+
- ssm:GetParameters
25+
- ssm:GetParameter
26+
Resource:
27+
- !Sub 'arn:aws:ssm:${AWS::Region}:${AWS::AccountId}:parameter/copilot/applications/demo/*'
28+
Outputs:
29+
SSMAccessPolicyArn:
30+
Description: "The ARN of the ManagedPolicy to attach to the instance role."
31+
Value: !Ref SSMAccessPolicy

copilot/apprunner/manifest.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# The manifest for the "apprunner" service.
2+
# Read the full specification for the "Request-Driven Web Service" type at:
3+
# https://aws.github.io/copilot-cli/docs/manifest/rd-web-service/
4+
5+
# Your service name will be used in naming your resources like log groups, App Runner services, etc.
6+
name: apprunner
7+
# The "architecture" of the service you're running.
8+
type: Request-Driven Web Service
9+
10+
image:
11+
# Docker build arguments.
12+
# For additional overrides: https://aws.github.io/copilot-cli/docs/manifest/rd-web-service/#image-build
13+
build: frontend/Dockerfile
14+
# Port exposed through your container to route traffic to it.
15+
port: 8080
16+
17+
# http:
18+
# healthcheck:
19+
# path: /
20+
# healthy_threshold: 3
21+
# unhealthy_threshold: 5
22+
# interval: 10s
23+
# timeout: 5s
24+
25+
# Number of CPU units for the task.
26+
cpu: 1024
27+
# Amount of memory in MiB used by the task.
28+
memory: 2048
29+
30+
# Optional fields for more advanced use-cases.
31+
#
32+
# variables: # Pass environment variables as key value pairs.
33+
# LOG_LEVEL: info
34+
#
35+
# tags: # Pass tags as key value pairs.
36+
# project: project-name
37+
38+
# You can override any of the values defined above by environment.
39+
# environments:
40+
# test:
41+
# variables:
42+
# LOG_LEVEL: debug # Log level for the "test" environment.

copilot/bad-worker/manifest.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# The manifest for the "bad-worker" service.
2+
# Read the full specification for the "Worker Service" type at:
3+
# https://aws.github.io/copilot-cli/docs/manifest/worker-service/
4+
5+
# Your service name will be used in naming your resources like log groups, ECS services, etc.
6+
name: bad-worker
7+
type: Worker Service
8+
9+
# Configuration for your containers and service.
10+
image:
11+
# Docker build arguments.
12+
build: worker/Dockerfile
13+
14+
cpu: 256 # Number of CPU units for the task.
15+
memory: 512 # Amount of memory in MiB used by the task.
16+
exec: true # Enable running commands in your container.
17+
18+
count:
19+
range: 1-10
20+
queue_delay:
21+
acceptable_latency: 10s
22+
23+
# The events can be be received from an SQS queue via the env var $COPILOT_QUEUE_URI.
24+
subscribe:
25+
topics:
26+
- name: loadtest
27+
service: loadtester
28+
# Optional fields for more advanced use-cases.
29+
#
30+
#variables: # Pass environment variables as key value pairs.
31+
# LOG_LEVEL: info
32+
33+
#secrets: # Pass secrets from AWS Systems Manager (SSM) Parameter Store.
34+
# GITHUB_TOKEN: GITHUB_TOKEN # The key is the name of the environment variable, the value is the name of the SSM parameter.
35+
36+
# You can override any of the values defined above by environment.
37+
#environments:
38+
# test:
39+
# count: 2 # Number of tasks to run for the "test" environment.

copilot/frontend/addons/bleepblop.yml

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

copilot/frontend/manifest.yml

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,35 @@ type: Load Balanced Web Service
88

99
# Distribute traffic to your service.
1010
http:
11-
# Requests to this path will be forwarded to your service.
12-
# To match all requests you can use the "/" path.
1311
path: '/'
14-
# You can specify a custom health check path. The default is "/".
15-
# healthcheck: '/'
16-
#network:
17-
# vpc:
18-
# placement: 'private'
19-
20-
# Configuration for your containers and service.
2112
image:
2213
# Docker build arguments. For additional overrides: https://aws.github.io/copilot-cli/docs/manifest/lb-web-service/#image-build
2314
build: frontend/Dockerfile
2415
port: 8080
2516

26-
cpu: 4096 # Number of CPU units for the task.
27-
memory: 8192 # Amount of memory in MiB used by the task.
28-
count:
29-
range: 2-10
30-
cpu_percentage: 70
31-
memory_percentage: 80
32-
requests: 10000
33-
response_time: 2s # Number of tasks that should be running in your service.
17+
cpu: 256 # Number of CPU units for the task.
18+
memory: 512 # Amount of memory in MiB used by the task.
19+
count: 1
20+
# count:
21+
# range: 2-10
22+
# cpu_percentage: 70
23+
# memory_percentage: 80
24+
# requests: 10000
25+
# response_time: 2s # Number of tasks that should be running in your service.
3426
exec: true # Enable running commands in your container.
3527

28+
publish:
29+
topics:
30+
- name: customers
31+
allowed_workers: [worker]
32+
33+
storage:
34+
volumes:
35+
myManagedEFSVolume:
36+
efs: true
37+
path: /var/efs
38+
read_only: false
39+
3640
# Optional fields for more advanced use-cases.
3741
#
3842
#variables: # Pass environment variables as key value pairs.

0 commit comments

Comments
 (0)