Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opensearch Audit Boto Parameter Validation Issue #188

Closed
rpatkialbelli opened this issue Aug 2, 2023 · 1 comment
Closed

Opensearch Audit Boto Parameter Validation Issue #188

rpatkialbelli opened this issue Aug 2, 2023 · 1 comment
Assignees
Labels
bug Something isn't working documentation Improvements or additions to documentation

Comments

@rpatkialbelli
Copy link

Describe the bug
Amazon_ElasticsearchService_Auditor throws errors around parameter validation. Following error is encountered:
botocore.exceptions.ParamValidationError: Parameter validation failed: Invalid type for parameter DomainName, value: {'DomainName': 'unified-logging-es-prod', 'EngineType': 'OpenSearch'}, type: <class 'dict'>, valid types: <class 'str'>"

The error is actually caused by the way the describe_elasticsearch_domain method is called within the describe_es_os_domains function.
The describe_elasticsearch_domain method expects the DomainName parameter to be passed as a string, not as a dictionary. However, in your case, it seems that the domain variable (which is an element in the list returned by elasticsearch.list_domain_names()["DomainNames"]) is a dictionary containing DomainName and EngineType keys.
To resolve the issue, you should modify the describe_es_os_domains function to extract the DomainName string from the domain dictionary before passing it to the describe_elasticsearch_domain method.

The following code change fixes the issue:

def describe_es_os_domains(cache, session):
    response = cache.get("list_domain_names")
    if response:
        return response
    
    elasticsearch = session.client("es")
    domainDetails = []

    for domain in elasticsearch.list_domain_names()["DomainNames"]:
        domainName = domain["DomainName"]
        domainDetails.append(
            elasticsearch.describe_elasticsearch_domain(
                DomainName=domainName
            )
        )

    cache["list_domain_names"] = domainDetails
    return cache["list_domain_names"]

@rpatkialbelli rpatkialbelli added bug Something isn't working documentation Improvements or additions to documentation labels Aug 2, 2023
@jonrau1 jonrau1 self-assigned this Aug 21, 2023
@jonrau1
Copy link
Owner

jonrau1 commented Aug 21, 2023

Damn, rookie skill issue.

Thanks - change committed into the salesforce_v1 branch

@jonrau1 jonrau1 closed this as completed Aug 21, 2023
jonrau1 added a commit that referenced this issue Aug 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants