This file contains hidden or 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
| # Count total EBS based storage in AWS | |
| aws ec2 describe-volumes | jq "[.Volumes[].Size] | add" | |
| # Count total EBS storage with a tag filter | |
| aws ec2 describe-volumes --filters "Name=tag:Name,Values=CloudEndure Volume qjenc" | jq "[.Volumes[].Size] | add" | |
| # Describe instances concisely | |
| aws ec2 describe-instances | jq '[.Reservations | .[] | .Instances | .[] | {InstanceId: .InstanceId, State: .State, SubnetId: .SubnetId, VpcId: .VpcId, Name: (.Tags[]|select(.Key=="Name")|.Value)}]' | |
| # Wait until $instance_id is running and then immediately stop it again | |
| aws ec2 wait instance-running --instance-id $instance_id && aws ec2 stop-instances --instance-id $instance_id | |
| # Get 10th instance in the account |
This file contains hidden or 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
| # Ever wondered which modules are the most popular? Well.. here they are. The top 500 PyPI modules, by download | |
| urllib3, 910195765 | |
| six, 749120890 | |
| botocore, 670113460 | |
| python-dateutil, 629757389 | |
| pip, 629606070 | |
| requests, 626954494 | |
| s3transfer, 595019137 | |
| certifi, 570148733 |
This file contains hidden or 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
| #!/bin/bash -e | |
| # How to use this script: | |
| # 1. Follow these instructions to configure a single AWS account to do initial login with SSO | |
| # https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sso.html | |
| # 2. Export AWS_PROFILE=... and then run "aws sso login" to get an SSO token | |
| # 3. Once signed in with AWS SSO, run this script to automatically list out all the other accounts and roles and add them to your config file | |
| # If you want to filter roles / accounts in the process, or validate config before committing it, you can customise the script to do this. |
This file contains hidden or 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 script will explain how to transfer a file to EC2 using SSM ONLY! | |
| # You will need to have permission to run SSM commands on the target machine and have sudo access as well | |
| # Infos | |
| INSTANCE_ID=i-1234567890 | |
| FILE_NAME=the_file.tar.gz | |
| # Step 1: Run command on machine to install netcat and dump from port to filename | |
| # < Start session |
This file contains hidden or 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
| #!/usr/bin/env zsh | |
| # This script assumes that you store all your charts in a single repo | |
| # under a single folder called charts-folder. It will go back through previous versions | |
| # of the code and upload all of them into your chart registry. | |
| # This script assumes that you have updated the chart version in `Chart.yaml` | |
| # whenever a change has been made in the chart. If this is not the case, you can | |
| # switch off version checking by disabling the check on line 54. |
This file contains hidden or 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 is a powershell script which I wrote to verify that Crowdstrike is installed | |
| # for deployment with Microsoft Intune (Endpoint Manager). | |
| # You can use it for any installer which deploys a windows service, just change the $service_name | |
| # variable from "csagent" to the name of the service. For example, Dropbox for Windows is "DbxSvc". | |
| # Name of the service | |
| $service_name = "csagent" | |
| # Number of retries | |
| $max_attempts = 15 |
This file contains hidden or 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
| # If your pod container doesn't have bash in the path, you might need to replace `bash` with `/bin/bash/`, `/bin/sh` or `/bin/ash`. | |
| # Simple string from the command line - puts the literal text 'AAA' into a new file /tmp/test.txt | |
| echo 'AAA' > kubectl -n MyNamespace exec -ti $my_pod_id -c my-pod-container -- bash -c 'cat - > /tmp/test.txt' | |
| # Copy / inject a file from the local filesystem into a new file in the pod in the remote kubernetes cluster | |
| kubectl -n MyNamespace exec -i $my_pod_id -c my-pod-container -- bash -c 'cat - > /tmp/file.txt' </my/input/file.txt |
This file contains hidden or 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
| # Ah yes, the lovely, undocumented, and not-at-all-irrationally-difficult-to-understand ArgoCD method of chart customisation - plugins... | |
| # If you are struggling to install the "lovely" plugin (or any plugin for that matter) with the ArgoCD Helm chart, this Gist could help you. | |
| # Include this values config file as part of a Helm/Helmfile values argument to include the "lovely" plugin in your ArgoCD deployment. | |
| # "Lovely" includes several popular tools for helm chart management, including the brilliant Helmfile, which itself includes | |
| # "Vals" for secrets management. | |
| --- | |
| argo-cd: | |
| configs: |
This file contains hidden or 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 gist describes how to undelete files in GCS while retaining most of the metadata. | |
| # GCS doesn't seem to use delete markers like AWS. If anyone knows a better way please say so in the comments. | |
| # I couldn't find any examples of how to do this other than in the UI. | |
| # GCS documentation doesn't seem to include instructions for restoring versioned objects in python, but I found | |
| # that this method works. Confusingly they use terms like version, generation, and revision interchangably in | |
| # the documentation. I couldn't understand how object deletion works on versioned buckets. | |
| import tempfile | |
| from google.cloud import storage |
This file contains hidden or 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 script assumes that you are using a router or device which uses NAT and support upnp, | |
| # you are using ip4 and a debian based linux distro (this covers 90% of home networks and raspberry pi). | |
| # Home routers often won't let you expose port 22, so the port is exposed and mapped with upnp. | |
| # Copy the script to your computer, and then edit the variables at the top. | |
| # Then run the script by typing "bash ./home_ssh_server.sh" into the terminal. | |
| ### Variables ### | |
| # This is the public hostname which you will use to connect to your home server. |
NewerOlder