三歩あるけば物も忘れる

お腹のお肉がメタボックル

ユーザ用ツール

サイト用ツール


Miscellaneous:memo

見出しレベル1


$userName = Read-Host -Prompt "Enter the username to register MFA."
$accountId = Read-Host -Prompt "Enter your 12-digit account ID."
$profile = Read-Host -Prompt "Enter the profile name used in the CLI."
$deviceName =  Read-Host -Prompt "Enter the device name to register for MFA."

$outfile = "qrcode.png"
$bootstrapMethod = "QRCodePNG"

aws iam create-virtual-mfa-device `
  --virtual-mfa-device-name ${deviceName} `
  --outfile ${outfile} `
  --bootstrap-method ${bootstrapMethod} `
  --profile ${profile}

$serialNumber = "arn:aws:iam::${accountId}:mfa/${deviceName}"

echo `r`n(Resolve-Path -Path ${outfile}).Path`r`n
echo "Open the above file and read it with Microsoft Authenticator."

$host.UI.RawUI.ReadKey()

$authenticationCode1 = Read-Host -Prompt "Enter the authentication code1."
$authenticationCode2 = Read-Host -Prompt "Enter the authentication code2."

aws iam enable-mfa-device `
  --user-name ${userName} `
  --serial-number ${serialNumber} `
  --authentication-code1 ${authenticationCode1} `
  --authentication-code2 ${authenticationCode2} `
  --profile ${profile}

{
    "version": "0",
    "id": "5d5e771e-e66f-119e-8dbd-16c34c34aa47",
    "detail-type": "AWS Health Event",
    "source": "retry",
    "account": "125901058219",
    "time": "2024-10-21T09:40:12Z",
    "region": "ap-northeast-1",
    "resources": [],
    "detail": {
        "eventArn": "TestEvent"
    }
}

import boto3
import os
client = boto3.client('sns')

def lambda_handler(event, context):
    
    state = event['alarmData']['state']['value']
    alarmName = event['alarmData']['alarmName']
    REGION = "in Asia Pacific (Osaka)"
    
    Subject = state + ' ”' + alarmName + '” ' + REGION

    print(Subject)


{
    "source": "aws.cloudwatch",
    "alarmArn": "arn:aws:cloudwatch:ap-northeast-1:125901058219:alarm:Shige001",
    "accountId": "125901058219",
    "time": "2024-03-25T08:17:49.222+0000",
    "region": "ap-northeast-1",
    "alarmData": {
        "alarmName": "Shige001",
        "state": {
            "value": "ALARM",
            "reason": "Threshold Crossed: 1 out of the last 1 datapoints [1.0 (25/03/24 08:12:00)] was greater than or equal to the threshold (0.0) (minimum 1 datapoint for OK -> ALARM transition).",
            "reasonData": "{\"version\":\"1.0\",\"queryDate\":\"2024-03-25T08:17:49.215+0000\",\"startDate\":\"2024-03-25T08:12:00.000+0000\",\"statistic\":\"Maximum\",\"period\":300,\"recentDatapoints\":[1.0],\"threshold\":0.0,\"evaluatedDatapoints\":[{\"timestamp\":\"2024-03-25T08:12:00.000+0000\",\"sampleCount\":1.0,\"value\":1.0}]}",
            "timestamp": "2024-03-25T08:17:49.222+0000"
        },
        "previousState": {
            "value": "INSUFFICIENT_DATA",
            "reason": "Unchecked: Initial alarm creation",
            "timestamp": "2024-03-25T08:17:24.779+0000"
        },
        "configuration": {
            "metrics": [
                {
                    "id": "a6c73a57-c495-95c1-1ab6-8b2e418dd40c",
                    "metricStat": {
                        "metric": {
                            "namespace": "Namespace1",
                            "name": "MetricName1",
                            "dimensions": {}
                        },
                        "period": 300,
                        "stat": "Maximum"
                    },
                    "returnData": true
                }
            ]
        }
    }
}

コメント

コメントを入力:
B J᠎ W W F
 
Miscellaneous/memo.txt · 最終更新: 2024/10/28 by admin