aws-cloudformation / aws-cloudformation-resource-providers-logs

The CloudFormation Resource Provider Package For Amazon CloudWatch Logs
https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/WhatIsCloudWatchLogs.html
Apache License 2.0
33 stars 35 forks source link

"Credentials must not be null" when testing locally #28

Closed benbridts closed 4 years ago

benbridts commented 4 years ago

I'm trying to get the LogGroup provider working locally, and created a test event to do that (see https://github.com/ikben/aws-cloudformation-resource-providers-logs/blob/try-to-get-things-working/aws-logs-loggroup/sam-tests/delete.json but with the credentials filled).

However, when I run sam local invoke TestEntrypoint --event sam-tests/delete.json I get the following error (there was an earlier error because the handler in template.yaml was wrong, but I fixed that):

{"status":"FAILED","errorCode":"InternalFailure","message":"Credentials must not be null.","callbackDelaySeconds":0}

I am probably doing something wrong, but I can't find what it is. Does the provider need it's own credentials outside of the ones supplied in the event?

Full output:

~$ sam local invoke TestEntrypoint --event sam-tests/delete.json
Invoking software.amazon.logs.loggroup.HandlerWrapper::testEntrypoint (java8)
Decompressing /Users/ben/src/vendor/aws-cloudformation-resource-providers-logs/aws-logs-loggroup/target/aws-logs-loggroup-handler-1.0-SNAPSHOT.jar

Fetching lambci/lambda:java8 Docker container image......
Mounting /private/var/folders/pq/cvfgj3_s0c565_sc9rwywd0w0000gn/T/tmpoh2fn5y6 as /var/task:ro,delegated inside runtime container
START RequestId: 9211bbbd-82c0-1911-5360-628b0a13acdf Version: $LATEST
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[DELETE] invoking handler...Failed to execute remote function: {Credentials must not be null.}java.lang.NullPointerException: Credentials must not be null.
        at software.amazon.awssdk.utils.Validate.paramNotNull(Validate.java:117)
        at software.amazon.awssdk.auth.signer.params.Aws4SignerParams.<init>(Aws4SignerParams.java:42)
        at software.amazon.awssdk.auth.signer.params.Aws4SignerParams$BuilderImpl.build(Aws4SignerParams.java:206)
        at software.amazon.awssdk.auth.signer.internal.BaseAws4Signer.sign(BaseAws4Signer.java:34)
        at software.amazon.awssdk.core.internal.http.pipeline.stages.SigningStage.signRequest(SigningStage.java:63)
        at software.amazon.awssdk.core.internal.http.pipeline.stages.SigningStage.execute(SigningStage.java:49)
        at software.amazon.awssdk.core.internal.http.pipeline.stages.SigningStage.execute(SigningStage.java:35)
        at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:206)
        at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:206)
        at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:206)
        at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:206)
        at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:206)
        at software.amazon.awssdk.core.internal.http.pipeline.stages.ApiCallAttemptTimeoutTrackingStage.execute(ApiCallAttemptTimeoutTrackingStage.java:74)
        at software.amazon.awssdk.core.internal.http.pipeline.stages.ApiCallAttemptTimeoutTrackingStage.execute(ApiCallAttemptTimeoutTrackingStage.java:43)
        at software.amazon.awssdk.core.internal.http.pipeline.stages.TimeoutExceptionHandlingStage.execute(TimeoutExceptionHandlingStage.java:78)
        at software.amazon.awssdk.core.internal.http.pipeline.stages.TimeoutExceptionHandlingStage.execute(TimeoutExceptionHandlingStage.java:40)
        at software.amazon.awssdk.core.internal.http.pipeline.stages.RetryableStage$RetryExecutor.doExecute(RetryableStage.java:114)
        at software.amazon.awssdk.core.internal.http.pipeline.stages.RetryableStage$RetryExecutor.execute(RetryableStage.java:87)
        at software.amazon.awssdk.core.internal.http.pipeline.stages.RetryableStage.execute(RetryableStage.java:63)
        at software.amazon.awssdk.core.internal.http.pipeline.stages.RetryableStage.execute(RetryableStage.java:43)
        at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:206)
        at software.amazon.awssdk.core.internal.http.StreamManagingStage.execute(StreamManagingStage.java:57)
        at software.amazon.awssdk.core.internal.http.StreamManagingStage.execute(StreamManagingStage.java:37)
        at software.amazon.awssdk.core.internal.http.pipeline.stages.ApiCallTimeoutTrackingStage.executeWithTimer(ApiCallTimeoutTrackingStage.java:81)
        at software.amazon.awssdk.core.internal.http.pipeline.stages.ApiCallTimeoutTrackingStage.execute(ApiCallTimeoutTrackingStage.java:61)
        at software.amazon.awssdk.core.internal.http.pipeline.stages.ApiCallTimeoutTrackingStage.execute(ApiCallTimeoutTrackingStage.java:43)
        at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:206)
        at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:206)
        at software.amazon.awssdk.core.internal.http.pipeline.stages.ExecutionFailureExceptionReportingStage.execute(ExecutionFailureExceptionReportingStage.java:37)
        at software.amazon.awssdk.core.internal.http.pipeline.stages.ExecutionFailureExceptionReportingStage.execute(ExecutionFailureExceptionReportingStage.java:26)
        at software.amazon.awssdk.core.internal.http.AmazonSyncHttpClient$RequestExecutionBuilderImpl.execute(AmazonSyncHttpClient.java:198)
        at software.amazon.awssdk.core.internal.handler.BaseSyncClientHandler.invoke(BaseSyncClientHandler.java:122)
        at software.amazon.awssdk.core.internal.handler.BaseSyncClientHandler.doExecute(BaseSyncClientHandler.java:148)
        at software.amazon.awssdk.core.internal.handler.BaseSyncClientHandler.execute(BaseSyncClientHandler.java:102)
        at software.amazon.awssdk.core.client.handler.SdkSyncClientHandler.execute(SdkSyncClientHandler.java:45)
        at software.amazon.awssdk.awscore.client.handler.AwsSyncClientHandler.execute(AwsSyncClientHandler.java:55)
        at software.amazon.awssdk.services.cloudwatchlogs.DefaultCloudWatchLogsClient.deleteLogGroup(DefaultCloudWatchLogsClient.java:603)
        at software.amazon.cloudformation.proxy.AmazonWebServicesClientProxy.injectCredentialsAndInvokeV2(AmazonWebServicesClientProxy.java:328)
        at software.amazon.logs.loggroup.DeleteHandler.handleRequest(DeleteHandler.java:22)
        at software.amazon.logs.loggroup.DeleteHandler.handleRequest(DeleteHandler.java:11)
        at software.amazon.logs.loggroup.HandlerWrapper.invokeHandler(HandlerWrapper.java:76)
        at software.amazon.logs.loggroup.HandlerWrapper.testEntrypoint(HandlerWrapper.java:100)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at lambdainternal.EventHandlerLoader$StreamMethodRequestHandler.handleRequest(EventHandlerLoader.java:354)
        at lambdainternal.EventHandlerLoader$2.call(EventHandlerLoader.java:906)
        at lambdainternal.AWSLambda.startRuntime(AWSLambda.java:341)
        at lambdainternal.AWSLambda.<clinit>(AWSLambda.java:63)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:348)
        at lambdainternal.LambdaRTEntry.main(LambdaRTEntry.java:119)
END RequestId: 9211bbbd-82c0-1911-5360-628b0a13acdf
REPORT RequestId: 9211bbbd-82c0-1911-5360-628b0a13acdf  Init Duration: 2852.11 ms       Duration: 2140.07 ms    Billed Duration: 2200 ms        Memory Size: 128 MB     Max Memory Used: 78 MB  

{"status":"FAILED","errorCode":"InternalFailure","message":"Credentials must not be null.","callbackDelaySeconds":0}
wbingli commented 4 years ago

The problem is because different AWS SDK version between java plugin. This repo uses 2.10.191 but java plugin uses2.10.49`. Ideally there should be not problem between SDK patch version but still it causes unexpected error.

A PR #29 has been submitted to fix this issue.