terraform-aws-cloudfront
terraform-aws-cloudfront copied to clipboard
origin_access_control_id not implemented
Description
We can only use the legacy origin_access_identity like below:
origin = {
default = {
domain_name = module.web_app.s3_bucket_bucket_regional_domain_name
s3_origin_config = {
origin_access_identity = "web_app"
}
}
}
origin_access_control does not work:
origin = {
default = {
domain_name = module.web_app.s3_bucket_bucket_regional_domain_name
origin_id = module.web_app.s3_bucket_id
origin_access_control_id = aws_cloudfront_origin_access_control.test.id
}
}
This issue has been automatically marked as stale because it has been open 30 days with no activity. Remove stale label or comment or this issue will be closed in 10 days
I can also confirm that its not working as the code states. had to use the next config
origin = { s3_one = { domain_name = "testbucket.s3.eu-west-1.amazonaws.com" origin_id = "s3-my-private-bucket" origin_access_control = "oac" } }
+1 This is not working as intended.
As a workaround (I am not proud of this and it should be thrown in a corner somewhere), you can have the module refer to itself, and manually pass in the origin_access_control_id.
origin_access_control_id = module.this.cloudfront_origin_access_controls_ids[0]
This issue has been automatically marked as stale because it has been open 30 days with no activity. Remove stale label or comment or this issue will be closed in 10 days
There are two ways to achieve the same result:
origin_access_control_id- expects ID of the resource created externally from the module (e.g.E345SXM82MIOSU)origin_access_control- key in theorigin_access_controlargument created by the module.
See this example for more details: https://github.com/terraform-aws-modules/terraform-aws-cloudfront/blob/master/examples/complete/main.tf#L96-L101
The workaround by @Duceswild99 can be like:
origin_access_control = "key_from_origin_access_control" # created by this module
This issue has been automatically marked as stale because it has been open 30 days with no activity. Remove stale label or comment or this issue will be closed in 10 days
This issue was automatically closed because of stale in 10 days
I'm going to lock this issue because it has been closed for 30 days β³. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.