Skip to content

Create initial public access logic/datamanager CLI#607

Merged
forstmeier merged 1 commit intomasterfrom
07-14-create_initial_public_access_logic_datamanager_cli
Jul 15, 2025
Merged

Create initial public access logic/datamanager CLI#607
forstmeier merged 1 commit intomasterfrom
07-14-create_initial_public_access_logic_datamanager_cli

Conversation

@forstmeier
Copy link
Copy Markdown
Collaborator

@forstmeier forstmeier commented Jul 14, 2025

Overview

Changes

  • add ALB and associated resource for public access
  • build datamanager CLI for example usage
  • add "authorize" Mise command

Comments

Basically, the Mise command authorizes the local AWS user to make requests against the public endpoint. The CLI is more for example purposes but could be repurposed as a tool for workflows or something. This has not yet been tested fully.

Summary by CodeRabbit

  • New Features

    • Introduced a command-line tool for interacting with the financial data API, supporting health checks, metrics retrieval, and equity bar data operations with AWS authentication.
    • Added infrastructure to expose the datamanager service securely via an authenticated API Gateway fronted by an Application Load Balancer (ALB).
    • Provided a task to authorize CLI access using AWS credentials.
  • Chores

    • Added new dependencies and configuration files for CLI and infrastructure components.
    • Registered the CLI as a workspace member for unified project management.

Copilot AI review requested due to automatic review settings July 14, 2025 18:10
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jul 14, 2025

Walkthrough

This update introduces a new CLI tool for interacting with a secured financial data API, adds infrastructure code for deploying an ALB and authenticated API Gateway, and updates configuration files to support these features. New Pulumi functions and tasks are included for managing ingress, API access policies, and workspace dependencies.

Changes

File(s) Change Summary
.mise.toml Added a new task cli:datamanager:authorize for AWS CLI authorization.
cli/datamanager.py New CLI tool for signed requests to financial data API endpoints with AWS authentication.
cli/pyproject.toml Added project metadata and dependencies for the CLI tool.
infrastructure/__main__.py Integrated ALB controller, ingress, API Gateway with authentication, and Pulumi stack outputs.
infrastructure/ingress.py New module: Pulumi constructs for ALB controller, ingress, API Gateway, and IAM policy for API access.
infrastructure/pyproject.toml Added boto3, requests, and botocore as dependencies.
pyproject.toml Registered cli as a workspace member.
application/datamanager/pyproject.toml Reformatted the dev dependency group from multi-line to single-line syntax without changing dependencies.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant API Gateway
    participant ALB
    participant Datamanager Service
    participant AWS IAM

    User->>CLI: Run command (e.g., bars, health, fetch)
    CLI->>AWS IAM: Sign request with credentials
    CLI->>API Gateway: Send signed HTTP request
    API Gateway->>ALB: Forward request (if authorized)
    ALB->>Datamanager Service: Proxy request
    Datamanager Service-->>ALB: Respond with data
    ALB-->>API Gateway: Return response
    API Gateway-->>CLI: Return API response
    CLI-->>User: Display result or error
Loading

Suggested reviewers

  • chrisaddy

Poem

In the warren, code hops anew,
A CLI to fetch what’s true,
ALB and Gateway guard the gate,
Credentials sign, requests don’t wait.
With Pulumi’s wand, the stack grows tall—
Rabbits cheer for APIs for all!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6f2e5b5 and ca5aa31.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (8)
  • .mise.toml (1 hunks)
  • application/datamanager/pyproject.toml (1 hunks)
  • cli/datamanager.py (1 hunks)
  • cli/pyproject.toml (1 hunks)
  • infrastructure/__main__.py (3 hunks)
  • infrastructure/ingress.py (1 hunks)
  • infrastructure/pyproject.toml (1 hunks)
  • pyproject.toml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (8)
  • pyproject.toml
  • infrastructure/pyproject.toml
  • .mise.toml
  • cli/datamanager.py
  • infrastructure/main.py
  • infrastructure/ingress.py
  • cli/pyproject.toml
  • application/datamanager/pyproject.toml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Run Python tests
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Collaborator Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds an initial public access workflow for the datamanager service via a new CLI and infrastructure updates for ALB, ingress, and API Gateway.

  • Include a new cli workspace member and set up its dependencies and CLI commands.
  • Extend infrastructure dependencies and implement ALB controller, service ingress, API Gateway with IAM auth, and access policy.
  • Wire up the Pulumi stack in infrastructure/__main__.py to provision the ingress and export outputs for the CLI, and add a MISE task for CLI authorization.

Reviewed Changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
pyproject.toml Added "cli" to workspace members to include the new CLI project.
infrastructure/pyproject.toml Added boto3, requests, and botocore dependencies for ingress and API Gateway logic.
infrastructure/ingress.py New module implementing ALB controller role, service ingress, API Gateway, and IAM policy.
infrastructure/main.py Registered ALB controller and datamanager ingress/API flows in the Pulumi main stack.
cli/pyproject.toml Defined cli project metadata, pinned Python version, and declared its dependencies.
cli/datamanager.py CLI implementation for health, equity-bars, metrics, and fetch endpoints with SigV4 signing.
.mise.toml Added cli:datamanager:authorize task to attach the generated IAM policy to a user.
Comments suppressed due to low confidence (1)

.mise.toml:112

  • [nitpick] The task templating syntax for --user-name is overly verbose. Simplify to --user-name {{arg("user-name")}} and verify the $ templating for Pulumi output matches MISE's expected syntax.
"""

Comment thread cli/pyproject.toml
Comment thread cli/datamanager.py Outdated
Comment thread cli/datamanager.py Outdated
Comment thread infrastructure/ingress.py Outdated
@graphite-app
Copy link
Copy Markdown

graphite-app Bot commented Jul 14, 2025

Graphite Automations

"Assign author to pull request" took an action on this PR • (07/14/25)

1 assignee was added to this PR based on John Forstmeier's automation.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 7

♻️ Duplicate comments (1)
cli/pyproject.toml (1)

1-10: Well-structured project configuration.

The project setup is consistent with workspace conventions:

  • Python version matches other projects (3.12.10)
  • Dependencies align with infrastructure requirements
  • Standard project metadata structure

Note: The dependency versions should be verified as mentioned in the infrastructure/pyproject.toml review to ensure they're current and secure.

🧹 Nitpick comments (4)
.mise.toml (1)

108-112: LGTM! Good adherence to coding guidelines.

The task properly uses mise for CLI operations as specified in the coding guidelines. The command syntax appears correct for both the mise argument substitution and pulumi stack output reference.

Consider adding error handling to ensure the pulumi stack output exists before attempting to use it:

 [tasks."cli:datamanager:authorize"]
 description = "Authorize the CLI with AWS credentials"
 run = """
+set -e
+cd infrastructure
 aws iam attach-user-policy --user-name {{arg(user-name="user-name")}} --policy-arn $(pulumi stack output DATAMANAGER_API_ACCESS_POLICY_ARN)
 """
cli/datamanager.py (2)

30-33: Remove redundant Content-Type assignment.

The Content-Type header is already set to "application/json" on line 25, making the assignment on line 32 redundant.

     if data:
         request_payload["data"] = json.dumps(data)
-        request_payload["headers"]["Content-Type"] = "application/json"

45-75: Consider adding retry logic for transient failures.

The API interaction functions could benefit from retry logic to handle transient network failures or temporary API issues. Consider using a library like tenacity or urllib3.util.retry for robust retry handling.

Would you like me to generate an implementation with retry logic for these API functions?

infrastructure/ingress.py (1)

202-211: Consider more specific route configuration.

The current route uses ANY /{proxy+} which forwards all methods and paths. Consider defining specific routes for better security and API documentation.

For better API governance, consider creating specific routes:

# Define specific routes for each endpoint
routes = [
    ("GET /health", "AWS_IAM"),
    ("GET /metrics", "AWS_IAM"),
    ("GET /equity-bars", "AWS_IAM"),
    ("POST /equity-bars/fetch", "AWS_IAM"),
]

for route_key, auth_type in routes:
    aws.apigatewayv2.Route(
        resource_name=f"pocketsizefund-{service_name}-route-{route_key.replace(' ', '-').replace('/', '-')}",
        api_id=api.id,
        route_key=route_key,
        target=integration.id.apply(lambda id: f"integrations/{id}"),
        authorization_type=auth_type,
        authorizer_id=authorizer.id,
    )
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ccb49de and 59f308b.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (7)
  • .mise.toml (1 hunks)
  • cli/datamanager.py (1 hunks)
  • cli/pyproject.toml (1 hunks)
  • infrastructure/__main__.py (3 hunks)
  • infrastructure/ingress.py (1 hunks)
  • infrastructure/pyproject.toml (1 hunks)
  • pyproject.toml (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
.mise.toml

Instructions used from:

Sources:
📄 CodeRabbit Inference Engine

  • CLAUDE.md
🧠 Learnings (1)
.mise.toml (1)
Learnt from: CR
PR: pocketsizefund/pocketsizefund#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-13T00:52:51.429Z
Learning: Applies to .mise.toml : Always use mise tasks for running tests, linting, formatting. If there is not a command already present in .mise.toml, suggest creating one.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Run Python tests
🔇 Additional comments (4)
pyproject.toml (1)

14-14: Proper workspace integration.

The addition of "cli" to workspace members correctly integrates the new CLI project into the workspace management system.

infrastructure/__main__.py (3)

4-4: Clean import organization.

The imports are well-organized and only import the necessary functions for the new ingress functionality.

Also applies to: 12-18


53-59: Proper ALB controller setup.

The ALB controller creation follows a logical sequence:

  1. Create the IAM role
  2. Deploy the controller with the role

The dependency chain is correctly established.


181-183: Well-structured Pulumi exports.

The exports provide the necessary outputs for:

  • ALB URL for direct access
  • API Gateway URL for authenticated access
  • Policy ARN for CLI authorization

This aligns well with the .mise.toml task that uses the policy ARN.

Comment thread infrastructure/pyproject.toml Outdated
Comment thread infrastructure/__main__.py
Comment thread cli/datamanager.py Outdated
Comment thread cli/datamanager.py Outdated
Comment thread infrastructure/ingress.py
Comment thread infrastructure/ingress.py
Comment thread infrastructure/ingress.py
@forstmeier forstmeier force-pushed the 07-14-create_initial_public_access_logic_datamanager_cli branch from 59f308b to 6f2e5b5 Compare July 14, 2025 18:43
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

♻️ Duplicate comments (1)
cli/pyproject.toml (1)

4-4: Use a version range instead of exact Python version pinning.

The exact Python version requirement (==3.12.10) is overly restrictive and can prevent users on minor updates from installing the project.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 59f308b and 6f2e5b5.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (8)
  • .mise.toml (1 hunks)
  • application/datamanager/pyproject.toml (1 hunks)
  • cli/datamanager.py (1 hunks)
  • cli/pyproject.toml (1 hunks)
  • infrastructure/__main__.py (3 hunks)
  • infrastructure/ingress.py (1 hunks)
  • infrastructure/pyproject.toml (1 hunks)
  • pyproject.toml (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • application/datamanager/pyproject.toml
🚧 Files skipped from review as they are similar to previous changes (5)
  • pyproject.toml
  • infrastructure/pyproject.toml
  • .mise.toml
  • cli/datamanager.py
  • infrastructure/ingress.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Run Python tests
🔇 Additional comments (6)
cli/pyproject.toml (1)

5-10: Dependencies are well-chosen for CLI functionality.

The selected dependencies align well with the CLI's purpose:

  • requests for HTTP API calls
  • loguru for structured logging
  • boto3/botocore for AWS service interactions and request signing

The minimum version constraints provide good compatibility while allowing updates.

infrastructure/__main__.py (5)

12-18: Import structure is well-organized.

The new imports from the ingress module are logically grouped and provide the necessary functions for ALB controller, API Gateway, and ingress management.


53-59: ALB controller setup follows proper dependency management.

The ALB controller role creation and controller deployment are correctly structured with proper dependencies and resource references.


160-165: Service ingress configuration is properly implemented.

The ingress creation correctly specifies dependencies on both the ALB controller and the datamanager service, ensuring proper deployment order.


176-179: IAM policy creation follows least-privilege principles.

The API access policy creation is properly scoped to the specific API Gateway and service, which is good for security.


181-183: Pulumi exports provide necessary integration points.

The exported values (ALB URL, API Gateway URL, and IAM policy ARN) are appropriate for CLI integration and the authorize command functionality mentioned in the PR objectives.

Comment thread infrastructure/__main__.py Outdated
Comment thread infrastructure/__main__.py
@forstmeier forstmeier force-pushed the 07-14-create_initial_public_access_logic_datamanager_cli branch from 6f2e5b5 to ca5aa31 Compare July 14, 2025 19:00
@forstmeier forstmeier merged commit 28f5384 into master Jul 15, 2025
4 checks passed
@forstmeier forstmeier deleted the 07-14-create_initial_public_access_logic_datamanager_cli branch July 15, 2025 00:31
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.

3 participants