'Create a new CloudFormation stack from a template URL supplied as an
environment variable. AWS credentials and CloudFormation parameters are
gathered from an ``acceptance.yml`` style configuration file.'

def _new_stack(self):

    config = extract_substructure_for_test(test_case=self, substructure=dict(aws=dict(access_key=u'<AWS    access    key    ID>', secret_access_token=u'<AWS    secret    access    key>', keyname=u'<AWS    SSH    key    pair    name>', region=u'<AWS    region    code>')), config=acceptance_yaml_for_test(self))
    template_url = os.environ.get('CLOUDFORMATION_TEMPLATE_URL', CLOUDFORMATION_TEMPLATE_URL)
    parameters = [{'ParameterKey': 'EC2KeyPair', 'ParameterValue': config['aws']['keyname']}, {'ParameterKey': 'AmazonAccessKeyID', 'ParameterValue': config['aws']['access_key']}, {'ParameterKey': 'AmazonSecretAccessKey', 'ParameterValue': config['aws']['secret_access_token']}, {'ParameterKey': 'VolumeHubToken', 'ParameterValue': os.environ.get('VOLUMEHUB_TOKEN', '')}, {'ParameterKey': 'S3AccessPolicy', 'ParameterValue': 'Yes'}]
    aws_config = dict(AWS_ACCESS_KEY_ID=config['aws']['access_key'], AWS_SECRET_ACCESS_KEY=config['aws']['secret_access_token'], AWS_DEFAULT_REGION=config['aws']['region'])
    d = create_cloudformation_stack(template_url, parameters, aws_config)
    def set_stack_variables(stack_report):
        outputs = stack_report['Outputs']
        stack_id = stack_report['StackId']
        for (variable_name, stack_output_name) in STACK_VARIABLES.items():
            setattr(self, variable_name, get_output(outputs, stack_output_name))
        if ('KEEP_STACK' not in os.environ):
            self.addCleanup(delete_cloudformation_stack, stack_id, aws_config)
    d.addCallback(set_stack_variables)
    return d
