def create_config_backend_options(module_opts, env_name, env_vars):
    """Return backend options defined in module options."""
    backend_opts = {}

    if module_opts.get('terraform_backend_config'):
        backend_opts['config'] = merge_nested_environment_dicts(
            module_opts.get('terraform_backend_config'),
            env_name
        )
    if module_opts.get('terraform_backend_cfn_outputs'):
        if not backend_opts.get('config'):
            backend_opts['config'] = {}
        if not backend_opts['config'].get('region'):
            backend_opts['config']['region'] = env_vars['AWS_DEFAULT_REGION']

        boto_args = extract_boto_args_from_env(env_vars)
        cfn_client = boto3.client(
            'cloudformation',
            region_name=backend_opts['config']['region'],
            **boto_args
        )
        for (key, val) in merge_nested_environment_dicts(module_opts.get('terraform_backend_cfn_outputs'),  # noqa pylint: disable=line-too-long
                                                         env_name).items():
            backend_opts['config'][key] = find_cfn_output(
                val.split('::')[1],
                cfn_client.describe_stacks(
                    StackName=val.split('::')[0]
                )['Stacks'][0]['Outputs']
            )

    return backend_opts
def create_config_backend_options ( module_opts , env_name , env_vars ) : backend_opts = { } if module_opts . get ( 'terraform_backend_config' ) : backend_opts [ 'config' ] = merge_nested_environment_dicts ( module_opts . get ( 'terraform_backend_config' ) , env_name ) if module_opts . get ( 'terraform_backend_cfn_outputs' ) : if not backend_opts . get ( 'config' ) : backend_opts [ 'config' ] = { } if not backend_opts [ 'config' ] . get ( 'region' ) : backend_opts [ 'config' ] [ 'region' ] = env_vars [ 'AWS_DEFAULT_REGION' ] boto_args = extract_boto_args_from_env ( env_vars ) cfn_client = boto3 . client ( 'cloudformation' , region_name = backend_opts [ 'config' ] [ 'region' ] , ** boto_args ) for ( key , val ) in merge_nested_environment_dicts ( module_opts . get ( 'terraform_backend_cfn_outputs' ) , env_name ) . items ( ) : backend_opts [ 'config' ] [ key ] = find_cfn_output ( val . split ( '::' ) [ 1 ] , cfn_client . describe_stacks ( StackName = val . split ( '::' ) [ 0 ] ) [ 'Stacks' ] [ 0 ] [ 'Outputs' ] ) return backend_opts
Return backend options defined in module options.