Skip to content

Instantly share code, notes, and snippets.

View MasahiroKawahara's full-sized avatar

MasahiroKawahara

View GitHub Profile
@MasahiroKawahara
MasahiroKawahara / alias.sh
Last active July 11, 2024 07:02
cfn-all-ss-ou : 全ての Service-managed StackSet の展開先OU(パス形式)を表示 ※委任管理者上で実施
[toplevel]
### Organizations
# 組織のルートIDを表示する
org-root = organizations list-roots --query "Roots[0].Id" --output text --no-paginate
# OU構造をパス形式で出力する
# -- depends on org-root
org-ou-paths =
!f () {
function _oupaths(){
[toplevel]
##### General #####
# アカウント情報を取得する
whoami = sts get-caller-identity
# リージョン名一覧を表示する
ls-regions = ec2 describe-regions --query "Regions[*].[RegionName]" --output text
# アカウント一覧(名前, ID)を表示する
ls-accounts = organizations list-accounts --query "Accounts[].[Name, Id]" --output text
@MasahiroKawahara
MasahiroKawahara / aws_cli_alias.sh
Last active July 14, 2023 06:36
IAM Identity Center のユーザー・グループ操作周りのAWS CLIエイリアス (.aws/cli/alias)
[toplevel]
whoami = sts get-caller-identity
### IAM Identity Center(SSO)
sso-store-id = sso-admin list-instances \
--query "Instances[0].IdentityStoreId" --output text
sso-user-id =
!f() {
store_id="$1"
@MasahiroKawahara
MasahiroKawahara / summarize_diff.py
Last active March 22, 2023 23:44
【ChatGPT】GitHubプルリクエスト作成時に差分内容を要約して自動コメントする仕組みを作ってみた
import os
import sys
import openai
from pathlib import Path
content_path = sys.argv[1]
diff_path = sys.argv[2]
# APIキーの設定
openai.api_key = os.environ.get("OPENAI_API_KEY")
@MasahiroKawahara
MasahiroKawahara / comment-pr-summary-by-chatgpt.yml
Last active March 22, 2023 23:45
【ChatGPT】GitHubプルリクエスト作成時に差分内容を要約して自動コメントする仕組みを作ってみた
name: comment-pr-summary-by-chatgpt
on:
pull_request_target:
types: [ opened, reopened ]
jobs:
comment-pr-summary-by-chatgpt:
runs-on: ubuntu-latest
permissions:
@MasahiroKawahara
MasahiroKawahara / inventory.py
Last active April 11, 2024 06:16
IAM Identity Center 棚卸しスクリプト
import boto3
import logging
import re
from tabulate import tabulate
from datetime import datetime
from operator import itemgetter
from itertools import product
logging.basicConfig(level=logging.INFO)
@MasahiroKawahara
MasahiroKawahara / main.tf
Created September 27, 2022 00:57
EventBridge API Destinationsを使ってGuardDuty検知をBacklogに自動起票してみた
### Provider
provider "aws" {
region = "ap-northeast-1"
}
### Locals
locals {
prefix = "test"
}
@MasahiroKawahara
MasahiroKawahara / terraform.tfvars
Created September 27, 2022 00:56
EventBridge API Destinationsを使ってGuardDuty検知をBacklogに自動起票してみた
backlog_issues_url = "https://xx.backlog.jp/api/v2/issues?apiKey=abcdefghijklmn"
backlog_project_id = "1234567890"
backlog_issue_type_id = "1234567890"
backlog_priority_id = "3"
@MasahiroKawahara
MasahiroKawahara / main.tf
Created September 22, 2022 02:21
AWS Security Hub の検出結果を自動で「通知済み」にする
### Provider
provider "aws" {
region = "ap-northeast-1"
}
### Locals
locals {
prefix = "test"
}
@MasahiroKawahara
MasahiroKawahara / main.tf
Created August 20, 2022 05:03
AWSアカウント名を含めたセキュリティ通知を作ってみる(Organizations)
### Provider
provider "aws" {
region = "ap-northeast-1"
}
### Locals
locals {
prefix = "test"
}