-
Notifications
You must be signed in to change notification settings - Fork 570
Open
Labels
type/cfnissue or feature request related to the cfn packageissue or feature request related to the cfn package
Description
When an error is returned by the lambda wrapped by aws cfn wrapper; the PhysicalResourceID is not included. It was modified recently to include all request types: #76
However, AWS Docs mention PhysicalResourceID is always required. Therefore Cloudformation incorrectly reports the error "Invalid Physical Resource ID" instead of the actual error during resource creation.
Steps to replicate:
Modified the Simple Test Lambda to include an error condition:
package main
import (
"context"
"fmt"
"errors"
"github.com/aws/aws-lambda-go/cfn"
"github.com/aws/aws-lambda-go/lambda"
)
func echoResource(ctx context.Context, event cfn.Event) (physicalResourceID string, data map[string]interface{}, err error) {
v, _ := event.ResourceProperties["Echo"].(string)
if event.RequestType == "Create" {
if v == "ERROR" {
err = errors.New("My Custom Resource Creation Failed")
fmt.Errorf("Error occurred")
return
}
}
data = map[string]interface{} {
"Echo": v,
}
return
}
func main() {
lambda.Start(cfn.LambdaWrap(echoResource))
}
Created simple Cloudformation template to create custom resource:
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: AWS Test
Resources:
TestResource:
Type: "Custom::TestResource"
Properties:
Echo: ERROR
ServiceToken: arn:aws:lambda:us-west-1:xxxxx:function:cfn-test
Observed that the error reported during Stack Creation is incorrect:
The error message reported must be : My Custom Resource Creation Failed
gunjankaphle and mrgrain
Metadata
Metadata
Assignees
Labels
type/cfnissue or feature request related to the cfn packageissue or feature request related to the cfn package