0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

AWSコマンド

ひさびさにいじって、忘れていたので忘備録です。

configファイルの中身を見る。

cat ~/.aws/config

plofileをリスティングする。

aws configure list-profiles

S3の中身を表示

 aws s3 ls --recursive s3://バケット名 --summarize --profile <profile名>

バケット名は、以下の名前の下のやつです。
image.png

以下は、S3バケットの中身を./distに同期するコマンドで、異なっているものだけ入れ替える感じ。

aws s3 sync ./dist s3://<BUCKET_NAME> --delete

そして、CoginitoのUserPoolはOIDC準拠のIdPなので、Reactのreact-oidc-contextというライブラリで操作ができるんですね。

IdPの値をとるのに以下のコマンドで、まず、ユーザープールのIdの値をとってきます。
私は、このプロジェクト用のプロファイルがあるので、指定しないとユーザープールが出てきません。

aws cognito-idp list-user-pools --profile <指定のプロファイル> --max-results 20

# 出力
{
    "UserPools": [
        {
            "Id": "ap-northeast-1_*********",
            "Name": "User pool - hogehoge",
            "LambdaConfig": {},
            "LastModifiedDate": "2025-08-31T06:26:51.157000+09:00",
            "CreationDate": "2025-08-31T06:26:51.157000+09:00"
        }
    ]
}

以下のコマンドでIdPをとってこれます。

aws cognito-idp list-user-pool-clients --user-pool-id <↑で出てきたIdの値> --profile <プロファイル名>
# 出力
{
    "UserPoolClients": [
        {
            "ClientId": "3XXkdXXXXXXXXX",
            "UserPoolId": "ap-northeast-1_**********",
            "ClientName": "my-spa-client"
        }
    ]
}

CallBackURLやLogOutURLの取得は、以下。

aws cognito-idp describe-user-pool-client  --user-pool-id <↑↑で出てきたIdの値> --client-id <↑で出てきたIdPの値> --profile <プロファイル名>

# 出力
{
    "UserPoolClient": {
        "UserPoolId": "ap-northeast-1_**********",
        "ClientName": "my-spa-client",
        "ClientId": "3XXkdXXXXXXXXX",
        "LastModifiedDate": "2026-01-17T22:48:50.102000+09:00",
        "CreationDate": "2026-01-17T22:48:50.102000+09:00",
        "RefreshTokenValidity": 30,
        "TokenValidityUnits": {},
        "CallbackURLs": [
            "https://*********.cloudfront.net/"
        ],
        "LogoutURLs": [
            "https://**********.cloudfront.net/"
        ],
        "AllowedOAuthFlows": [
            "code"
        ],
        "AllowedOAuthScopes": [
            "email",
            "openid",
            "profile"
        ],
        "AllowedOAuthFlowsUserPoolClient": true,
        "EnableTokenRevocation": true,
        "EnablePropagateAdditionalUserContextData": false,
        "AuthSessionValidity": 3
    }
}

通常、CognitoのURLは、とくに設定しなければ以下になるんですが、自分で設定する方法を教えてもらったので、追記です。

https://<ap-northeast-1_********>.auth.<region名>.amazoncognito.com
# idPからドメイン名を取得するコマンド
aws cognito-idp describe-user-pool --user-pool-id <ap-northeast-1_********> --query 'UserPool.Domain' --profile <profile名>

# ドメインの設定をするコマンド
aws cognito-idp create-user-pool-domain --user-pool-id <ap-northeast-1_******> --domain <設定したいドメイン名> --profile <profile名>

たぶんこれくらいの情報あれば、接続できるっしょ。
でも、できなかったので、とりあえず今日は、こんくらいで。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?