question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

(cloudfront): identifier not found

See original GitHub issue

We are using some Cloudfront Functions for our distributions but when we are deploying some changes our pipeline fails because it can not find the cloudfront based on its identifier. The problem is that the identifier that CDK Pipeline has is not correct.

Here’s the error :

Resource handler returned message: "Resource of type 'AWS::CloudFront::Function' with identifier 'eu-west-1mdscicdmdOfficeStaticSiteFunctionC23238D5' was not found." (RequestToken: 04588f89-6822-7f5d-22b2-c5c61f92ba7a, HandlerErrorCode: NotFound)

As you can see AWS CDK tries to find this identifier : eu-west-1mdscicdmdOfficeStaticSiteFunctionC23238D5 While the identifier found on the console is : eu-west-1mdscicdmdsOfficeStaticSiteFunctionC23238D5

Environment

  • CDK CLI Version : 1.115.0
  • Framework Version: 1.115.0
  • Node.js Version: 14
  • OS : Linux
  • Language (Version): Typescript

This is 🐛 Bug Report

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
daxAKAhackermancommented, Aug 13, 2021

Hello 👋

I am also affected by this issue. Here’s a minimal example of code that can be used to replicate the bug. This was tested with 1.118.0 and 1.117.0.

bin/cf-func-fail.ts

#!/usr/bin/env node
import 'source-map-support/register';
import * as cdk from '@aws-cdk/core';
import { CfFuncFailStack } from '../lib/cf-func-fail-stack';

const app = new cdk.App();
new CfFuncFailStack(app, 'CfFuncFailStack', {});

lib/cf-func-fail-stack.ts

import * as cdk from '@aws-cdk/core';
import { CfFuncConstruct } from './constructs/cf-func';

export class CfFuncFailStack extends cdk.Stack {
  constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);

    new CfFuncConstruct(this, 'CfFuncConstruct')
  }
}

lib/constructs/cf-func.ts

import * as cdk from '@aws-cdk/core'
import * as cloudfront from '@aws-cdk/aws-cloudfront'

export class CfFuncConstruct extends cdk.Construct {
  constructor (scope: cdk.Stack, id: string) {
    super(scope, id)

    new cloudfront.Function(this, 'RedirectionCloudFrontFunction', {
      code: cloudfront.FunctionCode.fromFile({
        filePath: 'lib/cloudfront-functions/my_func.js'
      })
    })
  }
}

lib/cloudfront-functions/my_func.js

function handler(event) {
    console.log('test2')
}

The bug is erratic. To replicate it, deploy the stack, modify the javascript function (changing the test2 string is sufficient), and redeploy. If the bug doesn’t occur, change the string again and deploy again (I use npx cdk deploy to deploy).

It takes 2-3 tries, but you eventually get the following error:


8:46:54 AM | UPDATE_FAILED        | AWS::CloudFront::Function | CfFuncConstructRed...ntFunctionF201D1DA
Resource handler returned message: "Resource of type 'AWS::CloudFront::Function' with identifier 'us-east-1CfFuncFaiectionCloudFrontFunctionD10DE1AD' was not found." (RequestToken: 2a405fda-4c21-6cff-0
7d0-32d577fcd481, HandlerErrorCode: NotFound)

There seems to be a mismatch between the resource name that CDK tries to update (us-east-1CfFuncFailectionCloudFrontFunctionD10DE1AD) and the real one (us-east-1CfFuncFaiectionCloudFrontFunctionD10DE1AD)

For now, the workaround is just to try again when it fails, and it will usually work within 1-2 retries.

If you need any more information, let me know!

1reaction
daxAKAhackermancommented, Aug 13, 2021

Yep, this looks like the same issue. The workaround mentioned does seem to fix the problem.

Thank you! I should have looked a bit harder 😅

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting distribution issues - Amazon CloudFront
Make sure that the URL that you're referencing uses the domain name (or CNAME) of your CloudFront distribution, not your Amazon S3 bucket...
Read more >
How do I resolve the error "The request could not be satisfied ...
How do I resolve the error "The request could not be satisfied. Request Blocked" from CloudFront ?
Read more >
aws_cloudfront_distribution | Resources | hashicorp/aws
The WAF Web ACL must exist in the WAF Global (CloudFront) region and the credentials configuring this argument must have waf:GetWebACL permissions assigned....
Read more >
CloudFront distribution origin should be set to S3 or origin ...
Get the ID of the CloudFront CDN distribution you want to remediate, either via the console or CLI: · Save the distribution configuration...
Read more >
Heroku SSL Cloudfront Missing Key-Pair-Id 403 error
This error occurs if you enable Restrict Viewer Access on the cache behavior on the distribution, but you are not actually using CloudFront...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found