Skip to content

Feature/0001 - #4

Merged
Koonosuke merged 2 commits into
mainfrom
feature/0001
Dec 2, 2025
Merged

Koonosuke merged 2 commits into
mainfrom
feature/0001

Conversation

@Koonosuke

Copy link
Copy Markdown
Collaborator

概要

IoTCoreポリシーの追加

その他

@Koonosuke
Koonosuke merged commit 191a07b into main Dec 2, 2025
1 check passed
@github-actions

github-actions Bot commented Dec 2, 2025

Copy link
Copy Markdown

🔗 関連するNotionタスク

状態: 進行中

@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello @Koonosuke, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

このプルリクエストは、AWS IoT Coreとの安全なインタラクションを可能にするためのIAMポリシーを導入します。具体的には、IoTデバイスがAWS IoTに接続し、特定の制御トピックからメッセージを受信し、他のトピックにデータを公開するために必要な最小限の権限を定義しています。これは、AWSハンズオン環境におけるIoTデバイスのセットアップを支援することを目的としています。

Highlights

  • 新規ファイル追加: AWS_Handson_2025/IoTCore/policy.md という新しいファイルが追加されました。
  • AWS IoT Coreポリシーの定義: このファイルには、AWS IoT Coreに接続し、特定のトピックを購読・受信し、広範なトピックに発行するための権限を付与するJSON形式のポリシーが定義されています。
  • プレースホルダーの使用: ポリシー内のリソースARNには、「アカウント ID」と「学籍番号」のプレースホルダーが含まれており、特定の環境に合わせてカスタマイズが必要です。
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

このプルリクエストは、AWS IoT Coreのポリシーを追加するものですね。セキュリティと再利用性を向上させるために、いくつかの改善提案をさせていただきます。具体的には、ハードコードされた値の代わりにポリシー変数を使用すること、プレースホルダーの表記を標準的なものにすること、そしてMarkdownファイルとしての体裁を整えることを提案します。

Comment on lines +1 to +25
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "iot:Connect",
"Resource": "arn:aws:iot:ap-northeast-1:アカウント ID:client/xiao-学籍番号"
},
{
"Effect": "Allow",
"Action": "iot:Subscribe",
"Resource": "arn:aws:iot:ap-northeast-1:アカウント ID:topicfilter/iot/xiao/xiao-学籍番号/control"
},
{
"Effect": "Allow",
"Action": "iot:Receive",
"Resource": "arn:aws:iot:ap-northeast-1:アカウント ID:topic/iot/xiao/xiao-学籍番号/control"
},
{
"Effect": "Allow",
"Action": "iot:Publish",
"Resource": "arn:aws:iot:ap-northeast-1:アカウント ID:topic/iot/xiao/xiao-学籍番号/#"
}
]
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

IoT Coreポリシーについて、セキュリティと再利用性を向上させるための提案です。

  1. ポリシー変数の使用: 現在のポリシーでは、クライアントID (xiao-学籍番号) がハードコードされています。これではデバイスごとにポリシーを作成する必要があり、管理が煩雑になります。代わりに ${iot:ClientId} というポリシー変数を使用することで、単一のポリシーを複数のデバイスで再利用できるようになります。これにより、ポリシーがより汎用的かつ安全になります。

  2. プレースホルダーの標準化: アカウント ID のような日本語のプレースホルダーは、環境によっては意図しない問題を引き起こす可能性があります。<AWS_ACCOUNT_ID> のような英数字の標準的なプレースホルダー表記を使用することをお勧めします。

  3. Markdownとしてのフォーマット: ファイルが .md 拡張子であるため、ドキュメントとして見なされます。JSONコンテンツをコードブロックで囲み、プレースホルダーを置き換える必要がある旨を説明するテキストを追加すると、より分かりやすくなります。

これらの点を考慮した修正案を以下に示します。

このポリシーを適用する前に、`<AWS_ACCOUNT_ID>` をご自身のAWSアカウントIDに置き換えてください。

```json
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": "iot:Connect",
            "Resource": "arn:aws:iot:ap-northeast-1:<AWS_ACCOUNT_ID>:client/${iot:ClientId}"
        },
        {
            "Effect": "Allow",
            "Action": "iot:Subscribe",
            "Resource": "arn:aws:iot:ap-northeast-1:<AWS_ACCOUNT_ID>:topicfilter/iot/xiao/${iot:ClientId}/control"
        },
        {
            "Effect": "Allow",
            "Action": "iot:Receive",
            "Resource": "arn:aws:iot:ap-northeast-1:<AWS_ACCOUNT_ID>:topic/iot/xiao/${iot:ClientId}/control"
        },
        {
            "Effect": "Allow",
            "Action": "iot:Publish",
            "Resource": "arn:aws:iot:ap-northeast-1:<AWS_ACCOUNT_ID>:topic/iot/xiao/${iot:ClientId}/#"
        }
    ]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant