Skip to content

CDK Resource Naming Improvements #29

@hakanson

Description

@hakanson

Note: As I was reviewing this project, and before I created any pull requests, I wanted to create a tracking issue on this topics. Much of the content was assisted by AI analysis using Kiro IDE.

Overview

The current CDK stack (app.py) uses generic names for many resources that don't clearly convey their functionality. This issue tracks recommended naming improvements to make the infrastructure more maintainable and easier to understand.

Benefits

  • Improved code readability and maintainability
  • Easier troubleshooting in AWS Console
  • Better CloudWatch dashboard clarity
  • Self-documenting infrastructure code
  • Reduced onboarding time for new developers

Recommended Changes

S3 Resources

Current Name Recommended Name Reasoning
pdfaccessibilitybucket1 pdf-remediation-processing-bucket Describes the bucket's purpose for PDF remediation workflow

VPC & Networking

Current Name Recommended Name Reasoning
MyVpc PdfProcessingVpc Indicates VPC is for PDF processing workloads
FargateCluster PdfRemediationCluster Clarifies cluster purpose for PDF remediation tasks

IAM Roles

Current Name Recommended Name Reasoning
EcsTaskRole EcsTaskExecutionRole Actually used for task execution (note: appears to be swapped with next one)
EcsTaskExecutionRole PdfProcessingTaskRole Used for actual task permissions (Bedrock, S3, Secrets Manager)

Note: These two roles appear to have reversed names based on their actual usage and policies.

ECS Task Definitions & Containers

Current Name Recommended Name Reasoning
MyFirstTaskDef AdobeAutotagTaskDefinition Describes Adobe PDF autotag and extraction functionality
MySecondTaskDef AltTextGenerationTaskDefinition Describes LLM-based alt-text generation functionality
python_container adobe-autotag-container Clarifies container runs Adobe autotag Python code
javascript_container alt-text-llm-container Clarifies container generates alt-text using LLM
PythonImage AdobeAutotagImage Describes the Docker image purpose
JavaScriptImage AltTextGeneratorImage Describes the Docker image purpose

Log Groups

Current Name Recommended Name Reasoning
PythonContainerLogGroup AdobeAutotagContainerLogs Matches container functionality
JavaScriptContainerLogGroup AltTextGeneratorContainerLogs Matches container functionality
StepFunctionLogs PdfRemediationWorkflowLogs Describes the workflow being logged

Step Functions Tasks

Current Name Recommended Name Reasoning
ECS RunTask RunAdobeAutotagTask Describes the Adobe autotag processing step
ECS RunTask (1) RunAltTextGenerationTask Describes the alt-text generation step
Map ProcessPdfChunksInParallel Describes parallel chunk processing
ParallelState ParallelAccessibilityWorkflow Describes parallel pre/post-check workflow

Lambda Functions

Current Name Recommended Name Reasoning
JavaLambda PdfMergerLambda Describes PDF merging functionality
AddTitleLambda BedrockTitleGeneratorLambda Clarifies it uses Bedrock to generate titles
SplitPDF PdfChunkSplitterLambda Describes PDF splitting into chunks
accessibility_checker_before_remidiation PreRemediationAccessibilityAuditor Clearer pre-processing audit purpose (also fixes typo: remediation)
accessibility_checker_after_remidiation PostRemediationAccessibilityAuditor Clearer post-processing audit purpose (also fixes typo: remediation)

Step Functions Lambda Tasks

Current Name Recommended Name Reasoning
Invoke Java Lambda MergePdfChunks Describes the merge operation
Invoke Add Title Lambda GenerateAccessibleTitle Describes title generation for accessibility
a11y_precheck AuditPreRemediationAccessibility More descriptive pre-remediation audit
a11y_postcheck AuditPostRemediationAccessibility More descriptive post-remediation audit

State Machine

Current Name Recommended Name Reasoning
MyStateMachine PdfAccessibilityRemediationWorkflow Describes the complete remediation workflow

CloudWatch Dashboard

Current Name Recommended Name Reasoning
PDF_Processing_Dashboard PdfRemediationMonitoringDashboard More specific about monitoring remediation workflow

Additional Issues Found

Typos

  • "remidiation" should be "remediation" throughout the codebase
    • Affects Lambda function names and task names
    • Found in: accessibility_checker_before_remidiation, accessibility_checker_after_remidiation

Role Name Confusion

The IAM roles EcsTaskRole and EcsTaskExecutionRole appear to have their purposes reversed:

  • EcsTaskRole is assigned as the execution role
  • EcsTaskExecutionRole is assigned as the task role and has Bedrock/S3/Secrets Manager permissions

This should be corrected to match AWS naming conventions.

Implementation Notes

  1. Breaking Changes: Renaming resources will create new resources and potentially orphan old ones. Plan for a migration strategy.
  2. Log Group Names: Some log groups use hardcoded paths (e.g., /ecs/MyFirstTaskDef/PythonContainerLogGroup) that should be updated to match new names.
  3. Environment Variables: Ensure any environment variables referencing resource names are updated.
  4. CloudWatch Queries: Dashboard queries reference log group names that will need updating.
  5. Documentation: Update any documentation that references the old resource names.

Acceptance Criteria

  • All resources renamed according to recommendations
  • Typo "remidiation" corrected to "remediation"
  • IAM role names and assignments corrected
  • Log group paths updated to match new resource names
  • CloudWatch dashboard queries updated
  • CDK deployment succeeds without errors
  • Existing functionality verified after deployment
  • Documentation updated with new resource names

Priority

Medium - While the current names are functional, improved naming will significantly enhance maintainability and reduce confusion for developers working with the infrastructure.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions