-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathACS-RAM-ApproveAttachCustomPolicyToUser.json
258 lines (258 loc) · 9.71 KB
/
ACS-RAM-ApproveAttachCustomPolicyToUser.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
{
"FormatVersion": "OOS-2019-06-01",
"Description": {
"en": "Attach custom policy to user that template executed by after approving",
"zh-cn": "审批通过后授予自定义权限给创建执行的子用户",
"name-en": "ACS-RAM-ApproveAttachCustomPolicyToUser",
"name-zh-cn": "审批通过后授予自定义权限给创建执行的子用户",
"categories": [
"security"
]
},
"Parameters": {
"policyDocument": {
"Label": {
"en": "PolicyDocument",
"zh-cn": "将授权的自定义权限策略的json脚本"
},
"Description": {
"en": "e.g.{ \"Version\": \"1\", \"Statement\": [ { \"Action\": [ \"oos:List*\", \"oos:Get*\" ], \"Resource\": \"*\", \"Effect\": \"Allow\" } ] }",
"zh-cn": "如{ \"Version\": \"1\", \"Statement\": [ { \"Action\": [ \"oos:List*\", \"oos:Get*\" ], \"Resource\": \"*\", \"Effect\": \"Allow\" } ] }"
},
"Type": "String",
"AssociationProperty": "Code"
},
"policyName": {
"Label": {
"en": "PolicyName",
"zh-cn": "将新建并授予的自定义权限策略名称"
},
"Type": "String"
},
"webHookUrl": {
"Label": {
"en": "WebHookUrl",
"zh-cn": "钉钉群助手的webhook地址"
},
"Description": {
"en": "e.g.https://oapi.dingtalk.com/robot/send?access_token=1234zxcvaksdq31414,acquiring DingTalk webhook please refer to second appendix in https://help.aliyun.com/document_detail/144679.html.",
"zh-cn": "形如https://oapi.dingtalk.com/robot/send?access_token=1234zxcvaksdq31414,具体钉钉WebHook获取请参考https://help.aliyun.com/document_detail/144679.html#h2--2-webhook-5。"
},
"Type": "String"
},
"atMobiles": {
"Label": {
"en": "AtMobiles",
"zn-cn": "钉钉手机号"
},
"Description": {
"en": "The dingtalk phone numbers of who be @ in notification,e.g.138ALBB1234",
"zh-cn": "审批通知中被@的群成员的钉钉手机号,比如138ALBB1234"
},
"Type": "List"
},
"atAll": {
"Label": {
"en": "AtAll",
"zh-cn": "是否@所有人"
},
"Description": {
"en": "Whether assistant @ all members in dingtalk group or not notification comes",
"zh-cn": "当群助手向钉钉群中发送审批通知时是否@所有人"
},
"Type": "String",
"Default": "false"
},
"approvers": {
"Label": {
"en": "Approvers",
"zh-cn": "可以审批授权的用户"
},
"Description": {
"en": "The name to fill is the front part of @ in the RAM user name,if RAM user is user001@companyAlias.onaliyun.com, then fill user001 in list",
"zh-cn": "用户名是RAM子用户名称中@前面的部分,比如RAM子用户为user001@companyAlias.onaliyun.com,那么列表中填写user001即可"
},
"Type": "List",
"AssociationProperty": "ALIYUN::RAM::User"
},
"minRequiredApprovals": {
"Label": {
"en": "MinRequiredApprovals",
"zh-cn": "最低需要通过审批的数量"
},
"Type": "Number",
"Default": 1
},
"OOSAssumeRole": {
"Label": {
"en": "OOSAssumeRole",
"zh-cn": "OOS扮演的RAM角色"
},
"Type": "String",
"Default": ""
}
},
"RamRole": "{{ OOSAssumeRole }}",
"Tasks": [
{
"Name": "approveAttachPolicy",
"Action": "ACS::Approve",
"Description": {
"en": "Approve task add policy",
"zh-cn": "审批后授权"
},
"Properties": {
"Approvers": "{{approvers}}",
"MinRequiredApprovals": "{{minRequiredApprovals}}",
"NotifyType": "WebHook",
"WebHook": {
"URI": "{{webhookUrl}}",
"Headers": {
"Content-Type": "application/json"
},
"Content": {
"msgtype": "text",
"text": {
"content": "Notice: Please approve the task execution to attach custom policy {{policyName}}\n{{policyDocument}}\nfor target user {{ACS::ExecuteUser}}.\nsent by {{ACS::RegionId}} oos {{ACS::ExecutionId}}.\n"
},
"at": {
"atMobiles": "{{atMobiles}}",
"isAtAll": "{{atAll}}"
}
}
}
}
},
{
"Name": "checkPolicyExist",
"Action": "ACS::CheckFor",
"Description": {
"en": "Check for the inexistence of policy",
"zh-cn": "判断自定义权限策略名称存在性"
},
"Properties": {
"Service": "RAM",
"API": "GetPolicy",
"Parameters": {
"PolicyType": "Custom",
"PolicyName": "{{ policyName }}"
},
"DesiredValues": [
"true",
"false"
],
"PropertySelector": ".DefaultPolicyVersion != null|tostring"
},
"Outputs": {
"existed": {
"Type": "String",
"ValueSelector": ".DefaultPolicyVersion == null|tostring"
}
}
},
{
"Name": "createStack",
"Action": "ACS::Template",
"When": {
"Fn::Equals": [
"{{ checkPolicyExist.existed }}",
"false"
]
},
"Description": {
"en": "Attach policy by Ros resource stack",
"zh-cn": "通过Ros资源栈为角色授权"
},
"Properties": {
"TemplateName": "ACS::ROS::CreateStack",
"Parameters": {
"stackName": {
"Fn::Replace": [
{
".": "_"
},
"OOS-{{ACS::ExecutionId}}"
]
},
"disableRollback": true,
"parameters": [
{
"ParameterKey": "PolicyType",
"ParameterValue": "Custom"
},
{
"ParameterKey": "UserName",
"ParameterValue": "{{ACS::ExecuteUser}}"
},
{
"ParameterKey": "PolicyName",
"ParameterValue": "{{ policyName }}"
}
],
"templateBody": "{\n \"Parameters\": {\n \"PolicyType\": {\n \"Type\": \"String\",\n \"Description\": \"Authorization policy type. Value: \\\"System\\\" or \\\"Custom\\\".\"\n },\n \"UserName\": {\n \"Type\": \"String\",\n \"Description\": \"User name.\"\n },\n \"PolicyName\": {\n \"Type\": \"String\",\n \"Description\": \"Authorization policy name.\"\n }\n },\n \"ROSTemplateFormatVersion\": \"2015-09-01\",\n \"Outputs\": {},\n \"Resources\": {\n \"AttachPolicyToUser\": {\n \"Type\": \"ALIYUN::RAM::AttachPolicyToUser\",\n \"Properties\": {\n \"PolicyType\": {\n \"Ref\": \"PolicyType\"\n },\n \"UserName\": {\n \"Ref\": \"UserName\"\n },\n \"PolicyName\": {\n \"Ref\": \"PolicyName\"\n }\n }\n }\n }\n}\n"
}
},
"Outputs": {
"stackId": {
"Type": "String",
"ValueSelector": "stackId"
}
}
},
{
"Name": "createStackForNewPolicy",
"Action": "ACS::Template",
"When": {
"Fn::Equals": [
"{{ checkPolicyExist.existed }}",
"true"
]
},
"Description": {
"en": "Attach policy by Ros resource stack when policy is not exist",
"zh-cn": "当policy不存在时,通过Ros资源栈为角色授权"
},
"Properties": {
"TemplateName": "ACS::ROS::CreateStack",
"Parameters": {
"stackName": {
"Fn::Replace": [
{
".": "_"
},
"OOS-{{ACS::ExecutionId}}"
]
},
"disableRollback": true,
"parameters": [
{
"ParameterKey": "PolicyDocument",
"ParameterValue": "{{ policyDocument }}"
},
{
"ParameterKey": "Users",
"ParameterValue": "{{ACS::ExecuteUser}}"
},
{
"ParameterKey": "PolicyName",
"ParameterValue": "{{ policyName }}"
}
],
"templateBody": "{\n \"ROSTemplateFormatVersion\": \"2015-09-01\",\n \"Resources\": {\n \"Policy\": {\n \"Type\": \"ALIYUN::RAM::ManagedPolicy\",\n \"Properties\": {\n \"PolicyName\": {\n \"Ref\": \"PolicyName\"\n },\n \"PolicyDocumentUnchecked\": {\n \"Ref\": \"PolicyDocument\"\n },\n \"Users\": {\n \"Ref\": \"Users\"\n }\n }\n }\n },\n \"Parameters\": {\n \"PolicyName\": {\n \"Type\": \"String\",\n \"Description\": \"Specifies the authorization policy name, containing up to 128 characters.\"\n },\n \"PolicyDocument\": {\n \"Type\": \"Json\",\n \"Description\": \"A policy document that describes what actions are allowed on which resources.\"\n },\n \"Users\": {\n \"Type\": \"CommaDelimitedList\",\n \"Description\": \"The names of users to attach to this policy.\"\n }\n },\n \"Outputs\": {\n \"PolicyName\": {\n \"Description\": \"When the logical ID of this resource is provided to the Ref intrinsic function, Ref returns the ARN.\",\n \"Value\": {\n \"Fn::GetAtt\": [\n \"Policy\",\n \"PolicyName\"\n ]\n }\n }\n },\n \"Metadata\": {\n \"ALIYUN::ROS::Interface\": {\n \"TemplateTags\": [\n \"acs:integrate:oos:ram_approve_attach_custom_policy_to_user\"\n ]\n }\n }\n}\n"
}
},
"Outputs": {
"stackId": {
"Type": "String",
"ValueSelector": "stackId"
}
}
}
],
"Outputs": {
"stackId": {
"Type": "String",
"Value": "{{createStack.stackId}}"
}
}
}