community.aws icon indicating copy to clipboard operation
community.aws copied to clipboard

cloudfront_functions

Open nick-zh opened this issue 4 years ago • 2 comments
trafficstars

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

nick-zh avatar Oct 10 '21 09:10 nick-zh

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.

click here for bot help

ansibullbot avatar Oct 10 '21 10:10 ansibullbot

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 }}

shawnbot avatar Aug 22 '23 19:08 shawnbot