in source/Lambda/innovation_run_sbx_stack.py [0:0]
def create(event, context):
logger.info(event)
try:
props = event["ResourceProperties"]
mgmt = props['Appstream_Account_ID']
sbx = props['Sandbox_Account_ID']
eip = props['EIP']
eip2 = props['EIP2']
tgw_id = props['Tgw_ID']
tb = props['Template_Base_Path']
credentials_sbx = assume_role(sbx)
s3_public_settings(sbx, credentials_sbx)
logger.info("Running Sandbox Stack")
run_stack(sbx, tb+"InnovationSandboxSbxAccount.template", credentials_sbx, [
{
'ParameterKey': 'TgwID',
'ParameterValue': tgw_id
},
{
'ParameterKey': 'MgmtID',
'ParameterValue': mgmt
},
{
'ParameterKey': 'UUID',
'ParameterValue': str(uuid.uuid4()).replace('-', '')
},
{
'ParameterKey': 'EIP',
'ParameterValue': eip
},
{
'ParameterKey': 'EIP2',
'ParameterValue': eip2
}
], 'InnovationSbxSBXStack')
tgw_sbx_details = get_transit_gateway_id_mgmt(credentials_sbx)
sbx_attach_id = tgw_sbx_details[1]
responseData = {"SBX_Attach_ID": sbx_attach_id}
send(event, context, SUCCESS,
responseData, "Run_Sbx_Setup")
except Exception as e:
message = {'MESSAGE': 'Exception while launching the stack in the Sandbox Account',
'FILE': __file__.split('/')[-1], 'METHOD': inspect.stack()[0][3], 'EXCEPTION': str(e), 'TRACE': traceback.format_exc()}
logger.exception(message)
errorResponseData = {
"Message": "Sandbox Stack Run Failed"
}
send(event, context, FAILED,
errorResponseData, "Run_Sbx_Setup")