When you say “add source” to the Cloudfront distribution and click on the “Domain Name” field, it lists all of your AWS resources from this account (including ELB). You can just select it.
However, the security group associated with your ELB must allow public access (HTTP / HTTPS, 0.0.0.0/0). This is no less secure, because in any case you want the public to access ELB through cloudfront. The moment you make things available through the CDN is for sharing. Thus, I set up ELB security groups. Open to other offers!
Now for the EC2 security group for ELB: Here you should not allow public access. Instead, only allow access from the ELB security group (you can achieve this by selecting the ELB security group from the list instead of entering the incoming IP address.
Now it can be configured a little differently if the source is S3. Here you do not need to publish a bucket. Instead, restrict access to the bucket using the Bucket policy (without any security groups here), allowing only the access identifier for the source IAM kernel. Learn more here - Serving personal content through CloudFront - Amazon CloudFront
source share