cloudformation-cli-go-plugin icon indicating copy to clipboard operation
cloudformation-cli-go-plugin copied to clipboard

Go plugin seems to need different `event.json` file than similar example using Python

Open TobyHFerguson opened this issue 4 years ago • 1 comments

Overview

A python example translated to Go fails, and it appears that this is because of the way that the event file is treated in the Python case vs the Go case.

Details

I took a working example from Writing an AWS CloudFormation Resource Provider in Python: Step by Step and translated the handlers into Go. I left the various events alone, using the ones that worked with python.

I setup my environment as documented in Setting up your environment for developing extensions

However I then got a failure which seems to my inexperienced eye (and some debugging) to be in the handoff of the event from the sam local invoke to the cloudformation-cli-go-plugin:

(cfn-go) bash-5.0$ sam local invoke TestEntrypoint --event events/create.json
Invoking handler (go1.x)
Failed to download a new amazon/aws-sam-cli-emulation-image-go1.x:rapid-1.0.0 image. Invoking with the already downloaded image.
Mounting /Users/tobyferguson/Development/CFN-step-by-step-go/bin as /var/task:ro,delegated inside runtime container
2021/02/25 21:45:58 Handler starting
START RequestId: 39e6a5ec-2557-1956-f123-a2eb92eef0f3 Version: $LATEST
Validation: Failed Validation
caused by: Region: zero value, BearerToken: zero value: baseError
null
2021/02/25 21:45:58 Handler received the CREATE action
END RequestId: 39e6a5ec-2557-1956-f123-a2eb92eef0f3
REPORT RequestId: 39e6a5ec-2557-1956-f123-a2eb92eef0f3	Init Duration: 192.37 ms	Duration: 5.69 ms	Billed Duration: 100 ms	Memory Size: 256 MB	Max Memory Used: 24 MB	

{"errorType":"baseError","errorMessage":"Validation: Failed Validation\ncaused by: Region: zero value, BearerToken: zero value"}

I'm not (yet) sure if this is a sam issue, or a cloudformation-cli-go-plugin issue but, given that this works with python and not with Go, I am going to start with the Go plugin!

The code and test case are on the master branch of my public repo CFN-step-by-step-go.

Follow the instructions there to generate an event file (it contains private keys, so is not copied here), and use it in to reproduce the issue.

TobyHFerguson avatar Mar 09 '21 04:03 TobyHFerguson

Hi Tony, Did you ever get this resolved? I'm having the same error trying to debug a custom resource

--Scott@AWS

skellish-aws avatar Jul 26 '21 20:07 skellish-aws