in provisioning_lambda/clients/iot.py [0:0]
def create_policy(self, policy_name, thing_arn, dsn):
client_arn = ':'.join(thing_arn.split(':')[:-1] + ['client/%s' % dsn])
policy_template = {
'Version': '2012-10-17',
'Statement': [
{
'Effect': 'Allow',
'Action': [
'iot:DescribeJobExecution',
'iot:GetPendingJobExecutions',
'iot:UpdateJobExecution',
'iot:StartNextPendingJobExecution',
'iot:DeleteThingShadow',
'iot:UpdateThingShadow',
'iot:GetThingShadow',
],
'Resource': thing_arn,
},
{'Effect': 'Allow', 'Action': 'iot:Connect', 'Resource': client_arn},
],
}
response = self.client.create_policy(policyName=policy_name, policyDocument=json.dumps(policy_template))
self.logger.info('Create policy: %s', policy_name)
return response