-
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.
- Loading branch information
1 parent
7348dc7
commit a09342d
Showing
14 changed files
with
227 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "6759997c-519b-49e6-97c4-d286c178ac92", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import json\n", | ||
"from pathlib import Path\n", | ||
"\n", | ||
"%run -i /notebooks/helper/aws.py\n", | ||
"%run -i /notebooks/helper/aws_functions.py\n", | ||
"aws_ctx = await aws_connect(\n", | ||
" profiles=[\n", | ||
" \"prod\",\n", | ||
" ],\n", | ||
" regions=[\n", | ||
" \"us-east-1\",\n", | ||
" \"us-west-1\",\n", | ||
" \"ca-central-1\",\n", | ||
" \"eu-west-1\",\n", | ||
" \"eu-west-2\",\n", | ||
" \"eu-central-1\",\n", | ||
" \"ap-southeast-2\",\n", | ||
" ],\n", | ||
" svc_include=[\n", | ||
" \"ec2\",\n", | ||
" ],\n", | ||
")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "0e3275ad-4fcb-449e-904a-0e3c678e9fe9", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"def get_volume_data(aws_ctx_obj, acct, region):\n", | ||
" print(f\"Waiting on data from {acct}/{region}\")\n", | ||
" volumes = retrieve_all_pages(aws_ctx_obj[acct][region][\"ec2\"], \"describe_volumes\").get(\"Volumes\", [])\n", | ||
" print(f\" - Picked up data from {acct}/{region}\")\n", | ||
" return dict(volumes=volumes)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "8383e9aa-5ea7-4070-9b6f-b824508728e8", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"all_ec2_volumes = perform_aws_operations(aws_ctx, get_volume_data)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "56491e10-9233-40f3-9e69-380931fc84b1", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"all_volumes = [{\"Account\": acct, \"Region\": reg_name, **vol} \n", | ||
" for acct, reg_dict in all_ec2_volumes.items() \n", | ||
" for reg_name, volumes in reg_dict.items() \n", | ||
" for vol, volume_list in volumes.items()\n", | ||
" for vol in volume_list]\n", | ||
"total_volume_count = len(all_volumes)\n", | ||
"total_volume_count" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "96f7c621-92b6-4e13-9a2f-fb1b5d224dcd", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"sum([v.get(\"Size\") for v in all_volumes])" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "67822ff1-0389-4d5b-8655-e8934ef428f9", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.10.5" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
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,97 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "013a0918-01b9-4ded-810b-c06d7c733e5c", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from IPython.display import display, HTML\n", | ||
"\n", | ||
"%run -i /notebooks/helper/aws.py\n", | ||
"%run -i /notebooks/helper/aws_functions.py\n", | ||
"aws_ctx = await aws_connect(\n", | ||
" profiles=[\n", | ||
" \"sandbox\",\n", | ||
" ],\n", | ||
" regions=[\n", | ||
" \"us-east-1\",\n", | ||
" ],\n", | ||
" svc_include=[\n", | ||
" \"ssm\",\n", | ||
" ],\n", | ||
")\n", | ||
"\n", | ||
"\n", | ||
"def get_all_env_parameters(ssm_client, env_id):\n", | ||
" pager = ssm_client.get_paginator(\"get_parameters_by_path\")\n", | ||
" params_response = pager.paginate(\n", | ||
" Path=f\"/DGC/{env_id}\", Recursive=True\n", | ||
" ).build_full_result()\n", | ||
" env_parameters = params_response.get(\"Parameters\")\n", | ||
" decrypted_env_params = {\n", | ||
" param.get(\"Name\"): ssm_client.get_parameter(\n", | ||
" Name=param.get(\"Name\"), WithDecryption=True\n", | ||
" )\n", | ||
" .get(\"Parameter\", {})\n", | ||
" .get(\"Value\")\n", | ||
" for param in env_parameters\n", | ||
" }\n", | ||
" return decrypted_env_params" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "47d5f3df-bf4e-4cfc-8c27-c860eef0f8f1", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"env_params = get_all_env_parameters(aws_ctx.sandbox.us_east_1.ssm, \"1b3f969e-ed7c-5240-8a89-6ed164defe8e\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "03f9af92-62de-4f54-a74f-3f2f3b1beb78", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"html_src = \"\"\n", | ||
"for name, value in env_params.items():\n", | ||
" html_src += f\"<h4>{name}</h4><div>{value}</div>\"\n", | ||
"display(HTML(html_src))" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "49476bf2-d1dd-4b21-8fc5-c9ddcb3a4fcd", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.10.5" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
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
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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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