- var_dump: documentation ( source)
- preg_match: documentation ( source)
<?php
$matches = [];
$message = 'Stack:arn:aws:cloudformation:us-west-2:717531488628:stack/magento-env-stage-mounttargets/9f7206d0-3e1e-11e6-941a-50d5ca0184f2 is in CREATE_FAILED state and can not be updated.';
preg_match('/~Stack\[(.+)\] is in ([A-Z_]+) state and can not be updated./', $message, $matches);
var_dump($matches);