forked from Netflix/consoleme
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Principal IAM Resolver OSS logic (Netflix#94)
* Principal IAM Resolver OSS logic * Remove unused code
- Loading branch information
Showing
6 changed files
with
72 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from typing import List | ||
|
||
import boto3 | ||
import ujson as json | ||
|
||
from consoleme.config import config | ||
from consoleme.exceptions.exceptions import MissingConfigurationValue | ||
from consoleme.lib.plugins import get_plugin_by_name | ||
|
||
log = config.get_logger() | ||
stats = get_plugin_by_name(config.get("plugins.metrics"))() | ||
|
||
client = boto3.client("config") | ||
|
||
|
||
def query(query: str) -> List: | ||
resources = [] | ||
configuration_aggregator_name: str = config.get( | ||
"aws_config.configuration_aggregator.name" | ||
) | ||
if not configuration_aggregator_name: | ||
raise MissingConfigurationValue("Invalid configuration for aws_config") | ||
response = client.select_aggregate_resource_config( | ||
Expression=query, | ||
ConfigurationAggregatorName=configuration_aggregator_name, | ||
Limit=100, | ||
) | ||
for r in response.get("Results", []): | ||
resources.append(json.loads(r)) | ||
while response.get("NextToken"): | ||
response = client.select_aggregate_resource_config( | ||
Expression=query, | ||
ConfigurationAggregatorName=configuration_aggregator_name, | ||
Limit=100, | ||
NextToken=response["NextToken"], | ||
) | ||
for r in response.get("Results", []): | ||
resources.append(json.loads(r)) | ||
return resources |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters