Skip to content

user service#1

Closed
woodsxwu wants to merge 1 commit intomainfrom
feature/user-service
Closed

user service#1
woodsxwu wants to merge 1 commit intomainfrom
feature/user-service

Conversation

@woodsxwu
Copy link
Copy Markdown
Collaborator

@woodsxwu woodsxwu commented Nov 5, 2025

Updated the user service and basic infrastructure of the project.

@PCBZ PCBZ requested a review from Copilot November 5, 2025 22:41
Copy link
Copy Markdown

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

This PR establishes shared AWS infrastructure using Terraform and implements a user service as the first microservice. The infrastructure includes VPC, networking, Application Load Balancer, and RDS PostgreSQL, along with a complete Go-based user service with ECS deployment and auto-scaling capabilities.

  • Sets up core shared infrastructure (VPC, ALB, RDS PostgreSQL) in modular Terraform
  • Implements user-service with CRUD operations, database schema initialization, and containerized deployment
  • Adds test data generation scripts and team coordination documentation

Reviewed Changes

Copilot reviewed 38 out of 40 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
terraform/*.tf Root-level shared infrastructure configuration including variables, provider, and module orchestration
terraform/modules/network/main.tf VPC, subnets, NAT gateways, route tables, and ALB security group definitions
terraform/modules/alb/main.tf Shared Application Load Balancer with default 404 listener
terraform/modules/rds/main.tf RDS PostgreSQL instance configuration with security group
services/user-service/main.go Go service implementing user CRUD API with database initialization
services/user-service/terraform/*.tf Service-specific infrastructure including ECS, ECR, target groups, and ALB routing
services/user-service/scripts/generate_test_data.py Async Python script for generating test user data via API
TEAM-GUIDE.md Documentation explaining shared vs service-specific infrastructure
.gitignore Comprehensive ignore patterns for Terraform, Docker, and development files

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread terraform/variables.tf
Comment on lines +50 to +55
variable "rds_master_password" {
description = "Master password for RDS PostgreSQL instance"
type = string
sensitive = true
default = "changeme123!"
}
Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

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

Hardcoded default password 'changeme123!' is a security risk. Remove the default value and require this to be provided via environment variable, tfvars file, or AWS Secrets Manager to prevent accidental deployment with weak credentials.

Copilot uses AI. Check for mistakes.
description = "Master password for shared RDS instance"
type = string
sensitive = true
default = "changeme123!"
Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

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

Hardcoded default password 'changeme123!' is a security risk. Remove the default value and require this to be provided via environment variable, tfvars file, or AWS Secrets Manager to prevent accidental deployment with weak credentials.

Suggested change
default = "changeme123!"

Copilot uses AI. Check for mistakes.
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 6.7.0"
Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

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

AWS provider version constraint '> 6.7.0' conflicts with the root terraform configuration which uses '> 5.0'. Use consistent provider versions across all modules. Consider using '~> 5.0' to match the root configuration or update both to use the same major version.

Suggested change
version = "~> 6.7.0"
version = "~> 5.0"

Copilot uses AI. Check for mistakes.
}

if !exists {
createDBQuery := fmt.Sprintf("CREATE DATABASE %s", dbName)
Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

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

SQL injection vulnerability: database name is concatenated directly into SQL query. While dbName comes from environment variables, use identifier quoting with pq.QuoteIdentifier() or validate dbName against a strict pattern (alphanumeric and underscores only) to prevent SQL injection.

Copilot uses AI. Check for mistakes.
}

if !userExists {
createUserQuery := fmt.Sprintf("CREATE USER %s WITH PASSWORD '%s'", serviceUser, masterPassword)
Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

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

SQL injection vulnerability and password exposure: both serviceUser and masterPassword are concatenated directly into SQL query. Use pq.QuoteIdentifier() for the username and parameterized queries or proper escaping for the password. Additionally, the password is logged in plain text in the query string if there's an error.

Copilot uses AI. Check for mistakes.
}

// Grant privileges to the service user
grantQuery := fmt.Sprintf("GRANT ALL PRIVILEGES ON DATABASE %s TO %s", dbName, serviceUser)
Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

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

SQL injection vulnerability: both dbName and serviceUser are concatenated directly into SQL query. Use pq.QuoteIdentifier() for both identifiers to prevent SQL injection.

Copilot uses AI. Check for mistakes.
Comment thread terraform/main.tf
security_group_id = module.network.alb_security_group_id
}

# Shared RDS Aurora Cluster
Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

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

Comment says 'Shared RDS Aurora Cluster' but the actual implementation in modules/rds/main.tf creates a single RDS PostgreSQL instance (aws_db_instance), not an Aurora cluster. Update the comment to 'Shared RDS PostgreSQL Instance' to accurately reflect the implementation.

Suggested change
# Shared RDS Aurora Cluster
# Shared RDS PostgreSQL Instance

Copilot uses AI. Check for mistakes.
}

log.Printf("Database schema initialized successfully")
return err
Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

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

Incorrect return value: the function always returns the last error value instead of nil on success. Change to 'return nil' since any actual error would have been returned earlier at line 192.

Suggested change
return err
return nil

Copilot uses AI. Check for mistakes.
import asyncio
import aiohttp
import argparse
import json
Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

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

Import of 'json' is not used.

Suggested change
import json

Copilot uses AI. Check for mistakes.
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.

2 participants