Skip to content

Distribution: functionAssociations not rendered to Terraform JSON #99

@so0k

Description

@so0k

Bug

The Distribution construct accepts functionAssociations in BehaviorOptions but does not render them to the Terraform JSON output. The property is silently ignored.

Expected behavior

CloudFront Function associations defined via:

defaultBehavior: {
  functionAssociations: [{
    function: myFunction,
    eventType: FunctionEventType.VIEWER_REQUEST,
  }],
}

should produce a function_association block in the synthesized aws_cloudfront_distribution resource.

Actual behavior

The function_association block is missing from the synthesized cdk.tf.json. The _renderDefaultCacheBehavior() method in distribution.js (lines 159-184) does not map functionAssociations to the provider output.

Workaround

(distribution as any).resource.addOverride("default_cache_behavior.function_association", [
  {
    event_type: "viewer-request",
    function_arn: directoryIndexFunction.functionArn,
  },
]);

Version

  • terraconstructs 0.2.3
  • @cdktf/provider-aws latest

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions