Skip to content

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Sep 17, 2025

This PR implements a complete Serverless Valkey cache solution for MITxOnline as a Redis replacement, addressing the transition requirements outlined in issue #3562.

Key Changes

New ServerlessCache Component

  • Created OLAmazonServerlessCache component with full IAM authentication support
  • Uses Valkey 8.x engine as specified in AWS Serverless ElastiCache requirements
  • Implements proper validation for cache names, subnet limits (max 3), and configuration parameters
  • Replaces traditional auth token authentication with IAM-based access

MITxOnline Integration

  • Integrated serverless cache alongside existing Redis infrastructure (additive approach)
  • Created ElastiCache IAM user (mitxonline-app-{env_suffix}) with full access permissions
  • Established ElastiCache user group (mitxonline-usergroup-{env_suffix}) for proper authentication
  • Updated IAM policies to include ElastiCache permissions: Connect, DescribeServerlessCaches, DescribeUsers, DescribeUserGroups

Authentication Architecture

The implementation addresses the IAM authentication requirements mentioned in the issue comments:

# Traditional Redis uses auth tokens
redis_cache_config = OLAmazonRedisConfig(
    auth_token=redis_config.require("password"),
    # ...
)

# Serverless cache uses IAM authentication
serverless_cache_config = OLAmazonServerlessCacheConfig(
    user_group_id=elasticache_user_group.user_group_id,
    # No auth_token needed
)

Exports and Integration Points

Added comprehensive exports for application configuration:

  • serverless_cache_endpoint - Primary write endpoint for applications
  • serverless_cache_reader_endpoint - Read replica endpoint for read operations
  • serverless_cache_arn - Full ARN for resource references and policies
  • serverless_cache_user_id / serverless_cache_user_group_id - IAM authentication credentials

Testing

  • Comprehensive test suite for OLAmazonServerlessCacheConfig validation
  • Tests cache name constraints, length validation, and configuration defaults
  • Ensures proper error handling for invalid configurations

Technical Implementation Details

The serverless cache configuration handles AWS-specific constraints:

  • Uses subnet_ids[:3] due to AWS 3-subnet maximum for serverless caches
  • Implements proper Pulumi Output dependency handling for IAM policy generation
  • Maintains backward compatibility with existing Redis infrastructure

This implementation provides the foundation for transitioning MITxOnline from traditional Redis to Serverless Valkey while maintaining the existing infrastructure during the migration period.

Fixes #3562.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@Copilot Copilot AI assigned Copilot and feoh Sep 17, 2025
Copy link
Author

Copilot AI commented Sep 17, 2025

@feoh 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

Copilot AI and others added 3 commits September 17, 2025 21:24
Co-authored-by: feoh <330070+feoh@users.noreply.github.com>
…cies

Co-authored-by: feoh <330070+feoh@users.noreply.github.com>
Co-authored-by: feoh <330070+feoh@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Transition MITxOnline to Serveless Valkey as Redis Replacement Implement Serverless Valkey cache with IAM authentication for MITxOnline Sep 17, 2025
@Copilot Copilot AI requested a review from feoh September 17, 2025 21:30
Copilot finished work on behalf of feoh September 17, 2025 21:30
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.

Transition MITxOnline to Serveless Valkey as Redis Replacement
2 participants