quickstart-amazon-eks-cluster-resource-provider icon indicating copy to clipboard operation
quickstart-amazon-eks-cluster-resource-provider copied to clipboard

runtime error: invalid memory address or nil pointer dereference

Open wesleywh opened this issue 3 years ago • 8 comments

This doesn't work:

aws cloudformation create-stack \
  --stack-name awsqs-eks-cluster-resource \
  --capabilities CAPABILITY_NAMED_IAM \
  --template-url https://s3.amazonaws.com/aws-quickstart/quickstart-amazon-eks-cluster-resource-provider/deploy.template.yaml \
  --region us-west-2 \
  --parameters ParameterKey=CreateClusterAccessRole,ParameterValue='true'

It produces an error in lambda that I had to find in the cloudwatch logs:

botocore.errorfactory.CFNRegistryException: An error occurred (CFNRegistryException) when calling the RegisterType operation: Error validating schemaHandlerPackage. Check the permissions on the bucket and object in your account and try again.

So I copied the zip file to my account's bucket and gave the execution role s3:GetObject permissions. Then I executed the lambda again and I get an Internal Error on registering it.

Next I tried downloading the raw code, unzipping it, navigating to the root directory of the unzipped file, and running the following:

cfn submit -v --region us-west-2 --set-default --role-arn <arn of previously created execution role> --endpoint-url https://cloudformation.us-west-2.amazonaws.com

The rpdk.log file shows the following:

[2020-08-18T17:01:23Z] DEBUG    - Logging set up successfully
[2020-08-18T17:01:23Z] DEBUG    - Running submit: Namespace(command=<function submit at 0x7ff9cfc31290>, dry_run=False, endpoint_url='https://cloudformation.us-west-2.amazonaws.com', region='us-west-2', role_arn='arn:aws:iam::427615184843:role/resoucetype/eks/xva-nonprod-cloudformation-ekscluster-executionrole', set_default=True, subparser_name='submit', use_role=True, verbose=1, version=False)
[2020-08-18T17:01:23Z] DEBUG    - Root directory: <path_to_dir>/cfn-eks-cluster
[2020-08-18T17:01:23Z] DEBUG    - Loading project file '<path_to_dir>/cfn-eks-cluster/.rpdk-config'
[2020-08-18T17:01:23Z] INFO     - Validating your resource schema...
[2020-08-18T17:01:23Z] DEBUG    - Rewriting refs in '<BASE>' (file:///<path_to_dir>/cfn-eks-cluster/awsqs-eks-cluster.json)
[2020-08-18T17:01:23Z] DEBUG    - overrides.json not found. Not writing to package.
[2020-08-18T17:01:23Z] DEBUG    - inputs not found. Not writing to package.
[2020-08-18T17:01:23Z] INFO     - Packaging Go project
[2020-08-18T17:01:23Z] DEBUG    - No Go executable match
[2020-08-18T17:01:23Z] DEBUG    - Caught exit recommendation
Traceback (most recent call last):
  File "<path_to_home>/.local/lib/python3.7/site-packages/rpdk/core/cli.py", line 98, in main
    args.command(args)
  File "<path_to_home>/.local/lib/python3.7/site-packages/rpdk/core/submit.py", line 21, in submit
    args.set_default,
  File "<path_to_home>/.local/lib/python3.7/site-packages/rpdk/core/project.py", line 352, in submit
    self._plugin.package(self, zip_file)
  File "<path_to_home>/.local/lib/python3.7/site-packages/rpdk/go/codegen.py", line 242, in package
    self._find_exe(project)
  File "<path_to_home>/.local/lib/python3.7/site-packages/rpdk/go/codegen.py", line 218, in _find_exe
    "No Go executable was found.\n"
rpdk.go.codegen.GoExecutableNotFoundError: No Go executable was found.
Please run 'make' or the equivalent command in your IDE to compile and package the code.
[2020-08-18T17:01:23Z] CRITICAL - No Go executable was found.
Please run 'make' or the equivalent command in your IDE to compile and package the code.

As you see it says "No Go executable found". The above command made a MakeFile for me, so I ran the make command and it outputs the following into my console:

cfn generate
Generated files for AWSQS::EKS::Cluster
env GOOS=linux go build -ldflags="-s -w" -tags="logging" -o bin/handler cmd/main.go
go build: when using gccgo toolchain, please pass linker flags using -gccgoflags, not -ldflags
# github.com/aws-cloudformation/cloudformation-cli-go-plugin/cfn/encoding
../../go/pkg/mod/github.com/jaymccon/[email protected]/cfn/encoding/stringify.go:88:10: error: reference to undefined field or method ‘IsZero’
   88 |      if v.IsZero() {
      |          ^
make: *** [Makefile:5: build] Error 2

This is where the error is coming from: https://github.com/jaymccon/cloudformation-cli-go-plugin/blob/master/cfn/encoding/stringify.go#L88

Needless to say, this has issues. I'm resorting to looking through your code to find the mentioned error to see if I can fix it. Otherwise please let me know what I'm doing wrong.

Note: I did try running go build as well with the exact same results as make.

wesleywh avatar Aug 18 '20 17:08 wesleywh