Given a valid config, create a domain.

    Returns {created: true} if the domain was created and returns
    {created: False} if the domain was not created.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_elasticsearch_domain.create mydomain \\
              {'InstanceType': 't2.micro.elasticsearch', 'InstanceCount': 1, \\
              'DedicatedMasterEnabled': false, 'ZoneAwarenessEnabled': false} \\
              {'EBSEnabled': true, 'VolumeType': 'gp2', 'VolumeSize': 10, \\
              'Iops': 0} \\
              {"Version": "2012-10-17", "Statement": [{"Effect": "Allow", "Principal": {"AWS": "*"}, "Action": "es:*", \\
               "Resource": "arn:aws:es:us-east-1:111111111111:domain/mydomain/*", \\
               "Condition": {"IpAddress": {"aws:SourceIp": ["127.0.0.1"]}}}]} \\
              {"AutomatedSnapshotStartHour": 0} \\
              {"rest.action.multi.allow_explicit_index": "true"}

def create(DomainName, ElasticsearchClusterConfig=None, EBSOptions=None,
           AccessPolicies=None, SnapshotOptions=None, AdvancedOptions=None,
           region=None, key=None, keyid=None, profile=None,
           ElasticsearchVersion=None):
    '''
    Given a valid config, create a domain.

    Returns {created: true} if the domain was created and returns
    {created: False} if the domain was not created.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_elasticsearch_domain.create mydomain \\
              {'InstanceType': 't2.micro.elasticsearch', 'InstanceCount': 1, \\
              'DedicatedMasterEnabled': false, 'ZoneAwarenessEnabled': false} \\
              {'EBSEnabled': true, 'VolumeType': 'gp2', 'VolumeSize': 10, \\
              'Iops': 0} \\
              {"Version": "2012-10-17", "Statement": [{"Effect": "Allow", "Principal": {"AWS": "*"}, "Action": "es:*", \\
               "Resource": "arn:aws:es:us-east-1:111111111111:domain/mydomain/*", \\
               "Condition": {"IpAddress": {"aws:SourceIp": ["127.0.0.1"]}}}]} \\
              {"AutomatedSnapshotStartHour": 0} \\
              {"rest.action.multi.allow_explicit_index": "true"}
    '''

    try:
        conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
        kwargs = {}
        for k in ('ElasticsearchClusterConfig', 'EBSOptions',
                    'AccessPolicies', 'SnapshotOptions', 'AdvancedOptions',
                    'ElasticsearchVersion'):
            if locals()[k] is not None:
                val = locals()[k]
                if isinstance(val, six.string_types):
                    try:
                        val = salt.utils.json.loads(val)
                    except ValueError as e:
                        return {'updated': False, 'error': 'Error parsing {0}: {1}'.format(k, e.message)}
                kwargs[k] = val
        if 'AccessPolicies' in kwargs:
            kwargs['AccessPolicies'] = salt.utils.json.dumps(kwargs['AccessPolicies'])
        if 'ElasticsearchVersion' in kwargs:
            kwargs['ElasticsearchVersion'] = six.text_type(kwargs['ElasticsearchVersion'])
        domain = conn.create_elasticsearch_domain(DomainName=DomainName, **kwargs)
        if domain and 'DomainStatus' in domain:
            return {'created': True}
        else:
            log.warning('Domain was not created')
            return {'created': False}
    except ClientError as e:
        return {'created': False, 'error': __utils__['boto3.get_error'](e)}