Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aws-apprunner-alpha: redesign Service construct to unify Source.fromEcr() and Source.fromEcrPublic() methods #33013

Open
1 task
garysassano opened this issue Jan 19, 2025 · 2 comments
Labels
@aws-cdk/aws-apprunner Related to the apprunner package effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p3

Comments

@garysassano
Copy link

Describe the bug

The current design of the Service construct in aws-apprunner-alpha has significant inconsistencies, particularly between Source.fromEcr and Source.fromEcrPublic. This issue proposes a redesign to unify these methods into a single interface, dynamically determining the repository type (public or private) using regex. For context, see the related issue: #32974

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Version

No response

Expected Behavior

see above

Current Behavior

see above

Reproduction Steps

see above

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.176.0

Framework Version

No response

Node.js Version

22.12.0

OS

Ubuntu 24.04.1

Language

TypeScript

Language Version

No response

Other information

No response

@garysassano garysassano added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jan 19, 2025
@github-actions github-actions bot added the @aws-cdk/aws-apprunner Related to the apprunner package label Jan 19, 2025
@garysassano garysassano changed the title aws-apprunner-alpha: redesign Service construct to unify Source.fromEcr and Source.fromEcrPublic Methods aws-apprunner-alpha: redesign Service construct to unify Source.fromEcr() and Source.fromEcrPublic() methods Jan 19, 2025
@pahud
Copy link
Contributor

pahud commented Jan 21, 2025

Hi @garysassano

I read your comment. The reason is ECR and ECR Public are actually two different services and I agree we should add validations when necessary. I am not sure if unifying them into a single method/interface would be a good idea as they are not just the difference in URI but ECR requires more authorization than ECR Public and absolutely we can programmatically control that. Given this is still an alpha module, we welcome any PRs or high level API samples that allows the team to get more insights to move this forward. wdyt? I am making this a FR.

@pahud pahud added effort/medium Medium work item – several days of effort p3 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. feature-request A feature should be added or improved. and removed needs-triage This issue or PR still needs to be triaged. bug This issue is a bug. labels Jan 21, 2025
@garysassano
Copy link
Author

Hi @pahud

Thanks for the response and for acknowledging the need for validation. If the separation between ECR and ECR_PUBLIC must remain, I'd suggest setting this distinction directly at the Service level rather than at the Source level. By doing so, you could eliminate props like accessRole for ECR_PUBLIC entirely if they're not needed, rather than allowing them to be specified and then silently ignored. This would prevent confusion and improve the developer experience.

Even with the separation, the interface should be streamlined. It's inconsistent to use repository (an IRepository) + tagDigest (a string) for ECR repositories but imageIdentifier (a string) for ECR_PUBLIC repositories. A unified way to specifying the Docker image would simplify the construct significantly.

The approach could mirror how constructs like HealthCheck work. For example, you can define a health check using HealthCheck.http or HealthCheck.tcp:

healthCheck: HealthCheck.http({
  path: "/health",
  healthyThreshold: 1,
  unhealthyThreshold: 5,
}),

healthCheck: HealthCheck.tcp({
  healthyThreshold: 1,
  unhealthyThreshold: 5,
}),

Note that HealthCheck.http doesn't have a path prop.

In the same way, you could have Service.ecr and Service.ecr_public to make the API more intuitive and consistent.

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-apprunner Related to the apprunner package effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p3
Projects
None yet
Development

No branches or pull requests

2 participants