Currently, Serverless Framework can deploy a project properly only with the relevant role permissions in the SLS_QcsRole
role under the account. This role contains the policies for products that are used in deployment with Serverless Framework. You can configure the permissions for a root account or sub-account.
Currently, you can grant permissions by configuring the account key. As the root account has the permissions to create roles and bind policies, you can associate it with SLS_QcsRole
for Serverless Framework access in the following way:
If you want to configure persistent environment variables/key information so that you do not need to deploy them by scanning the code every time, you can create a .env
file under the project directory and save the SecretId
and SecretKey
information.
# .env
TENCENT_SECRET_ID=123 // Your `SecretId`
TENCENT_SECRET_KEY=123 // Your `SecretKey`
Serverless Framework will check whether the user is in Mainland China by default during deployment. If your development environment is outside Mainland China and you want to use Serverless Framework in the Mainland China edition, you can add the following configuration in the .env
file to start the Mainland China edition by default, which provides an interactive quick deployment process (for more information, please see Getting Started).
# .env
TENCENT_SECRET_ID=123
TENCENT_SECRET_KEY=123
SERVERLESS_PLATFORM_VENDOR=tencent
Note:
- If you don't have a Tencent Cloud account yet, please sign up first.
- If you already have a Tencent Cloud account, you can get
SecretId
andSecretKey
in API Key Management.
If you want to grant a sub-account the permission to deploy by scanning code, you need to ensure that the sub-account has permissions to create roles and bind role policies. You can add the preset policy QcloudCamRoleFullAccess
or QcloudCamSubaccountsAuthorizeRoleFullAccess
to the sub-account.
You can also add SLS_QcsRole
by using the root account in the CAM Console to grant access to Serverless Framework resources. The role entity is sls.cloud.tencent.com
, which includes the following policy permissions:
After the creation is successful, the root account needs to bind the following two policies to the sub-account:
uin
(account ID):{
"version": "2.0",
"statement": [
{
"action": [
"cam:PassRole"
],
"resource": [
"qcs::cam::uin/000000000000:roleName/SLS_QcsRole"
],
"effect": "allow"
}
]
}
Two authorization methods are provided below for your reference:
QcloudSLSFullAccess
and click Next.{
"version": "2.0",
"statement": [
{
"action": [
"sls:*"
],
"resource": "*",
"effect": "allow"
}
]
}
You can allow a sub-account to manipulate only specific Serverless Framework resources in the following steps:
{
"version": "2.0",
"statement": [
{
"action": [
"sls:*"
],
"resource": "qcs::sls:ap-guangzhou::appname/${appname}/stagename/${stagename}",
"effect": "allow"
}
]
}
After the configuration is completed, the sub-account will have the permission to manipulate serverless applications only under ${appname}
and ${stagename}
.
Was this page helpful?