Skip to content

Commit a244e86

Browse files
authored
Merge pull request #151 from wchaws/dev2
docs: update readme
2 parents 5d6c00c + 122b160 commit a244e86

File tree

5 files changed

+52
-36
lines changed

5 files changed

+52
-36
lines changed

source/constructs/README.md

Lines changed: 33 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -107,18 +107,6 @@ curl <DistUrl0>/example.jpg?x-oss-process=image/resize,w_200,h_100/quality,q_50
107107
1. 配置 DNS 解析。CloudFormation 堆栈部署完成后,您需要配置 CNAME 解析将域名指向 CloudFront,并且等待解析生效后方可使用该解决方案。您
108108
可以通过查看 CloudFormation 的输出来获取 CloudFront 的地址。
109109

110-
### 配置参数说明(cdk.context.json)
111-
| 参数名称 | 描述 |
112-
| --------------- | ------------------------------------------------------------ |
113-
| buckets | S3 存储桶。|
114-
| secret_arn | Secrets 用于调用 Post API (可选)|
115-
| stack_tags| 资源标签,方便进行费用统计(可选) |
116-
| ecs_desired_count | 初始化 Fargate 所需任务实例数量 |
117-
| use_vpc_id | 部署程序的 VPC(可选) |
118-
| enable_public_alb | 负载均衡器模式选择,面向互联网 true,内部 false,默认为面向互联网(可选) |
119-
| enable_cloudfront | CloudFront 的开关,默认为开启 true,关闭 false (可选) |
120-
| subnet_ids | 部署程序或者内部 ALB 的子网,同一 AZ 下仅可配置一个(可选)|
121-
122110
### 部署参数(中国区域)
123111

124112
| 参数名称 | 描述 |
@@ -208,6 +196,20 @@ This is an ECS Fargate based version of serverless image handler. The key featur
208196
4. [aws-cdk](https://docs.aws.amazon.com/cdk/latest/guide/getting_started.html)
209197
5. [cdk bootstrap](https://docs.aws.amazon.com/cdk/latest/guide/cli.html#cli-bootstrap)
210198

199+
200+
### 配置参数说明(cdk.context.json)
201+
| 参数名称 | 描述 |
202+
| --------------- | ------------------------------------------------------------ |
203+
| buckets | S3 存储桶。|
204+
| secret_arn | Secrets 用于调用 Post API (可选)|
205+
| stack_tags| 资源标签,方便进行费用统计(可选) |
206+
| ecs_desired_count | 初始化 Fargate 所需任务实例数量 |
207+
| use_vpc_id | 部署程序的 VPC(可选) |
208+
| enable_public_alb | 负载均衡器模式选择,面向互联网 true,内部 false,默认为面向互联网(可选) |
209+
| enable_cloudfront | CloudFront 的开关,默认为开启 true,关闭 false (可选) |
210+
| subnet_ids | 部署程序或者内部 ALB 的子网,同一 AZ 下仅可配置一个(可选)|
211+
212+
211213
### How to use?
212214

213215
```bash
@@ -217,46 +219,34 @@ yarn
217219
# Run test
218220
yarn test
219221

222+
# edit cdk.context.json
223+
220224
# Deploy stack
221225
CDK_DEPLOY_REGION=us-west-2 yarn deploy serverless-ecs-image-handler-stack
222226

223-
# Or deploy stack to an existing vpc
224-
CDK_DEPLOY_REGION=us-west-2 yarn deploy serverless-ecs-image-handler-stack -c use_vpc_id=vpc-123124124124
225-
226-
# Or deploy stack with an existing s3 bucket (WARN: This may overide your existing bucket policy)
227-
CDK_DEPLOY_REGION=us-west-2 yarn deploy serverless-ecs-image-handler-stack -c use_vpc_id=vpc-123124124124 -c use_bucket=your-bucket
228-
229227
# Destroy stack if you need
230228
yarn destroy serverless-ecs-image-handler-stack
231229
```
232230

233231
Once it is deployed you will get:
234232

235233
```
234+
...
236235
✅ serverless-ecs-image-handler-stack
237236
238237
Outputs:
239-
serverless-ecs-image-handler-stack.serverlessecrimagehandlerstackCFDistributionUrl1454FE90 = https://ABCDEFGH.cloudfront.net
240-
serverless-ecs-image-handler-stack.serverlessecrimagehandlerstackServiceLoadBalancerDNSDB026A6D = serve-serve-ABCDEF.us-west-2.elb.amazonaws.com
241-
serverless-ecs-image-handler-stack.serverlessecrimagehandlerstackServiceServiceURLE05B511A = http://serve-serve-ABCDEF.us-west-2.elb.amazonaws.com
242-
serverless-ecs-image-handler-stack.serverlessecrimagehandlerstackSrcBucketS3Url593801C5 = s3://serverless-ecr-image-han-serverlessecrimagehandle-ABCDE
238+
serverless-ecs-image-handler-stack.BucketPolicy0 = {"Action":"s3:GetObject","Effect":"Allow","Principal":{"CanonicalUser":"5edea5fed6735e7c8829"},"Resource":"arn:aws:s3:::bucket/*"}
239+
serverless-ecs-image-handler-stack.DistributionUrl0 = https://ABCDEFG.cloudfront.net
240+
serverless-ecs-image-handler-stack.StyleConfig = serverless-ecs-image-handler-stack-serverlessecsimagehandlerstackStyleTable258B7J
241+
serverless-ecs-image-handler-stack.serverlessecsimagehandlerstackServiceLoadBalancerDNSA7F19049 = serve-serve-ABC.us-west-2.elb.amazonaws.com
242+
serverless-ecs-image-handler-stack.serverlessecsimagehandlerstackServiceServiceURL3A810472 = http://serve-serve-ABC.us-west-2.elb.amazonaws.com
243243
244244
Stack ARN:
245-
arn:aws:cloudformation:us-west-2:000000000:stack/serverless-ecs-image-handler-stack/0000000-0000-0000-0000-0000
246-
✨ Done in 593.00s.
247-
```
248-
249-
Upload some pictures into
250-
251-
```
252-
serverlessecrimagehandlerstackSrcBucketS3Url593801C5 = s3://serverless-ecr-image-han-serverlessecrimagehandle-ABCDE
245+
arn:aws:cloudformation:us-west-2:000:stack/serverless-ecs-image-handler-stack/3fbd2fd0-90bb-11ec-b883-023abefd402f
246+
Done in 559.32s.
253247
```
254248

255-
Then you could try to open
256-
257-
```
258-
serverlessecrimagehandlerstackCFDistributionUrl1454FE90 = https://ABCDEFGH.cloudfront.net
259-
```
249+
Upload some pictures into your buckets:
260250

261251
Like: https://ABCDEFG.cloudfront.net/example.jpg?x-oss-process=image/resize,w_500,h_500,limit_0/quality,q_50
262252

@@ -287,6 +277,14 @@ $ npx loadtest -t 900 -c 20 --rps 300 "http://serve-serve-ABCDEF.us-west-2.elb.a
287277
[Fri Jul 23 2021 13:02:23 GMT+0000 (Coordinated Universal Time)] INFO 100% 2578 ms (longest request)
288278
```
289279

280+
### End to end test
281+
282+
Check [this](../new-image-handler/test/e2e/README.md).
283+
284+
### Benchmark test
285+
286+
Check [this](../new-image-handler/test/bench/README.md).
287+
290288
### Troubleshooting
291289

292290
1. Internal error reported from downstream service during operation 'AWS::CloudFront::OriginRequestPolicy'.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Benchmark test
2+
3+
## curl.sh make http requests to urls in parallel
4+
5+
```
6+
# edit urls.txt
7+
8+
$ ./curl.sh urls.txt
9+
$ N=10 ./curl.sh urls.txt # make 10 http requests simultaneously
10+
```

source/new-image-handler/test/bench/curl.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ N=${2:-2}
66

77
echo "request ${N} urls in parallel"
88
printf "time_total(sec)\thttp_code\tsize_download(bytes)\turl\n"
9-
cat ${URLS} | xargs -P ${N} -I {} curl -s "{}" -o /dev/null -w "%{time_total}\t%{http_code}\t%{size_download}\t{}\n"
9+
grep -v '^#' ${URLS} | xargs -P ${N} -I {} curl -s "{}" -o /dev/null -w "%{time_total}\t%{http_code}\t%{size_download}\t{}\n"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Each line must be a URL.
2+
# Comments for lines starting with #.
3+
# Example:
4+
# https://<HOST>/example.jpg?x-oss-process=image/format,gif/quality,q_80

source/new-image-handler/test/e2e/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# End 2 end test
2+
3+
## mkhtml.py is a side by side image comparison tools
4+
15
```
26
$ chmod +x mkhtml.py
37
$ B=http://HOST/ ./mkhtml.py

0 commit comments

Comments
 (0)