forked from getmoto/moto
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add new elbv2 ssl protocols, add scripts to automatically generate (b…
…ut not insert) them
- Loading branch information
Showing
2 changed files
with
278 additions
and
21 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
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,41 @@ | ||
#!/bin/bash | ||
import json | ||
|
||
import boto3 | ||
import re | ||
|
||
CAMEL_CASE_PATTERN = re.compile(r"(?<!^)(?=[A-Z])") | ||
|
||
KEY_BLACKLIST = ["SupportedLoadBalancerTypes"] | ||
|
||
def camel_case_to_snake_case(name: str): | ||
return CAMEL_CASE_PATTERN.sub("_", name).lower() | ||
|
||
|
||
def get_ssl_elb_ssl_policies(): | ||
elbv2_client = boto3.client("elbv2") | ||
return elbv2_client.describe_ssl_policies()["SslPolicies"] | ||
|
||
|
||
def transform_policies(ssl_policies: dict): | ||
if isinstance(ssl_policies, list): | ||
return [transform_policies(item) for item in ssl_policies] | ||
if not isinstance(ssl_policies, dict): | ||
return ssl_policies | ||
result = {} | ||
for key, value in ssl_policies.items(): | ||
if key in KEY_BLACKLIST: | ||
continue | ||
new_key = camel_case_to_snake_case(key) | ||
result[new_key] = transform_policies(value) | ||
return result | ||
|
||
|
||
def main(): | ||
policies = get_ssl_elb_ssl_policies() | ||
transformed_policies = transform_policies(policies) | ||
print(json.dumps(transformed_policies, indent=4)) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |