sam build runs maven tests
See original GitHub issueDescription
SAM build runs maven tests and fails with Credentials not found error.
Steps to reproduce
-
Run SAM build for a maven backed lambda like below.
/usr/local/bin/sam build --template /private/var/folders/70/307d2nds25b6pq7xthz1mfmw0000gp/T/template6.yaml --build-dir /private/var/folders/70/307d2nds25b6pq7xthz1mfmw0000gp/T/lambdaBuild11 --use-container --skip-pull-image
-
Tests run
-------------------------------------------------------
T E S T S
-------------------------------------------------------
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.mylambda.XTest
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 5.14 sec <<< FAILURE!
- Tests initialize SDK client in code and errors with
"Caused by: com.amazonaws.SdkClientException: Unable to load AWS credentials from any provider in the chain: [EnvironmentVariableCredentialsProvider: Unable to load AWS credentials from environment variables (AWS_ACCESS_KEY_ID (or AWS_ACCESS_KEY) and AWS_SECRET_KEY (or AWS_SECRET_ACCESS_KEY)), SystemPropertiesCredentialsProvider: Unable to load AWS credentials from Java system properties (aws.accessKeyId and aws.secretKey), com.amazonaws.auth.profile.ProfileCredentialsProvider@4362d7df: profile file cannot be null, com.amazonaws.auth.EC2ContainerCredentialsProviderWrapper@21680803: Unable to load credentials from service endpoint]"
Observed result
[INFO] BUILD FAILURE\n[INFO] ------------------------------------------------------------------------\n[INFO] Total time: 01:40 min\n[INFO] Finished at: 2019-04-08T20:09:05Z\n[INFO] ------------------------------------------------------------------------\n[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project project-name: There are test failures.\n[ERROR] \n[ERROR] Please refer to /tmp/samcli/scratch/target/surefire-reports for the individual test results.\n[ERROR] -> [Help 1]\n[ERROR] \n[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.\n[ERROR] Re-run Maven using the -X switch to enable full debug logging.\n[ERROR] \n[ERROR] For more information about the errors and possible solutions, please read the following articles:\n[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException", "code": 400}}
2019-04-08 14:09:06 http://localhost:None "GET /v1.35/containers/bea332c6a58fcf8040ce61bdaf31704d0224f8e511d629fbe963c015ad18feaf/json HTTP/1.1" 200 None
2019-04-08 14:09:06 http://localhost:None "DELETE /v1.35/containers/bea332c6a58fcf8040ce61bdaf31704d0224f8e511d629fbe963c015ad18feaf?v=False&link=False&force=True HTTP/1.1" 204 0
Build Failed
Error: JavaMavenWorkflow:MavenBuild - Maven Failed: [INFO] Scanning for projects...
Expected result
Either maven tests are not run or sam cli passes the credentials info to maven tests
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
- OS: macOs
sam --version
: SAM CLI, version 0.14.2
Issue Analytics
- State:
- Created 4 years ago
- Comments:5
Top Results From Across the Web
sam build runs maven tests · Issue #1105 · aws/aws-sam-cli
SAM build runs maven tests and fails with Credentials not found error. Steps to reproduce. Run SAM build for a maven backed lambda...
Read more >sam build - AWS Serverless Application Model
Build an AWS SAM application using the sam build command from the AWS SAM CLI. ... like locally testing the application or deploying...
Read more >Skip gradle test with aws sam build - Stack Overflow
I have java spring boot gradle project. When I use sam build command it fails because of failing tests. Is there a way...
Read more >Learning AWS SAM: sam build - YouTube
In this video I do an in depth view of the AWS SAM CLI command, sam init. The ` sam build ` command...
Read more >Disable Gralde tests when building projects with SAM
aws sam cloud java gradle. The Serverless Application Model (SAM) allows to easily build, deploy and run serverless applications on AWS.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
having an option like
--skip-build-tests
or similar that would pass to the build tool (in this case maven-DskipTests
would be nice to speed up trial development and debugging for projects with lots of included tests.From the build source here is the location that defines the “JavaMavenWorkflow:MavenBuild” step -> https://github.com/aws/aws-lambda-builders/blob/67f42dd936fd4f0c517c38acb8b6a170156549ec/aws_lambda_builders/workflows/java_maven/maven.py#L27-L34
I’m surprised no-one has yet suggested the following workaround:
You can pass all sorts of flags this way.
You will know it’s working when you see the following in the --debug output