forked from jeevers/documentation-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscan.py
More file actions
executable file
·37 lines (30 loc) · 972 Bytes
/
scan.py
File metadata and controls
executable file
·37 lines (30 loc) · 972 Bytes
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
#!/usr/bin/env python
# Scans a CloudFormation template file
# Requires "requests" to be installed
import requests
import json
# Please substitute filePath, apiKey, and region
# Cloud Conformity API Key
apiKey="Your Cloud Conformity API Key"
# Path to CloudFormation template file Yaml or JSON file
filePath="Path to CloudFormation template"
# Region in which Cloud Conformity serves your organisation
region="us-west-2"
endpoint = 'https://' + region + '-api.cloudconformity.com'
url = endpoint + '/v1/template-scanner/scan'
headers = {
'Content-Type': 'application/vnd.api+json',
'Authorization': 'ApiKey ' + apiKey
}
contents = open(filePath, 'r').read()
payload = {
'data': {
'attributes': {
'type': 'cloudformation-template',
'contents': contents
}
}
}
print 'Request:\n' + json.dumps(payload, indent=2)
resp = requests.post(url, headers=headers, data=json.dumps(payload))
print 'Response:\n' + json.dumps(resp.json(), indent=2, sort_keys=True)