Architect's Log

I'm a Cloud Architect. I'm highly motivated to reduce toils with driving DevOps.

GitHub認証にGitHub CLIを利用するには

コマンドラインから GitHub にアクセスする際に、認証する方法は複数あります。

GitHub CLI (gh) を使用しブラウザで認証すると、persnal access token の発行が不要になります。プロトコルは SSH も選べますが、今回は鍵の作成が不要な HTTPS を使用します。

環境

Ubuntu 24.04.3 LTS on WSL

手順

GitHub CLI (gh) をインストールします。

$ sudo apt update
$ sudo apt install gh                                                                                 
$ gh --version
# gh version 2.45.0 (2025-07-18 Ubuntu 2.45.0-1ubuntu0.3)                                                                                                                      ```

gh auth login を実行し、以下のように入力します。ブラウザで提示された URL にアクセスし、認証コードを入力します。

$ gh auth login
? What account do you want to log into? GitHub.com
? What is your preferred protocol for Git operations on this host? HTTPS
? Authenticate Git with your GitHub credentials? Yes
? How would you like to authenticate GitHub CLI? Login with a web browser

gh が Git の credential helper として設定され、今後 git clone 等の際に認証が不要になります。

$ git config --list | grep credential
# credential.https://github.com.helper=
# credential.https://github.com.helper=!/usr/bin/gh auth git-credential
# credential.https://gist.github.com.helper=
# credential.https://gist.github.com.helper=!/usr/bin/gh auth git-credential

参考

https://docs.github.com/ja/authentication/keeping-your-account-and-data-secure/about-authentication-to-github

なぜKMSキーが割り当てられていないエイリアスが存在するのか?

AWS CLI list-aliases のレスポンスに、TargetKeyId フィールドがないエイリアスが含まれていることがあります。

aws kms list-aliases
{
    "Aliases": [
        {
            "AliasName": "alias/aws/codecommit",
            "AliasArn": "arn:aws:kms:ap-northeast-1:xxxxxxxxxxxx:alias/aws/codecommit",
            "TargetKeyId": "xxxx...",
            "CreationDate": "2024-06-17T00:34:07.222000+00:00",
            "LastUpdatedDate": "2024-06-17T00:34:07.222000+00:00"
        },
        {
            "AliasName": "alias/aws/dynamodb",
            "AliasArn": "arn:aws:kms:ap-northeast-1:xxxxxxxxxxxx:alias/aws/dynamodb"
        },
        ...

なぜ、KMSキーが割り当てられていないエイリアスが存在するのか疑問に思い、調べてみました。

続きを読む

LINQPadでユニットテストを書くには?

サマリー

LINQPadはv.6.9からxUnitをサポートしていて、ユニットテストが書けます。

https://www.linqpad.net/LINQPad6.aspx

You can now add xunit test support to your query via new option on the Query menu. This adds the required references, a runner, and a sample test method to get you started. There's also a option on the Query menu Alt+Shift+T to execute all tests.

この記事では、LINQPadでのユニットテストの書き方を説明します。

続きを読む

Terraform作業ディレクトリの容量を節約するには?

問題

ディスク領域不足のアラートが出た。

terraformerのimportを何度も繰り返したせいで、作業ディレクトリ全部にTerrafromのプロバイダープラグインがダウンロードされていたのが原因。

サマリ―

Terraform作業ディレクトリの容量を節約するには、プラグインをキャッシュするとよい。

続きを読む