mirror of
https://github.com/FreeRTOS/FreeRTOS.git
synced 2025-06-15 20:38:04 +08:00

This adds aws_config_offline, which allows the user to download demo_config.h for the MQTT Mutual Auth Demo using a webpage. This also adds aws_config_quick_start, which provides a means to generate demo_config.h for the Mutual Auth Demo with boto3.
28 lines
767 B
Python
28 lines
767 B
Python
#!/usr/bin/env python
|
|
|
|
import boto3
|
|
import json
|
|
|
|
|
|
class Policy():
|
|
def __init__(self, name, policy=''):
|
|
self.name = name
|
|
self.policy = policy
|
|
self.client = boto3.client('iot')
|
|
|
|
def create(self):
|
|
assert not self.exists(), "Policy already exists"
|
|
self.client.create_policy(policyName=self.name,
|
|
policyDocument=self.policy)
|
|
|
|
def delete(self):
|
|
assert self.exists(), "Policy does not exist, cannot be deleted"
|
|
self.client.delete_policy(policyName=self.name)
|
|
|
|
def exists(self):
|
|
policies = self.client.list_policies()['policies']
|
|
for policy in policies:
|
|
if self.name == policy['policyName']:
|
|
return True
|
|
return False
|