cloudfront_origins: Built-in lookup for CloudFront VPC origin security group? #33812
Open
1 of 2 tasks
Labels
@aws-cdk/aws-cloudfront-origins
Related to CloudFront Origins for the CDK CloudFront Library
effort/medium
Medium work item – several days of effort
feature-request
A feature should be added or improved.
p2
Describe the feature
It could really help with my user code readability if the pattern mentioned here for looking up the ID of CloudFront's VPC Security Group, could be embedded directly into the
VpcOrigin
construct or elsewhere in one of the CloudFront CDK packages?Use Case
I'm connecting a CloudFront Distribution to an ALB in my VPC using CloudFront VPC Origins, and trying to grant least-privilege ingress access to the ALB's security group via
SecurityGroup.addIngressRule(...)
: Only allowing connections from the CloudFront service.It's great that the CDK docs mention a pattern for looking up CloudFront's generated SG with a Custom Resource (since the alternative EC2 prefix list approach requires you to know the prefix list ID for your specific AWS Region)... But would be better if this pattern could be pushed into the library itself to simplify usage?
Proposed Solution
As I understand (?) the security group is 1/ only generated if/when VPC origin(s) are configured, and 2/ shared between any CloudFront distributions connecting to that VPC.
Some possible places it could be added I can think of include:
Distribution
likevpcOriginSecurityGroupId
(presumably that does a lazy check during synthesis and throws an error if it's referenced when none of the origins in the distribution are VPC Origins?)Other Information
No response
Acknowledgements
CDK version used
2.180.0
Environment details (OS name and version, etc.)
MacOS 15.3
The text was updated successfully, but these errors were encountered: