in sam/app-decompose-for-parallelism/ctl.py [0:0]
def cmd_create_dashboard(cli_args):
profile = get_parameter('profile')
region = get_parameter('region')
dashboard_json = ''
with open('./dashboards/summary_dashboard.json','r') as file:
dashboard_json = file.read()
# Get data to substitute
metrics_namespace = get_output_value('MetricNamesapce')
dashboard_json = dashboard_json.replace('!!!METRICNAMESPACE!!!',metrics_namespace)
log_group = get_output_value('StateMachineLogGroup')
log_group = log_group.split(':')[6]
dashboard_json = dashboard_json.replace('!!!LOGGROUP!!!',log_group)
dashboard_json = dashboard_json.replace('!!!REGION!!!',region)
try:
boto3.setup_default_session(profile_name=profile,region_name=region)
client = boto3.client('cloudwatch')
client.put_dashboard(
DashboardName='{}Summary-{}'.format(metrics_namespace,region),
DashboardBody=dashboard_json
)
except:
print("Error: Failed to create dashboard: {}".format(sys.exc_info()))
exit()