Skip to content

custom-resources: Custom resource provider framework not passing ResponseURL to user function #21058

@okonos

Description

@okonos

Describe the bug

According to AWS custom resource reference, ResponseURL is a required request field.
The behavior of custom resource provider framework was changed in 2.31.0 to not pass it to user function. It's discussed in #20899.
Without ResponseURL, the provider function fails trying to send the response to CloudFormation.

It works as expected in version 2.30.0.

Expected Behavior

Custom resource should be created without errors.

Current Behavior

Custom resource creation fails with following error (Golang function, the ResponseURL in the event it receives is an empty string):

Received response status [FAILED] from custom resource. Message returned: Error: Put "": unsupported protocol scheme ""

Reproduction Steps

Sample custom resource function from:
https://pkg.go.dev/github.com/aws/aws-lambda-go/cfn#readme-sample-function

import { Stack, StackProps, CustomResource } from 'aws-cdk-lib';
import { Construct } from 'constructs';
import {
    Code,
    Function,
    Runtime,
} from 'aws-cdk-lib/aws-lambda';
import {
    Provider,
} from 'aws-cdk-lib/custom-resources';

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

    const fn = new Function(this, 'MyFunc', {
      runtime: Runtime.GO_1_X,
      memorySize: 256,
      code: Code.fromAsset('build/'),
      handler: 'func',
    });

    const provider = new Provider(this, 'Provider', {
        onEventHandler: fn,
    });

    new CustomResource(this, 'CustomResource', { serviceToken: provider.serviceToken });
  }
}

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.31.0 (build b67950d)

Framework Version

No response

Node.js Version

v16.15.1

OS

Ubuntu

Language

Typescript

Language Version

No response

Other information

No response

Metadata

Metadata

Assignees

Labels

@aws-cdk/custom-resourcesRelated to AWS CDK Custom ResourcesbugThis issue is a bug.effort/smallSmall work item – less than a day of effortp0

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions