You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -13,165 +13,93 @@ cd swift-tencent-scf-runtime/Examples/CloudFunctions
13
13
14
14
Note: The example scripts assume you have [jq](https://stedolan.github.io/jq/download/) command line tool installed.
15
15
16
-
## Deployment instructions using AWS CLI
16
+
## Deployment instructions using TCCLI
17
17
18
-
Steps to deploy this sample to AWS Lambda using the AWS CLI:
18
+
Steps to deploy this sample to Tencent SCF Platform using TCCLI:
19
19
20
-
1. Login to AWS Console and create an AWS Lambda with the following settings:
21
-
* Runtime: Custom runtime
22
-
* Handler: Can be any string, does not matter in this case
20
+
1. Login to SCF Console and create a cloud function
21
+
2. Build, package and deploy the function
23
22
24
-
2. Build, package and deploy the Lambda
25
-
26
-
```
27
-
./scripts/deploy.sh
28
-
```
29
-
30
-
Notes:
31
-
- This script assumes you have AWS CLI installed and credentials setup in `~/.aws/credentials`.
32
-
- The default lambda function name is `SwiftSample`. You can specify a different one updating `lambda_name` in `deploy.sh`
33
-
- Update `s3_bucket=swift-lambda-test` in `deploy.sh` before running (AWS S3 buckets require a unique global name)
34
-
- Both lambda function and S3 bucket must exist before deploying for the first time.
35
-
36
-
### Deployment instructions using AWS SAM (Serverless Application Model)
37
-
38
-
AWS [Serverless Application Model](https://aws.amazon.com/serverless/sam/) (SAM) is an open-source framework for building serverless applications. This framework allows you to easily deploy other AWS resources and more complex deployment mechanisms such a CI pipelines.
39
-
40
-
***Note:*** Deploying using SAM will automatically create resources within your AWS account. Charges may apply for these resources.
41
-
42
-
To use SAM to deploy this sample to AWS:
43
-
44
-
1. Install the AWS CLI by following the [instructions](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html).
45
-
46
-
2. Install SAM CLI by following the [instructions](https://aws.amazon.com/serverless/sam/).
47
-
48
-
3. Build, package and deploy the Lambda
49
-
50
-
```
51
-
./scripts/sam-deploy.sh --guided
52
-
```
53
-
54
-
The script will ask you which sample Lambda you wish to deploy. It will then guide you through the SAM setup process.
55
-
56
-
```
57
-
Setting default arguments for 'sam deploy'
58
-
=========================================
59
-
Stack Name [sam-app]: tencent-scf-runtime-sample
60
-
AWS Region [us-east-1]: <your-favourite-region>
61
-
#Shows you resources changes to be deployed and require a 'Y' to initiate deploy
62
-
Confirm changes before deploy [y/N]: Y
63
-
#SAM needs permission to be able to create roles to connect to the resources in your template
64
-
Allow SAM CLI IAM role creation [Y/n]: Y
65
-
Save arguments to samconfig.toml [Y/n]: Y
66
-
```
67
-
68
-
If you said yes to confirm changes, SAM will ask you to accept changes to the infrastructure you are setting up. For more on this, see [Cloud Formation](https://aws.amazon.com/cloudformation/).
69
-
70
-
The `sam-deploy` script passes through any parameters to the SAM deploy command.
71
-
72
-
4. Subsequent deploys can just use the command minus the `guided` parameter:
73
-
74
-
```
75
-
./scripts/sam-deploy.sh
76
-
```
77
-
78
-
The script will ask you which sample Lambda you wish to deploy. If you are deploying a different sample lambda, the deploy process will pull down the previous Lambda.
79
-
80
-
SAM will still ask you to confirm changes if you said yes to that initially.
81
-
82
-
5. Testing
83
-
84
-
For the API Gateway sample:
85
-
86
-
The SAM template will provide an output labelled `LambdaApiGatewayEndpoint` which you can use to test the Lambda. For example:
87
-
88
-
```
89
-
curl <<LambdaApiGatewayEndpoint>>
90
-
```
91
-
92
-
***Warning:*** This SAM template is only intended as a sample and creates a publicly accessible HTTP endpoint.
93
-
94
-
For all other samples use the AWS Lambda console.
23
+
```
24
+
./scripts/deploy.sh
25
+
```
95
26
96
-
### Deployment instructions using Serverless Framework (serverless.com)
27
+
Notes:
28
+
- This script assumes you have TCCLI installed and user configured (See https://cloud.tencent.com/document/product/440/34012).
29
+
- You'll be prompted to provide the COS bucket ID and region, and the SCF function name and region.
30
+
- Both the cloud function and COS bucket must exist before deploying for the first time.
97
31
98
-
[Serverless framework](https://www.serverless.com/open-source/) (Serverless) is a provider agnostic, open-source framework for building serverless applications. This framework allows you to easily deploy other AWS resources and more complex deployment mechanisms such a CI pipelines. Serverless Framework offers solutions for not only deploying but also testing, monitoring, alerting, and security and is widely adopted by the industry and offers along the open-source version a paid one.
32
+
### Deployment instructions using Serverless Framework for Tencent (serverless.com/cn)
99
33
100
-
***Note:*** Deploying using Serverless will automatically create resources within your AWS account. Charges may apply for these resources.
34
+
[Serverless framework](https://www.serverless.com/open-source/) (Serverless) is a provider agnostic, open-source framework for building serverless applications. [Serverless framework for Tencent](https://www.serverless.com/cn/) is a highly customized version that allows you to easily deploy other Tencent Cloud resources and more complex deployment mechanisms such a CI pipelines. Serverless Framework offers solutions for not only deploying but also testing, monitoring, alerting, and security and is widely adopted by the industry, and the Tencent Cloud version is totally free.
101
35
102
-
To use Serverless to deploy this sample to AWS:
36
+
***Note:*** Deploying using Serverless will automatically create resources within your Tencent Cloud account. Charges may apply for these resources.
103
37
104
-
1. Install the AWS CLI by following the [instructions](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html).
38
+
To use Serverless to deploy this sample to Tencent Cloud:
105
39
106
-
2. Install Serverless by following the [instructions](https://www.serverless.com/framework/docs/getting-started/).
107
-
If you already have installed be sure you have the latest version.
108
-
The examples have been tested with the version 1.72.0.
40
+
1. Install Serverless by following the [instructions](https://www.serverless.com/framework/docs/getting-started/).
41
+
If you already have installed, be sure you have the latest version.
42
+
The examples have been tested with the version 1.78.1.
109
43
110
44
```
111
-
Serverless --version
112
-
Framework Core: 1.72.0 (standalone)
113
-
Plugin: 3.6.13
45
+
$ serverless --version
46
+
Framework Core: 1.78.1
47
+
Plugin: 3.7.0
114
48
SDK: 2.3.1
115
-
Components: 2.30.12
49
+
Components: 2.34.1
116
50
```
117
51
118
-
3. Build, package and deploy the Lambda
52
+
2. Build, package and deploy the cloud function
119
53
120
-
```
121
-
./scripts/serverless-deploy.sh
122
-
```
123
-
124
-
The script will ask you which sample Lambda you wish to deploy.
125
-
126
-
The `serverless-deploy.sh` script passes through any parameters to the Serverless deploy command.
54
+
```
55
+
./scripts/serverless-deploy.sh
56
+
```
127
57
128
-
4. Testing
58
+
The script will ask you which sample function you wish to deploy.
129
59
130
-
For the APIGateway sample:
60
+
3. Test
131
61
132
-
The Serverless template will provide an endpoint which you can use to test the Lambda.
62
+
For the APIGateway sample, the Serverless template provides an endpoint with API Gateway which you can use to test the cloud function.
133
63
134
64
Outuput example:
135
65
136
66
```
137
-
...
138
-
...
139
-
Serverless: Stack update finished...
140
-
Service Information
141
-
service: apigateway-swift-aws
142
-
stage: dev
143
-
region: us-east-1
144
-
stack: apigateway-swift-aws-dev
145
-
resources: 12
146
-
api keys:
147
-
None
148
-
endpoints:
149
-
GET - https://r39lvhfng3.execute-api.us-east-1.amazonaws.com/api
0 commit comments