Skip to content

Latest commit

 

History

History
94 lines (88 loc) · 3.6 KB

File metadata and controls

94 lines (88 loc) · 3.6 KB

Corp2BU

Get Lambda Functions

# awssp
$ACC=$(aws sts get-caller-identity | jq '.Account' | tr -d '"');
aws lambda list-functions | jq -r '.Functions[0:] | {Functions: map({FunctionName: .FunctionName, Description: .Description, Runtime: .Runtime, LastModified: .LastModified, VpcId: .VpcConfig.VpcId, SubnetIds: .VpcConfig.SubnetIds, SecurityGroupIds: .VpcConfig.SecurityGroupIds, EnvVars: .Environment.Variables, Architectures: .Architectures})}' > data/$(aws sts get-caller-identity | jq '.Account' | tr -d '"')_lambda_functions.json

# Automation
# awssp
# CoreTech/Export-CMC-SecOps-Data
aws lambda list-functions | jq -r '.Functions[0:] | {Functions: map({FunctionName: .FunctionName, Description: .Description, Runtime: .Runtime, LastModified: .LastModified, VpcId: .VpcConfig.VpcId, SubnetIds: .VpcConfig.SubnetIds, SecurityGroupIds: .VpcConfig.SecurityGroupIds, EnvVars: .Environment.Variables, Architectures: .Architectures})}' > ../Corp2BU/data/$(aws sts get-caller-identity | jq '.Account' | tr -d '"')_lambda_functions.json
# CoreTech/Export-CMC-SecOps-Data
python __tmp.py --input ../Corp2BU/data/$(aws sts get-caller-identity | jq '.Account' | tr -d '"')_lambda_functions.json

Lambda Function output sample:

{
      "FunctionName": "cct-ops-lambda-iam-access-key-check",
      "FunctionArn": "arn:aws:lambda:us-east-1:670213464448:function:cct-ops-lambda-iam-access-key-check",
      "Runtime": "python3.9",
      "Role": "arn:aws:iam::670213464448:role/ops/default/cct-ops-lambda-iam-access-key-check",
      "Handler": "iam_access_key_check.lambda_handler",
      "CodeSize": 4020,
      "Description": "A Lambda that checks age of access keys in the environment and notifies vpc users via email about needed actions for key change",
      "Timeout": 120,
      "MemorySize": 128,
      "LastModified": "2023-09-14T20:58:30.000+0000",
      "CodeSha256": "VlF0aSlH+mHLvXur3aZDZ/f8Q9aqQCVnvmMnnbGQaus=",
      "Version": "$LATEST",
      "VpcConfig": {
        "SubnetIds": [
          "subnet-a7024cfc",
          "subnet-e58687ac"
        ],
        "SecurityGroupIds": [
          "sg-0338356396751108c"
        ],
        "VpcId": "vpc-65100602"
      },
      "Environment": {
        "Variables": {
          "message_sent_from": "503326142@ge.com",
          "smtp_address": "e2ksmtp01.e2k.ad.ge.com",
          "ENV": "prod",
          "UAI": "UAI3027454"
        }
      },
      "KMSKeyArn": "arn:aws:kms:us-east-1:670213464448:key/bc254f93-1e3c-49a5-90c2-cb49efaef9cb",
      "TracingConfig": {
        "Mode": "PassThrough"
      },
      "RevisionId": "4193641d-08c9-4c60-99a6-aa94878e1fb6",
      "PackageType": "Zip",
      "Architectures": [
        "x86_64"
      ],
      "EphemeralStorage": {
        "Size": 512
      },
      "SnapStart": {
        "ApplyOn": "None",
        "OptimizationStatus": "Off"
      }
}

Extract UAI

Run below in Corp2BU data folder:
In grep -Eio, -E used for extended grep, i for case insensitive match & o to return matched keyword only.

# UAI Extract from EC2 Global View CSV Files
grep -Eio 'uai[0-9]+' $(ls -1 ????????????_ec2*.csv) | sort | uniq -u

# UAI Extract from Lambda Global View JSON Files
grep -Eio 'uai[0-9]+' $(ls -1 ????????????_lambda*.json) | sort | uniq -u

Miscs

Macro to Add side margin to excell table & all of its sheet

Sub AddMargin() 
    Dim r As Range 
    With ActiveSheet.UsedRange 
        .Cells.WrapText = True 
        .Cells.VerticalAlignment = xlCenter 
        .EntireRow.AutoFit 
        For Each r In .Rows 
            r.RowHeight = r.RowHeight + 20   ' Margin value
        Next r 
    End With 
End Sub