This repository has been archived by the owner on Jan 13, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetSnapshotFunction.py
53 lines (38 loc) · 2.26 KB
/
getSnapshotFunction.py
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
import os
from this import d
import datetime
import aws_ConfigValues
import aws_PoliciesInRoles
import suppFunct
from os.path import exists
print("############################################################################################################")
print("This script will create a snapshot of the SEA Guardrails. This snapshot depends of the account you are using")
print("It requires you previously have enter the values for:")
print(" AWS_ACCESS_KEY_ID")
print(" AWS_SECRET_ACCESS_KEY")
print(" AWS_SESSION_TOKEN")
print(" AWS_DEFAULT_REGION")
print("by exporting them into your terminal session")
print("############################################################################################################")
print("The following questions are used to create the name of the output files in the form")
print("YYYMMDD_<type><Role><Config/Policies>_<LicensePlate>_<LZ#>")
print("############################################################################################################")
print("")
def getSnapshot(awsRoleUsed, LicensePlate, LZ):
awsRoleUsedSplit=awsRoleUsed.split("_")
typeDic={"CORE":"core","core":"core", "MASTER":"master","master":"master","WORKLOAD":"workload","workload":"workload"}
type=typeDic[awsRoleUsedSplit[1]]
roleDic={"admin":"Admin","billing":"Billing","developer":"Developer", "readonly":"Readonly","security":"SecurityAudit"}
role=roleDic[awsRoleUsedSplit[2]]
currentDate = datetime.date.today().strftime("%Y%m%d")
resultsConfigFile=currentDate + "_" + type + role + "Config" + "_" + LicensePlate + "_" + "LZ" + LZ + ".json"
resultsPoliciesFile=currentDate + "_" + type + role + "Policies" + "_" + LicensePlate+ "_" + "LZ" + LZ + ".json"
# Notice the folder where we save the results is hardcoded
aws_ConfigValues.awsConfigValues(awsRoleUsed,LicensePlate,"./results/"+resultsConfigFile,LZ)
aws_PoliciesInRoles.awsPoliciesInRoles(awsRoleUsed,LicensePlate,"./results/"+resultsPoliciesFile,LZ)
print("The following files have been created in the results folder:")
print("-" + resultsConfigFile )
print("-" + resultsConfigFile.split(".")[0] + ".html")
print("-" + resultsPoliciesFile )
print("-" + resultsPoliciesFile.split(".")[0] + ".html")
return