Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b8f71e9

Browse files
committed
fix: change role to roleArn
1 parent 1a2ec5b commit b8f71e9

File tree

8 files changed

+60
-15
lines changed

8 files changed

+60
-15
lines changed

‎docs/configure.md‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ inputs:
1919
region: ap-guangzhou # 云函数所在区域
2020
name: asw-demo
2121
definition: ./workflow.json
22+
roleArn: qcs::cam::uin/100015854621:roleName/asw-demo_test
2223
chineseName: chineseName
2324
description: This is asw demo.
2425
type: STANDARD
25-
role: asw-role
2626
enableCls: false
2727
input: '{"key":"value"}'
2828
```
@@ -33,14 +33,14 @@ inputs:
3333
3434
| 参数名称 | 必选 | 类型 | 默认值 | 描述 |
3535
| ----------- | :--: | :---------- | :---------------------: | :----------------------------------------- |
36-
| region | 否 | string | `ap-guangzhou` | 工作流所在区域 |
3736
| src | 是 | [Src](#Src) | | 指定当前需要上传的包含工作流配置文件的目录 |
3837
| name | 是 | string | | 工作流名称 |
3938
| definition | 是 | string | | 工作流配置 json 文件路径,或者 JSON 字符串 |
39+
| roleArn | 是 | string | | 运行角色 RoleArn |
40+
| region | 否 | string | `ap-guangzhou` | 工作流所在区域 |
4041
| chineseName | 否 | string | `serverless` | 中文名称 |
4142
| description | 否 | string | `Created By Serverless` | 备注 |
4243
| type | 否 | string | `STANDARD` | 工作流类型 |
43-
| role | 否 | string | | 运行角色,如果不配置,会自动创建 |
4444
| enableCls | 否 | boolean | `false` | 是否启动日志投递 |
4545
| input | 否 | string | `''` | 默认运行参数 |
4646

@@ -50,8 +50,6 @@ inputs:
5050

5151
通常 `asw` 组件的运行依赖 `SLS_QcsRole` 角色授权操作云端资源,如果需要使用本组件,需要给 `SLS_QcsRole` 角色添加 `QcloudASWFullAccess` 策略。
5252

53-
使用此组件时,用户一般需要配置 `role` 参数,来指定创建的工作流依赖运行的角色,如果不配置该参数,组件会尝试创建符合条件的角色(角色命名规则为 `[工作流名称]_[账号AppId]_[8位随机应为字符]`),但是需要保证 `SLS_QcsRole` 角色含有创建角色策略 `QcloudCamRoleFullAccess`。
54-
5553
## Src
5654

5755
项目代码配置

‎example/serverless.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ inputs:
99
region: ap-guangzhou
1010
name: asw-demo
1111
definition: ./workflow.json
12+
roleArn: qcs::cam::uin/100015854621:roleName/serverless-test-aws
1213
chineseName: chineseName
1314
description: Created By Serverless
1415
input: '{"key":"value"}'
15-
role: asw-role # 请确保角色已经存在

‎scripts/utils.ts‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,58 @@ export function getComponentConfig(version: string): ComponentConfig {
2828
actions: {
2929
deploy: {
3030
definition: 'Deploy',
31+
inputs: {
32+
src: {
33+
type: 'src',
34+
required: true,
35+
description: 'Code path',
36+
},
37+
name: {
38+
type: 'string',
39+
required: true,
40+
description: '工作流名称',
41+
},
42+
definition: {
43+
type: 'string',
44+
required: true,
45+
description: '工作流配置 json 文件路径,或者 JSON 字符串',
46+
},
47+
roleArn: {
48+
type: 'string',
49+
required: true,
50+
description: '运行角色 RoleArn',
51+
},
52+
region: {
53+
type: 'string',
54+
required: false,
55+
description: '工作流所在区域',
56+
},
57+
chineseName: {
58+
type: 'string',
59+
required: false,
60+
description: '中文名称',
61+
},
62+
description: {
63+
type: 'string',
64+
required: false,
65+
description: '备注',
66+
},
67+
type: {
68+
type: 'string',
69+
required: false,
70+
description: '工作流类型',
71+
},
72+
enableCls: {
73+
type: 'boolean',
74+
required: false,
75+
description: '是否启动日志投递',
76+
},
77+
input: {
78+
type: 'string',
79+
required: false,
80+
description: '默认运行参数',
81+
},
82+
},
3183
},
3284
remove: {
3385
definition: 'Remove',

‎src/formatter.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,12 @@ export const formatInputs = async (inputs: Inputs, instance: Component<State>) =
2525
const newInputs: Inputs = Object.assign(inputs, {
2626
definition: definition,
2727
name: inputs.name,
28-
role: inputs.role||instance.state.roleName,
28+
roleArn: inputs.roleArn,
2929
type: inputs.type || CONFIGS.type,
3030
chineseName: inputs.chineseName || CONFIGS.chineseName,
3131
description: inputs.description || CONFIGS.description,
3232
enableCls: inputs.enableCls ?? CONFIGS.enableCls,
3333
input: inputs.input,
34-
appId: inputs.appId,
3534
});
3635

3736
return {

‎src/index.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ export class ServerlessComponent extends Component<State> {
3232

3333
const credentials = this.getCredentials();
3434

35-
inputs.appId = this.getAppId();
3635
const { region, newInputs } = await formatInputs(inputs, this);
3736

3837
const asw = new Asw(credentials, region);

‎src/interface/inputs.ts‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@ export interface Inputs {
88
src?: string;
99
definition: string;
1010
name: string;
11-
role?: string;
11+
roleArn: string;
1212
type?: string;
1313
chineseName?: string;
1414
description?: string;
1515
enableCls?: boolean;
1616
input?: string;
1717

18-
appId?: string;
19-
2018
executeName?: string;
2119

2220
srcOriginal?: {

‎src/interface/state.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
export type State = {
22
requestId: string;
33
resourceId: string;
4-
isNewRole: boolean;
5-
roleName: string;
4+
roleArn: string;
65
region?: string;
76
};

‎src/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"dependencies": {
3-
"tencent-component-toolkit": "^2.9.5"
3+
"tencent-component-toolkit": "^2.9.8"
44
}
55
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /