Migration overview
- Update your CloudFront Integration to the latest version that supports JavaScript Agent V4 (2.2.0 or later) using your preferred deployment method.
- Update your CloudFront distribution cache behavior path.
- Verify that the updated integration works.
- Switch from JavaScript Agent V3 to V4 in your application.
Step 1: Update your CloudFront Integration’s Lambda function
Follow the update guide for your deployment method:- CloudFormation:
- If you’ve enabled the automatic updates you should already be using the latest version of the Lambda function.
- Important: Due to recent changes on AWS, you might need to update your Management Lambda function permissions. To do so, follow the CloudFront Management Lambda permissions update guide.
- If you are not using automatic updates, you need to update the Lambda function manually.
- Terraform:
https://yourwebsite.com/FPJS_BEHAVIOR_PATH/status.
Step 2: Update your CloudFront distribution cache behavior path
Depending on your deployment method, you need to update the cache behavior path in your CloudFront distribution in the following ways:The latest version of the Lambda function maintains compatibility with your existing CloudFront
configuration and JavaScript agent v3, but the following CloudFront configuration change is
recommended before upgrading to JavaScript agent v4.
CloudFormation
- Head to your CloudFront distribution in the AWS console.
- Select the Behaviors tab and edit the fpcdn.io behavior.
- Update the Path Pattern from
FPJS_BEHAVIOR_PATH/*toFPJS_BEHAVIOR_PATH*(without the trailing slash): - Save the changes.
- If your behavior path contains more than one segment (e.g.
ore54guier/vbcnkxb654):- Head to the Origins tab and edit the fpcdn.io origin.
- Add a custom header:
- Set Header name to
FPJS_INTEGRATION_PATH_DEPTH. - Set Value to the number of path segments in the behavior path, in our example it’s
2.
- Set Header name to
- Save the changes.
Terraform
Ensure that you’re using our Terraform Module version v2.0.0 or later.
path_pattern from FPJS_BEHAVIOR_PATH/* to FPJS_BEHAVIOR_PATH* (without the trailing slash)
main.tf
ore54guier/vbcnkxb654), you need to count the number of path segments in the behavior path and add the integration_path_depth paramater with value equal to the number of path segments:
main.tf
- Run
terraform planto verify the planned configuration changes. - Run
terraform applyto apply the changes.
Step 3: Update your application to use the JavaScript Agent V4
At this point, you should have CloudFront integration running that will work with both v3 and v4 JavaScript agents. Try using the integration with the V4 agent. For example:JavaScript
Step 4: Switch from JavaScript Agent V3 to V4
At this point, you can start migrating your application to use the new JavaScript Agent V4.JavaScript