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
#!/usr/bin/env zsh | |
# aws-multi-role.zsh | |
# Usage: ./aws-multi-role.zsh <env> | |
# Example: ./aws-multi-role.zsh preprod | |
set -euo pipefail | |
# --- 1. prerequisites -------------------------------------------------------- | |
# verify jq is installed (for JSON parsing) | |
if ! command -v jq >/dev/null; then |
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
1. Basic Syntax | |
• Comments: | |
Use # for single-line comments and triple quotes ("""...""" or '''...''') for multi-line strings or docstrings. | |
# This is a single-line comment | |
""" | |
This is a multi-line comment or docstring. | |
Useful for module or function documentation. | |
""" |
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
fields @timestamp, @message | |
| parse @message " * * * * * * * * * * * * * * *" as version, account_id, interface_id, srcAddr, dstAddr, srcPort, dstPort, protocol, packets, bytes, start_time, end_time, action, log_status | |
| limit 10 |
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
fields @message | |
| parse @message " * * * * * * * * * * * * * * *" as version, account_id, interface_id, srcAddr, dstAddr, srcPort, dstPort, protocol, packets, bytes, start_time, end_time, action, log_status | |
| filter dstPort = 25 or dstPort = 465 | |
| filter dstAddr in ["10.39.132.10", "10.39.133.138", "10.39.132.97", "10.39.133.151"] | |
| limit 10000 |
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
DIR_PATH=$(pwd | sed 's%^.*account-build%account-build%g') | |
AWS_SHORT_ACCOUNT_ID=$(echo ${DIR_PATH} | /bin/awk -F "/" '{print $2}') | |
APPACC_ID=$( cat account-variables.tf | tr '\n' ' ' | sed -e 's/.*variable[ \t]*"account-id"[ \t]*{[ \t]*default = "\([0-9]*\)"[ \t]*}.*/\1/g' ) | |
STACKNAME=$(basename "${DIR_PATH}") | |
AWS_ACCOUNT_NUMBER=$(aws sts get-caller-identity --query 'Account' --output text) | |
S3_CF_BUCKET="${AWS_ACCOUNT_NUMBER}-config" | |
CORRECT_ACC_FLAG="false" | |
ACCOUNT_TYPE=$( cat account-variables.tf | grep account-type | awk -F '"' '{print tolower($4)}' ) | |
ROLE_NAME=$(aws sts get-caller-identity | jq '.Arn' | awk -F "/" '{ print $2 }') | |
APPACC_NAME=$(cat account-variables.tf | grep account-shortname | awk -F '"' '{print tolower($4)}') |
NewerOlder