community.aws
community.aws copied to clipboard
cloudfront_functions
Summary
It would be great to have support for cloudfront functions. Right now you can only specify lambdas for viewer requests, etc.
Issue Type
Feature Idea
Component Name
cloudfront_functions
Additional Information
Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
Files identified in the description: None
If these files are inaccurate, please update the component name section of the description or use the !component bot command.
For anyone else blocked by this, I did figure out a workaround for at least the association of existing CloudFront functions with a distribution's cache behavior. The cloudfront_distribution module doesn't validate unrecognized parameters in cache behaviors, so you can pass function_associations to either default_cache_behaviors or one of the cache_behaviors entries. The trick is that you have to conform to the AWS API's FunctionAssociations schema, which involves some awkward YAML:
- name: CloudFront distribution
community.aws.cloudfront_distribution:
# ... distribution config
default_cache_behavior:
# ... cache behavior config
function_associations:
# must match the length of the items list
quantity: 1
items:
# "viewer-request" or "viewer-response"
- event_type: viewer-request
# "function_a_r_n" is transformed to "FunctionARN"
function_a_r_n: arn:aws:cloudfront::{{ aws_account_id }}:function/{{ cf_function_name }}