diff --git a/buildspec.yml b/buildspec.yml new file mode 100644 index 0000000..bdf24fb --- /dev/null +++ b/buildspec.yml @@ -0,0 +1,12 @@ +version: 0.2 + +phases: + build: + commands: + - echo Build started on `date` + post_build: + commands: + - echo Build completed on `date` +#artifacts: +# files: +# - hello \ No newline at end of file diff --git a/lib/services/elasticsearchservice.py b/lib/services/elasticsearchservice.py new file mode 100644 index 0000000..4d95ad9 --- /dev/null +++ b/lib/services/elasticsearchservice.py @@ -0,0 +1,34 @@ +import boto3 + +class Elasticsearchservice: + + def __init__(self, region): + self.name = 'elasticsearch' + self.region = region + self.identifiers = [] + self.templates = { + 'identifier': 'Domain', + 'identifier': 'AccountId', + 'cfn-monitor': 'ElasticSearch', + 'cfn-guardian': 'ElasticSearch' + } + self.get_resources() + + def get_resources(self): + try: + client = boto3.client('es', region_name=self.region) + get_domains = client.list_domain_names() + + for item in get_domains['DomainNames']: + account_id = boto3.client("sts").get_caller_identity()["Account"] + self.identifiers.extend([{ + 'id': { + 'Id': account_id, + 'AccountId': account_id, + 'Domain': item['DomainName'] + } + }]) + + except Exception as e: + print('ERROR'.ljust(7) + self.region.ljust(16) + self.name.ljust(19) + str(e), flush=True) + pass \ No newline at end of file