Coder Social home page Coder Social logo

aws-sam-java-rest's Introduction

SAM DynamoDB Application for Managing Orders

This is a sample application to demonstrate how to build an application on DynamoDB using the DynamoDBMapper ORM framework to map Order items in a DynamoDB table to a RESTful API for order management.

.
├── README.md                               <-- This instructions file
├── LICENSE.txt                             <-- Apache Software License 2.0
├── NOTICE.txt                              <-- Copyright notices
├── pom.xml                                 <-- Java dependencies, Docker integration test orchestration
├── src
│   ├── main
│   │   └── java
│   │       ├── com.amazonaws.config              <-- Classes to manage Dagger 2 dependency injection
│   │       │   ├── OrderComponent.java           <-- Contains inject methods for handler entrypoints
│   │       │   └── OrderModule.java              <-- Provides dependencies like the DynamoDB client for injection
│   │       ├── com.amazonaws.dao                 <-- Package for DAO objects
│   │       │   └── OrderDao.java                 <-- DAO Wrapper around the DynamoDBTableMapper for Orders
│   │       ├── com.amazonaws.exception           <-- Source code for custom exceptions
│   │       ├── com.amazonaws.handler             <-- Source code for lambda functions
│   │       │   ├── CreateOrderHandler.java       <-- Lambda function code for creating orders
│   │       │   ├── CreateOrdersTableHandler.java <-- Lambda function code for creating the orders table
│   │       │   ├── DeleteOrderHandler.java       <-- Lambda function code for deleting orders
│   │       │   ├── GetOrderHandler.java          <-- Lambda function code for getting one order
│   │       │   ├── GetOrdersHandler.java         <-- Lambda function code for getting a page of orders
│   │       │   └── UpdateOrderHandler.java       <-- Lambda function code for updating an order
│   │       └── com.amazonaws.model               <-- Source code for model classes
│   │           ├── request                       <-- Source code for request model classes
│   │           │   ├── CreateOrderRequest.java      <-- POJO shape for creating an order
│   │           │   ├── GetOrDeleteOrderRequest.java <-- POJO shape for getting or deleting an order
│   │           │   ├── GetOrdersRequest.java        <-- POJO shape for getting a page of orders
│   │           │   └── UpdateOrderRequest.java      <-- POJO shape for updating an order
│   │           ├── response                      <-- Source code for response model classes
│   │           │   ├── GatewayResponse.java         <-- Generic POJO shape for the APIGateway integration
│   │           │   └── GetOrdersResponse.java       <-- POJO shape for a page of orders
│   │           └── Order.java                    <-- POJO for Order resources
│   └── test                                      <-- Unit and integration tests
│       └── java
│           ├── com.amazonaws.config              <-- Classes to manage Dagger 2 dependency injection
│           ├── com.amazonaws.dao                 <-- Tests for OrderDao
│           ├── com.amazonaws.handler             <-- Unit and integration tests for handlers
│           │   ├── CreateOrderHandlerIT.java     <-- Integration tests for creating orders
│           │   ├── CreateOrderHandlerTest.java   <-- Unit tests for creating orders
│           │   ├── DeleteOrderHandlerTest.java   <-- Unit tests for deleting orders
│           │   ├── GetOrderHandlerTest.java      <-- Unit tests for getting one order
│           │   ├── GetOrdersHandlerTest.java     <-- Unit tests for getting a page of orders
│           │   └── UpdateOrderHandlerTest.java   <-- Unit tests for updating an order
│           └── com.amazonaws.services.lambda.runtime <-- Unit and integration tests for handlers
│               └── TestContext.java              <-- Context implementation for use in tests
└── template.yaml                                 <-- Contains SAM API Gateway + Lambda definitions

Requirements

Setup process

Installing dependencies

We use maven to install our dependencies and package our application into a JAR file:

mvn package

Local development

Invoking function locally through local API Gateway

  1. Start DynamoDB Local in a Docker container. docker run -p 8000:8000 amazon/dynamodb-local
  2. Create the DynamoDB table. aws dynamodb create-table --table-name orders_table --attribute-definitions AttributeName=orderId,AttributeType=S --key-schema AttributeName=orderId,KeyType=HASH --billing-mode PAY_PER_REQUEST --endpoint-url http://localhost:8000
  3. Start the SAM local API.
  • On a Mac: sam local start-api --env-vars src/test/resources/test_environment_mac.json
  • On Windows: sam local start-api --env-vars src/test/resources/test_environment_windows.json
  • On Linux: sam local start-api --env-vars src/test/resources/test_environment_linux.json

If the previous command ran successfully you should now be able to hit the following local endpoint to invoke the functions rooted at http://localhost:3000/orders

SAM CLI is used to emulate both Lambda and API Gateway locally and uses our template.yaml to understand how to bootstrap this environment (runtime, where the source code is, etc.) - The following excerpt is what the CLI will read in order to initialize an API and its routes:

...
Events:
    GetOrders:
        Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
        Properties:
            Path: /orders
            Method: get

Packaging and deployment

AWS Lambda Java runtime accepts either a zip file or a standalone JAR file - We use the latter in this example. SAM will use CodeUri property to know where to look up for both application and dependencies:

...
    GetOrdersFunction:
        Type: AWS::Serverless::Function
        Properties:
            CodeUri: target/aws-sam-java-rest-1.0.0.jar
            Handler: com.amazonaws.handler.GetOrdersHandler::handleRequest

Firstly, we need a S3 bucket where we can upload our Lambda functions packaged as ZIP before we deploy anything - If you don't have a S3 bucket to store code artifacts then this is a good time to create one:

export BUCKET_NAME=my_cool_new_bucket
aws s3 mb s3://$BUCKET_NAME

Next, run the following command to package our Lambda function to S3:

sam package \
    --template-file template.yaml \
    --output-template-file packaged.yaml \
    --s3-bucket $BUCKET_NAME

Next, the following command will create a Cloudformation Stack and deploy your SAM resources.

sam deploy \
    --template-file packaged.yaml \
    --stack-name sam-orderHandler \
    --capabilities CAPABILITY_IAM

See Serverless Application Model (SAM) HOWTO Guide for more details in how to get started.

After deployment is complete you can run the following command to retrieve the API Gateway Endpoint URL:

aws cloudformation describe-stacks \
    --stack-name sam-orderHandler \
    --query 'Stacks[].Outputs'

Testing

Running unit tests

We use JUnit for testing our code. Unit tests in this sample package mock out the DynamoDBTableMapper class for Order objects. Unit tests do not require connectivity to a DynamoDB endpoint. You can run unit tests with the following command:

mvn test

Running integration tests

Integration tests in this sample package do not mock out the DynamoDBTableMapper and use a real AmazonDynamoDB client instance. Integration tests require connectivity to a DynamoDB endpoint, and as such the POM starts DynamoDB Local from the Dockerhub repository for integration tests.

mvn verify

Running end to end tests through the SAM CLI Local endpoint

Running the following end-to-end tests requires Python 3 and the requests pip package to be installed. For these tests to succeed,

pip3 install requests
python3 src/test/resources/api_tests.py 3

The number that follows the test script name is the number of orders to create in the test. For these tests to work, you must follow the steps for local development.

Appendix

AWS CLI commands

AWS CLI commands to package, deploy and describe outputs defined within the cloudformation stack:

sam package \
    --template-file template.yaml \
    --output-template-file packaged.yaml \
    --s3-bucket REPLACE_THIS_WITH_YOUR_S3_BUCKET_NAME

sam deploy \
    --template-file packaged.yaml \
    --stack-name sam-orderHandler \
    --capabilities CAPABILITY_IAM \
    --parameter-overrides MyParameterSample=MySampleValue

aws cloudformation describe-stacks \
    --stack-name sam-orderHandler --query 'Stacks[].Outputs'

Bringing to the next level

Next, you can use the following resources to know more about beyond hello world samples and how others structure their Serverless applications:

aws-sam-java-rest's People

Contributors

amcp avatar kasulavamsi avatar khanshariquem avatar mehulkar avatar msailes avatar tebanieo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aws-sam-java-rest's Issues

transactGetItems / transactWriteItems ( ConditionCheck )

I suppose this might not be the correct place to ask for this, but since its the linked example on the page dynamodb-local page I will put it here.

It seems as if the dynamodb-local docker container does not support the ConditionCheck. At least I am getting an "unimplemented" error.

Are there any plans on supporting this?

Build failure

I pulled down this repo, ran mvn package and I see the tests fail:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  4.295 s
[INFO] Finished at: 2019-07-18T14:59:59-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project aws-sam-java-rest: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test failed: The forked VM terminated without saying properly goodbye. VM crash or System.exit called ? -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
Apache Maven 3.6.1 (d66c9c0b3152b2e69ee9bac180bb8fcc8e6af555; 2019-04-04T15:00:29-04:00)
Maven home: /usr/local/Cellar/maven/3.6.1/libexec
Java version: 12.0.1, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/openjdk-12.0.1.jdk/Contents/Home
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.14.5", arch: "x86_64", family: "mac"

Question: Best practice for creating the dynamo table

Hello and thanks for the sample app!

I see that in this project there is an endpoint triggered from a POST request, that attempts to create the dynamodb table. I realize this is just a sample project but I was expecting the table definition to be in the template.yaml file instead of java code and now I wonder if there was a reason for the author to do it this way instead

Dynamo unreachable

Working on Windows 10 I am unable to browse content of database with http://127.0.0.1:3000/orders endpoint due to docker-related networking issues. This is due to endpoints being defined with hostname docker.for.windows.localhost which is no longer domain name used by docker during Docker for Windows installation. Recommended is to use host.docker.internal. This change fixes the issue and provides excellent out-of-the-box experience for fresh install of docker for windows.

[ERROR] Runtime.ImportModuleError: Unable to import module

Hello SAM + LAMBDA users,

I am facing below issue in both Local scenario and after deploying app to aws and hitting test endpoint via API Gateway


Error info :

Steps

  • Build & Start:
sam build --use-container
sam local start-api --env-vars test/sample/integration_test/environment.json
  • curl Get :
curl http://127.0.0.1:3000/sample
  • Getting below error
START RequestId: 156a4eec-0ec1-182f-d06e-04bfce652b1f Version: $LATEST
[ERROR] Runtime.ImportModuleError: Unable to import module 'list_handler': No module named 'src'
END RequestId: 156a4eec-0ec1-182f-d06e-04bfce652b1f
REPORT RequestId: 156a4eec-0ec1-182f-d06e-04bfce652b1f  Init Duration: 537.49 ms    Duration: 4.27 ms   Billed Duration: 100 ms Memory Size: 1024 MB    Max Memory Used: 32 MB  
Lambda returned empty body!
Invalid API Gateway Response Keys: {'errorType', 'errorMessage'} in {'errorType': 'Runtime.ImportModuleError', 'errorMessage': "Unable to import module 'list_handler': No module named 'src'"}
<class 'samcli.local.apigw.local_apigw_service.LambdaResponseParseException'>

SAM :

sam --version
SAM CLI, version 0.48.0

OS: MAC


Details :

  • Project structure:
.
├── README.md
├── api-event.json
├── environment.json
├── events
│   └── event.json
├── src
│   └── sample
│       ├── handler
│       │   ├── create_handler.py
│       │   ├── get_handler.py
│       │   ├── list_handler.py
│       │   ├── requirements.txt
│       └── helper
│           ├── dynamodb_helper.py
│           └── logging_helper.py
├── template.yaml
└── test
    └── sample
        ├── integration_test
        │   ├── api_tests.py
        │   └── environment.json
        ├── test_helper.py
        └── unit_test
  • template.yaml
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
sample-sam-app

  SAM Template for sample-sam-app

Globals:
  Function:
    Timeout: 20
    MemorySize: 1024
    Environment:
      Variables:
        TABLE_NAME: !Ref SampleTable
        APPLICATION_NAME: "SAMPLE"

Resources:
  CreateFunction:
    Type: AWS::Serverless::Function 
    Properties:
      CodeUri: src/sample/handler
      Handler: create_handler.lambda_handler
      Runtime: python3.7
      Policies:
        - DynamoDBCrudPolicy:
            TableName: !Ref SampleTable
      Events:
        Create:
          Type: Api 
          Properties:
            Path: /sample
            Method: post

  GetFunction:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: src/sample/handler
      Handler: get_handler.lambda_handler
      Runtime: python3.7
      Policies:
        - DynamoDBReadPolicy:
            TableName: !Ref SampleTable
      Events:
        Get:
          Type: Api 
          Properties:
            Path: /sample/{data_id}
            Method: get

  ListFunction:
    Type: AWS::Serverless::Function 
    Properties:
      CodeUri: src/sample/handler
      Handler: list_handler.lambda_handler
      Runtime: python3.7
      Policies:
        - DynamoDBReadPolicy:
            TableName: !Ref SampleTable
      Events:
        Get:
          Type: Api 
          Properties:
            Path: /sample
            Method: get

  SampleTable:
    Type: AWS::DynamoDB::Table
    Properties:
      TableName: sample
      AttributeDefinitions:
        - AttributeName: user_id
          AttributeType: S
        - AttributeName: data_id
          AttributeType: S
      KeySchema:
        - AttributeName: user_id
          KeyType: HASH
        - AttributeName: data_id
          KeyType: RANGE
      BillingMode: PAY_PER_REQUEST 

Outputs:
    CreateFunction:
      Description: "Create Lambda Function ARN"
      Value: !GetAtt CreateFunction.Arn

    GetFunction:
      Description: "Get Lambda Function ARN"
      Value: !GetAtt GetFunction.Arn

    ListFunction:
      Description: "List Lambda Function ARN"
      Value: !GetAtt ListFunction.Arn
  • docker doesnt show sam-app :
docker ps

CONTAINER ID        IMAGE                   COMMAND                  CREATED             STATUS              PORTS                    NAMES
2e45a561d2ab        amazon/dynamodb-local   "java -jar DynamoDBL…"   19 minutes ago      Up 19 minutes       0.0.0.0:8000->8000/tcp   romantic_mahavira

Build fails with JaCoCo

Windows 10 OOB execution of mvn package on master results in

Exception in thread "main" java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:513)
at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:525)
Caused by: java.lang.RuntimeException: Class java/lang/UnknownError could not be instrumented.
at org.jacoco.agent.rt.internal_c13123e.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:140)
at org.jacoco.agent.rt.internal_c13123e.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:101)
at org.jacoco.agent.rt.internal_c13123e.PreMain.createRuntime(PreMain.java:55)
at org.jacoco.agent.rt.internal_c13123e.PreMain.premain(PreMain.java:47)
... 6 more
Caused by: java.lang.NoSuchFieldException: $jacocoAccess
at java.base/java.lang.Class.getField(Class.java:1999)
at org.jacoco.agent.rt.internal_c13123e.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:138)
... 9 more
*** java.lang.instrument ASSERTION FAILED ***: "result" with message agent load/premain call failed at line: 422
FATAL ERROR in native method: processing of -javaagent failed, processJavaStart failed

Update from 0.8.1 to latest 0.8.5 fixes the issue.

Connect to 127.0.0.1:8000 [/127.0.0.1] failed: Connection refused (Connection refused)

I tried:
Docker run:

  • docker run -p 8000:8000 amazon/dynamodb-local
  • docker run -p 8000:8000 amazon/dynamodb-local -jar DynamoDBLocal.jar -sharedDb
  • docker run -p 8000:8000 amazon/dynamodb-local -jar DynamoDBLocal.jar -sharedDb -inMemory

and :

  • sam local start-api --env-vars src/test/resources/test_environment_linux.json

And in all cases I got this :

  • App starts normally :
    2019-07-26 15:52:05 Mounting GetOrderFunction at http://127.0.0.1:3000/orders/{order_id} [GET] 2019-07-26 15:52:05 Mounting DeleteOrderFunction at http://127.0.0.1:3000/orders/{order_id} [DELETE] 2019-07-26 15:52:05 Mounting UpdateOrderFunction at http://127.0.0.1:3000/orders/{order_id} [POST] 2019-07-26 15:52:05 Mounting CreateOrderFunction at http://127.0.0.1:3000/orders [POST] 2019-07-26 15:52:05 Mounting GetOrdersFunction at http://127.0.0.1:3000/orders [GET] 2019-07-26 15:52:05 Mounting CreateOrdersTableFunction at http://127.0.0.1:3000/_create_orders_table [POST] 2019-07-26 15:52:05 You can now browse to the above endpoints to invoke your functions. You do not need to restart/reload SAM CLI while working on your functions, changes will be reflected instantly/automatically. You only need to restart SAM CLI if you update your AWS SAM template 2019-07-26 15:52:05 * Running on http://127.0.0.1:3000/ (Press CTRL+C to quit)

  • curl to api:
    curl http://localhost:3000/orders

  • throws exception:
    2019-07-26 15:49:04 Invoking com.amazonaws.handler.GetOrdersHandler::handleRequest (java8) 2019-07-26 15:49:05 Decompressing /root/Projects/aws-lambda/aws-sam-java-rest/target/aws-sam-java-rest-1.0.0.jar Fetching lambci/lambda:java8 Docker container image...... 2019-07-26 15:49:13 Mounting /tmp/tmpazHrq1 as /var/task:ro,delegated inside runtime container Jul 26, 2019 6:49:14 PM com.fasterxml.jackson.databind.ext.Java7Support <clinit> WARNING: Unable to load JDK7 types (annotations, java.nio.file.Path): no Java7 support added 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. START RequestId: d6387246-c75a-455e-a2dc-34fa2999eba6 Version: $LATEST software.amazon.awssdk.core.exception.SdkClientException: Unable to execute HTTP request: Connect to 127.0.0.1:8000 [/127.0.0.1] failed: Connection refused (Connection refused) at software.amazon.awssdk.core.exception.SdkClientException$BuilderImpl.build(SdkClientException.java:93) at software.amazon.awssdk.core.internal.http.pipeline.stages.RetryableStage$RetryExecutor.handleThrownException(RetryableStage.java:170) at software.amazon.awssdk.core.internal.http.pipeline.stages.RetryableStage$RetryExecutor.execute(RetryableStage.java:123) at software.amazon.awssdk.core.internal.http.pipeline.stages.RetryableStage.execute(RetryableStage.java:69) at software.amazon.awssdk.core.internal.http.pipeline.stages.RetryableStage.execute(RetryableStage.java:49) at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:205) at software.amazon.awssdk.core.internal.http.StreamManagingStage.execute(StreamManagingStage.java:57) at software.amazon.awssdk.core.internal.http.StreamManagingStage.execute(StreamManagingStage.java:42) at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:205) at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:205) 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:25) at software.amazon.awssdk.core.internal.http.AmazonSyncHttpClient$RequestExecutionBuilderImpl.execute(AmazonSyncHttpClient.java:283) at software.amazon.awssdk.core.client.handler.BaseSyncClientHandler.invoke(BaseSyncClientHandler.java:91) at software.amazon.awssdk.core.client.handler.BaseSyncClientHandler.execute(BaseSyncClientHandler.java:103) at software.amazon.awssdk.core.client.handler.BaseSyncClientHandler.execute(BaseSyncClientHandler.java:68) at software.amazon.awssdk.core.client.handler.SdkSyncClientHandler.execute(SdkSyncClientHandler.java:44) at software.amazon.awssdk.awscore.client.handler.AwsSyncClientHandler.execute(AwsSyncClientHandler.java:53) at software.amazon.awssdk.services.dynamodb.DefaultDynamoDbClient.scan(DefaultDynamoDbClient.java:2456) at com.amazonaws.dao.OrderDao.getOrders(OrderDao.java:152) at com.amazonaws.handler.GetOrdersHandler.handleRequest(GetOrdersHandler.java:64) 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) Caused by: org.apache.http.conn.HttpHostConnectException: Connect to 127.0.0.1:8000 [/127.0.0.1] failed: Connection refused (Connection refused) at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:159) at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:373) 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 software.amazon.awssdk.http.apache.internal.conn.ClientConnectionManagerFactory$Handler.invoke(ClientConnectionManagerFactory.java:80) at com.sun.proxy.$Proxy0.connect(Unknown Source) at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:381) at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237) at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185) at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56) at software.amazon.awssdk.http.apache.internal.impl.ApacheSdkHttpClient.execute(ApacheSdkHttpClient.java:72) at software.amazon.awssdk.http.apache.ApacheHttpClient.execute(ApacheHttpClient.java:200) at software.amazon.awssdk.http.apache.ApacheHttpClient.access$400(ApacheHttpClient.java:92) at software.amazon.awssdk.http.apache.ApacheHttpClient$1.call(ApacheHttpClient.java:178) at software.amazon.awssdk.http.apache.ApacheHttpClient$1.call(ApacheHttpClient.java:175) at software.amazon.awssdk.core.internal.http.pipeline.stages.MakeHttpRequestStage.executeHttpRequest(MakeHttpRequestStage.java:58) at software.amazon.awssdk.core.internal.http.pipeline.stages.MakeHttpRequestStage.execute(MakeHttpRequestStage.java:50) at software.amazon.awssdk.core.internal.http.pipeline.stages.MakeHttpRequestStage.execute(MakeHttpRequestStage.java:34) at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:205) at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:205) at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:205) at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:205) at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:205) at software.amazon.awssdk.core.internal.http.pipeline.stages.RetryableStage$RetryExecutor.doExecute(RetryableStage.java:145) at software.amazon.awssdk.core.internal.http.pipeline.stages.RetryableStage$RetryExecutor.execute(RetryableStage.java:111) ... 22 more Caused by: java.net.ConnectException: Connection refused (Connection refused) at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:589) at org.apache.http.conn.socket.PlainConnectionSocketFactory.connectSocket(PlainConnectionSocketFactory.java:75) at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)

I access to dynamodb shell via web browser to check if db is ok and it is up and running normally.

Any tip on this stuff ?
Thanks in advance.

Cannot hit docker container using end point

Hello I am having trouble following the documentation on the readMe file, below are the steps I follow

Steps to reproduce:

  • Get dependencies

:
mvn package

  • Run docker container :

docker run -p 8000:8000 amazon/dynamodb-local
Output:

Initializing DynamoDB Local with the following configuration:
Port:   8000
InMemory:       true
DbPath: null
SharedDb:       false
shouldDelayTransientStatuses:   false
CorsParams:  
  • Checking...

docker ps

CONTAINER ID        IMAGE                   COMMAND                  CREATED              STATUS              PORTS                    NAMES
340025693b3a        amazon/dynamodb-local   "java -jar DynamoDBL…"   About a minute ago   Up About a minute   0.0.0.0:8000->8000/tcp   modest_mahavira
  • Start api:

sam local start-api --env-vars src/test/resources/test_environment_windows.json

Output:

2019-06-07 06:01:01 Found credentials in shared credentials file: ~/.aws/credentials
2019-06-07 06:01:01 Mounting GetOrderFunction at http://127.0.0.1:3000/orders/{order_id} [GET]
2019-06-07 06:01:01 Mounting CreateOrdersTableFunction at http://127.0.0.1:3000/_create_orders_table [POST]
2019-06-07 06:01:01 Mounting GetOrdersFunction at http://127.0.0.1:3000/orders [GET]
2019-06-07 06:01:01 Mounting DeleteOrderFunction at http://127.0.0.1:3000/orders/{order_id} [DELETE]
2019-06-07 06:01:01 Mounting CreateOrderFunction at http://127.0.0.1:3000/orders [POST]
2019-06-07 06:01:01 Mounting UpdateOrderFunction at http://127.0.0.1:3000/orders/{order_id} [POST]
2019-06-07 06:01:01 You can now browse to the above endpoints to invoke your functions. You do not need to restart/reload SAM CLI while working on your functions, changes will be reflected instantly/automatical
ly. You only need to restart SAM CLI if you update your AWS SAM template
2019-06-07 06:01:01  * Running on http://127.0.0.1:3000/ (Press CTRL+C to quit)

Errors out saying :
software.amazon.awssdk.core.exception.SdkClientException: Unable to execute HTTP request: docker.for.windows.localhost

Expected result:

To work as documented

  • My system info:
OS Name	Microsoft Windows 10 Pro
Version	10.0.17134 Build 17134
Other OS Description 	Not Available
OS Manufacturer	Microsoft Corporation
System Name	DESKTOP-FC3Q9EQ
System Manufacturer	Dell Inc.
System Model	Inspiron 15 7000 Gaming
System Type	x64-based PC
System SKU	0798
Processor	Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz, 2801 Mhz, 4 Core(s), 8 Logical Processor(s)
BIOS Version/Date	Dell Inc. 1.9.0, 1/10/2019
SMBIOS Version	3.0
Embedded Controller Version	255.255
BIOS Mode	UEFI
BaseBoard Manufacturer	Dell Inc.
BaseBoard Model	Not Available
BaseBoard Name	Base Board
Platform Role	Mobile
Secure Boot State	On
PCR7 Configuration	Elevation Required to View
Windows Directory	C:\WINDOWS
System Directory	C:\WINDOWS\system32
Boot Device	\Device\HarddiskVolume1
Locale	United States
Hardware Abstraction Layer	Version = "10.0.17134.765"
User Name	DESKTOP-FC3Q9EQ\sgg35
Time Zone	Eastern Daylight Time
Installed Physical Memory (RAM)	16.0 GB
Total Physical Memory	15.9 GB
Available Physical Memory	5.81 GB
Total Virtual Memory	18.2 GB
Available Virtual Memory	2.98 GB
Page File Space	2.38 GB
Page File	C:\pagefile.sys
Kernel DMA Protection	Off
Virtualization-based security	Running
Virtualization-based security Required Security Properties	
Virtualization-based security Available Security Properties	Base Virtualization Support, Secure Boot, DMA Protection, Mode Based Execution Control
Virtualization-based security Services Configured	
Virtualization-based security Services Running	
Device Encryption Support	Elevation Required to View
A hypervisor has been detected. Features required for Hyper-V will not be displayed.	
  • Docker version:

Docker version 18.09.2, build 6247962

  • sam cli:

SAM CLI, version 0.16.0

  • Complete stack trace:
Fetching lambci/lambda:java8 Docker container image......
2019-06-07 06:07:26 Mounting D:\Temp\tmpea9_931o as /var/task:ro,delegated inside runtime container
Jun 07, 2019 10:07:28 AM com.fasterxml.jackson.databind.ext.Java7Support <clinit>
WARNING: Unable to load JDK7 types (annotations, java.nio.file.Path): no Java7 support added
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.
?[32mSTART RequestId: 6744a18e-e17b-4c0a-a0d1-d815149dc554 Version: $LATEST?[0m
?[31msoftware.amazon.awssdk.core.exception.SdkClientException: Unable to execute HTTP request: docker.for.windows.localhost
        at software.amazon.awssdk.core.exception.SdkClientException$BuilderImpl.build(SdkClientException.java:93)
        at software.amazon.awssdk.core.internal.http.pipeline.stages.RetryableStage$RetryExecutor.handleThrownException(RetryableStage.java:170)
        at software.amazon.awssdk.core.internal.http.pipeline.stages.RetryableStage$RetryExecutor.execute(RetryableStage.java:123)
        at software.amazon.awssdk.core.internal.http.pipeline.stages.RetryableStage.execute(RetryableStage.java:69)
        at software.amazon.awssdk.core.internal.http.pipeline.stages.RetryableStage.execute(RetryableStage.java:49)
        at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:205)
        at software.amazon.awssdk.core.internal.http.StreamManagingStage.execute(StreamManagingStage.java:57)
        at software.amazon.awssdk.core.internal.http.StreamManagingStage.execute(StreamManagingStage.java:42)
        at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:205)
        at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:205)
        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:25)
        at software.amazon.awssdk.core.internal.http.AmazonSyncHttpClient$RequestExecutionBuilderImpl.execute(AmazonSyncHttpClient.java:283)
        at software.amazon.awssdk.core.client.handler.BaseSyncClientHandler.invoke(BaseSyncClientHandler.java:91)
        at software.amazon.awssdk.core.client.handler.BaseSyncClientHandler.execute(BaseSyncClientHandler.java:103)
        at software.amazon.awssdk.core.client.handler.BaseSyncClientHandler.execute(BaseSyncClientHandler.java:68)
        at software.amazon.awssdk.core.client.handler.SdkSyncClientHandler.execute(SdkSyncClientHandler.java:44)
        at software.amazon.awssdk.awscore.client.handler.AwsSyncClientHandler.execute(AwsSyncClientHandler.java:53)
        at software.amazon.awssdk.services.dynamodb.DefaultDynamoDbClient.scan(DefaultDynamoDbClient.java:2456)
        at com.amazonaws.dao.OrderDao.getOrders(OrderDao.java:152)
        at com.amazonaws.handler.GetOrdersHandler.handleRequest(GetOrdersHandler.java:64)
        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)
Caused by: java.net.UnknownHostException: docker.for.windows.localhost
        at java.net.InetAddress.getAllByName0(InetAddress.java:1281)
        at java.net.InetAddress.getAllByName(InetAddress.java:1193)
        at java.net.InetAddress.getAllByName(InetAddress.java:1127)
        at org.apache.http.impl.conn.SystemDefaultDnsResolver.resolve(SystemDefaultDnsResolver.java:45)
        at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:112)
        at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:373)
        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 software.amazon.awssdk.http.apache.internal.conn.ClientConnectionManagerFactory$Handler.invoke(ClientConnectionManagerFactory.java:80)
        at com.sun.proxy.$Proxy0.connect(Unknown Source)
        at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:381)
        at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237)
        at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185)
        at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
        at software.amazon.awssdk.http.apache.internal.impl.ApacheSdkHttpClient.execute(ApacheSdkHttpClient.java:72)
        at software.amazon.awssdk.http.apache.ApacheHttpClient.execute(ApacheHttpClient.java:200)
        at software.amazon.awssdk.http.apache.ApacheHttpClient.access$400(ApacheHttpClient.java:92)
        at software.amazon.awssdk.http.apache.ApacheHttpClient$1.call(ApacheHttpClient.java:178)
        at software.amazon.awssdk.http.apache.ApacheHttpClient$1.call(ApacheHttpClient.java:175)
        at software.amazon.awssdk.core.internal.http.pipeline.stages.MakeHttpRequestStage.executeHttpRequest(MakeHttpRequestStage.java:58)
        at software.amazon.awssdk.core.internal.http.pipeline.stages.MakeHttpRequestStage.execute(MakeHttpRequestStage.java:50)
        at software.amazon.awssdk.core.internal.http.pipeline.stages.MakeHttpRequestStage.execute(MakeHttpRequestStage.java:34)
        at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:205)
        at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:205)
        at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:205)
        at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:205)
        at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:205)
        at software.amazon.awssdk.core.internal.http.pipeline.stages.RetryableStage$RetryExecutor.doExecute(RetryableStage.java:145)
        at software.amazon.awssdk.core.internal.http.pipeline.stages.RetryableStage$RetryExecutor.execute(RetryableStage.java:111)
        ... 22 more
?[0m
?[32mEND RequestId: 6744a18e-e17b-4c0a-a0d1-d815149dc554?[0m
?[32mREPORT RequestId: 6744a18e-e17b-4c0a-a0d1-d815149dc554     Duration: 6583.42 ms    Billed Duration: 6600 ms        Memory Size: 128 MB     Max Memory Used: 8 MB   ?[0m
2019-06-07 06:07:41 Invalid API Gateway Response Keys: {'stackTrace', 'errorType', 'errorMessage', 'cause'} in {'errorMessage': 'Unable to execute HTTP request: docker.for.windows.localhost', 'errorType': 'soft
ware.amazon.awssdk.core.exception.SdkClientException', 'stackTrace': ['software.amazon.awssdk.core.exception.SdkClientException$BuilderImpl.build(SdkClientException.java:93)', 'software.amazon.awssdk.core.inter
nal.http.pipeline.stages.RetryableStage$RetryExecutor.handleThrownException(RetryableStage.java:170)', 'software.amazon.awssdk.core.internal.http.pipeline.stages.RetryableStage$RetryExecutor.execute(RetryableSt
age.java:123)', 'software.amazon.awssdk.core.internal.http.pipeline.stages.RetryableStage.execute(RetryableStage.java:69)', 'software.amazon.awssdk.core.internal.http.pipeline.stages.RetryableStage.execute(Retr
yableStage.java:49)', 'software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:205)', 'software.amazon.awssdk.core.internal.ht
tp.StreamManagingStage.execute(StreamManagingStage.java:57)', 'software.amazon.awssdk.core.internal.http.StreamManagingStage.execute(StreamManagingStage.java:42)', 'software.amazon.awssdk.core.internal.http.pip
eline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:205)', 'software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.exe
cute(RequestPipelineBuilder.java:205)', 'software.amazon.awssdk.core.internal.http.pipeline.stages.ExecutionFailureExceptionReportingStage.execute(ExecutionFailureExceptionReportingStage.java:37)', 'software.am
azon.awssdk.core.internal.http.pipeline.stages.ExecutionFailureExceptionReportingStage.execute(ExecutionFailureExceptionReportingStage.java:25)', 'software.amazon.awssdk.core.internal.http.AmazonSyncHttpClient$
RequestExecutionBuilderImpl.execute(AmazonSyncHttpClient.java:283)', 'software.amazon.awssdk.core.client.handler.BaseSyncClientHandler.invoke(BaseSyncClientHandler.java:91)', 'software.amazon.awssdk.core.client
.handler.BaseSyncClientHandler.execute(BaseSyncClientHandler.java:103)', 'software.amazon.awssdk.core.client.handler.BaseSyncClientHandler.execute(BaseSyncClientHandler.java:68)', 'software.amazon.awssdk.core.c
lient.handler.SdkSyncClientHandler.execute(SdkSyncClientHandler.java:44)', 'software.amazon.awssdk.awscore.client.handler.AwsSyncClientHandler.execute(AwsSyncClientHandler.java:53)', 'software.amazon.awssdk.ser
vices.dynamodb.DefaultDynamoDbClient.scan(DefaultDynamoDbClient.java:2456)', 'com.amazonaws.dao.OrderDao.getOrders(OrderDao.java:152)', 'com.amazonaws.handler.GetOrdersHandler.handleRequest(GetOrdersHandler.jav
a:64)', 'sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)', 'sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)', 'sun.reflect.DelegatingMethodAccessorImpl.invoke(Delegatin
gMethodAccessorImpl.java:43)', 'java.lang.reflect.Method.invoke(Method.java:498)'], 'cause': {'errorMessage': 'docker.for.windows.localhost', 'errorType': 'java.net.UnknownHostException', 'stackTrace': ['java.n
et.InetAddress.getAllByName0(InetAddress.java:1281)', 'java.net.InetAddress.getAllByName(InetAddress.java:1193)', 'java.net.InetAddress.getAllByName(InetAddress.java:1127)', 'org.apache.http.impl.conn.SystemDef
aultDnsResolver.resolve(SystemDefaultDnsResolver.java:45)', 'org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:112)', 'org.apache.http.impl.conn.Pool
ingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:373)', 'sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)', 'sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce
ssorImpl.java:62)', 'sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)', 'java.lang.reflect.Method.invoke(Method.java:498)', 'software.amazon.awssdk.http.apache.internal.conn
.ClientConnectionManagerFactory$Handler.invoke(ClientConnectionManagerFactory.java:80)', 'com.sun.proxy.$Proxy0.connect(Unknown Source)', 'org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClient
Exec.java:381)', 'org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237)', 'org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185)', 'org.apache.http.impl.client.Inte
rnalHttpClient.doExecute(InternalHttpClient.java:185)', 'org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)', 'org.apache.http.impl.client.CloseableHttpClient.execute(Closeable
HttpClient.java:56)', 'software.amazon.awssdk.http.apache.internal.impl.ApacheSdkHttpClient.execute(ApacheSdkHttpClient.java:72)', 'software.amazon.awssdk.http.apache.ApacheHttpClient.execute(ApacheHttpClient.j
ava:200)', 'software.amazon.awssdk.http.apache.ApacheHttpClient.access$400(ApacheHttpClient.java:92)', 'software.amazon.awssdk.http.apache.ApacheHttpClient$1.call(ApacheHttpClient.java:178)', 'software.amazon.a
wssdk.http.apache.ApacheHttpClient$1.call(ApacheHttpClient.java:175)', 'software.amazon.awssdk.core.internal.http.pipeline.stages.MakeHttpRequestStage.executeHttpRequest(MakeHttpRequestStage.java:58)', 'softwar
e.amazon.awssdk.core.internal.http.pipeline.stages.MakeHttpRequestStage.execute(MakeHttpRequestStage.java:50)', 'software.amazon.awssdk.core.internal.http.pipeline.stages.MakeHttpRequestStage.execute(MakeHttpRe
questStage.java:34)', 'software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:205)', 'software.amazon.awssdk.core.internal.ht
tp.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:205)', 'software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineSta
ge.execute(RequestPipelineBuilder.java:205)', 'software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:205)', 'software.amazon
.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:205)', 'software.amazon.awssdk.core.internal.http.pipeline.stages.RetryableStage$Retr
yExecutor.doExecute(RetryableStage.java:145)', 'software.amazon.awssdk.core.internal.http.pipeline.stages.RetryableStage$RetryExecutor.execute(RetryableStage.java:111)', 'software.amazon.awssdk.core.internal.ht
tp.pipeline.stages.RetryableStage.execute(RetryableStage.java:69)', 'software.amazon.awssdk.core.internal.http.pipeline.stages.RetryableStage.execute(RetryableStage.java:49)', 'software.amazon.awssdk.core.inter
nal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:205)', 'software.amazon.awssdk.core.internal.http.StreamManagingStage.execute(StreamManagingStage.java:
57)', 'software.amazon.awssdk.core.internal.http.StreamManagingStage.execute(StreamManagingStage.java:42)', 'software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineSta
ge.execute(RequestPipelineBuilder.java:205)', 'software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:205)', 'software.amazon
.awssdk.core.internal.http.pipeline.stages.ExecutionFailureExceptionReportingStage.execute(ExecutionFailureExceptionReportingStage.java:37)', 'software.amazon.awssdk.core.internal.http.pipeline.stages.Execution
FailureExceptionReportingStage.execute(ExecutionFailureExceptionReportingStage.java:25)', 'software.amazon.awssdk.core.internal.http.AmazonSyncHttpClient$RequestExecutionBuilderImpl.execute(AmazonSyncHttpClient
.java:283)', 'software.amazon.awssdk.core.client.handler.BaseSyncClientHandler.invoke(BaseSyncClientHandler.java:91)', 'software.amazon.awssdk.core.client.handler.BaseSyncClientHandler.execute(BaseSyncClientHan
dler.java:103)', 'software.amazon.awssdk.core.client.handler.BaseSyncClientHandler.execute(BaseSyncClientHandler.java:68)', 'software.amazon.awssdk.core.client.handler.SdkSyncClientHandler.execute(SdkSyncClient
Handler.java:44)', 'software.amazon.awssdk.awscore.client.handler.AwsSyncClientHandler.execute(AwsSyncClientHandler.java:53)', 'software.amazon.awssdk.services.dynamodb.DefaultDynamoDbClient.scan(DefaultDynamoD
bClient.java:2456)', 'com.amazonaws.dao.OrderDao.getOrders(OrderDao.java:152)', 'com.amazonaws.handler.GetOrdersHandler.handleRequest(GetOrdersHandler.java:64)', 'sun.reflect.NativeMethodAccessorImpl.invoke0(Na
tive Method)', 'sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)', 'sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)', 'java.lang.reflect.Method
.invoke(Method.java:498)']}}
2019-06-07 06:07:41 Function returned an invalid response (must include one of: body, headers or statusCode in the response object). Response received: {"errorMessage":"Unable to execute HTTP request: docker.fo
r.windows.localhost","errorType":"software.amazon.awssdk.core.exception.SdkClientException","stackTrace":["software.amazon.awssdk.core.exception.SdkClientException$BuilderImpl.build(SdkClientException.java:93)"
,"software.amazon.awssdk.core.internal.http.pipeline.stages.RetryableStage$RetryExecutor.handleThrownException(RetryableStage.java:170)","software.amazon.awssdk.core.internal.http.pipeline.stages.RetryableStage
$RetryExecutor.execute(RetryableStage.java:123)","software.amazon.awssdk.core.internal.http.pipeline.stages.RetryableStage.execute(RetryableStage.java:69)","software.amazon.awssdk.core.internal.http.pipeline.st
ages.RetryableStage.execute(RetryableStage.java:49)","software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:205)","software.
amazon.awssdk.core.internal.http.StreamManagingStage.execute(StreamManagingStage.java:57)","software.amazon.awssdk.core.internal.http.StreamManagingStage.execute(StreamManagingStage.java:42)","software.amazon.a
wssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:205)","software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$Compos
ingRequestPipelineStage.execute(RequestPipelineBuilder.java:205)","software.amazon.awssdk.core.internal.http.pipeline.stages.ExecutionFailureExceptionReportingStage.execute(ExecutionFailureExceptionReportingSta
ge.java:37)","software.amazon.awssdk.core.internal.http.pipeline.stages.ExecutionFailureExceptionReportingStage.execute(ExecutionFailureExceptionReportingStage.java:25)","software.amazon.awssdk.core.internal.ht
tp.AmazonSyncHttpClient$RequestExecutionBuilderImpl.execute(AmazonSyncHttpClient.java:283)","software.amazon.awssdk.core.client.handler.BaseSyncClientHandler.invoke(BaseSyncClientHandler.java:91)","software.ama
zon.awssdk.core.client.handler.BaseSyncClientHandler.execute(BaseSyncClientHandler.java:103)","software.amazon.awssdk.core.client.handler.BaseSyncClientHandler.execute(BaseSyncClientHandler.java:68)","software.
amazon.awssdk.core.client.handler.SdkSyncClientHandler.execute(SdkSyncClientHandler.java:44)","software.amazon.awssdk.awscore.client.handler.AwsSyncClientHandler.execute(AwsSyncClientHandler.java:53)","software
.amazon.awssdk.services.dynamodb.DefaultDynamoDbClient.scan(DefaultDynamoDbClient.java:2456)","com.amazonaws.dao.OrderDao.getOrders(OrderDao.java:152)","com.amazonaws.handler.GetOrdersHandler.handleRequest(GetO
rdersHandler.java:64)","sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)","sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)","sun.reflect.DelegatingMethodAccessorImpl.inv
oke(DelegatingMethodAccessorImpl.java:43)","java.lang.reflect.Method.invoke(Method.java:498)"],"cause":{"errorMessage":"docker.for.windows.localhost","errorType":"java.net.UnknownHostException","stackTrace":["j
ava.net.InetAddress.getAllByName0(InetAddress.java:1281)","java.net.InetAddress.getAllByName(InetAddress.java:1193)","java.net.InetAddress.getAllByName(InetAddress.java:1127)","org.apache.http.impl.conn.SystemD
efaultDnsResolver.resolve(SystemDefaultDnsResolver.java:45)","org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:112)","org.apache.http.impl.conn.Pool
ingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:373)","sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)","sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccess
orImpl.java:62)","sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)","java.lang.reflect.Method.invoke(Method.java:498)","software.amazon.awssdk.http.apache.internal.conn.Clie
ntConnectionManagerFactory$Handler.invoke(ClientConnectionManagerFactory.java:80)","com.sun.proxy.$Proxy0.connect(Unknown Source)","org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.ja
va:381)","org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237)","org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185)","org.apache.http.impl.client.InternalHttpCl
ient.doExecute(InternalHttpClient.java:185)","org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)","org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.j
ava:56)","software.amazon.awssdk.http.apache.internal.impl.ApacheSdkHttpClient.execute(ApacheSdkHttpClient.java:72)","software.amazon.awssdk.http.apache.ApacheHttpClient.execute(ApacheHttpClient.java:200)","sof
tware.amazon.awssdk.http.apache.ApacheHttpClient.access$400(ApacheHttpClient.java:92)","software.amazon.awssdk.http.apache.ApacheHttpClient$1.call(ApacheHttpClient.java:178)","software.amazon.awssdk.http.apache
.ApacheHttpClient$1.call(ApacheHttpClient.java:175)","software.amazon.awssdk.core.internal.http.pipeline.stages.MakeHttpRequestStage.executeHttpRequest(MakeHttpRequestStage.java:58)","software.amazon.awssdk.cor
e.internal.http.pipeline.stages.MakeHttpRequestStage.execute(MakeHttpRequestStage.java:50)","software.amazon.awssdk.core.internal.http.pipeline.stages.MakeHttpRequestStage.execute(MakeHttpRequestStage.java:34)"
,"software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:205)","software.amazon.awssdk.core.internal.http.pipeline.RequestPip
elineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:205)","software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipel
ineBuilder.java:205)","software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:205)","software.amazon.awssdk.core.internal.htt
p.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:205)","software.amazon.awssdk.core.internal.http.pipeline.stages.RetryableStage$RetryExecutor.doExecute(Retrya
bleStage.java:145)","software.amazon.awssdk.core.internal.http.pipeline.stages.RetryableStage$RetryExecutor.execute(RetryableStage.java:111)","software.amazon.awssdk.core.internal.http.pipeline.stages.Retryable
Stage.execute(RetryableStage.java:69)","software.amazon.awssdk.core.internal.http.pipeline.stages.RetryableStage.execute(RetryableStage.java:49)","software.amazon.awssdk.core.internal.http.pipeline.RequestPipel
ineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:205)","software.amazon.awssdk.core.internal.http.StreamManagingStage.execute(StreamManagingStage.java:57)","software.amazon.awssdk.co
re.internal.http.StreamManagingStage.execute(StreamManagingStage.java:42)","software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder
.java:205)","software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:205)","software.amazon.awssdk.core.internal.http.pipeline
.stages.ExecutionFailureExceptionReportingStage.execute(ExecutionFailureExceptionReportingStage.java:37)","software.amazon.awssdk.core.internal.http.pipeline.stages.ExecutionFailureExceptionReportingStage.execu
te(ExecutionFailureExceptionReportingStage.java:25)","software.amazon.awssdk.core.internal.http.AmazonSyncHttpClient$RequestExecutionBuilderImpl.execute(AmazonSyncHttpClient.java:283)","software.amazon.awssdk.c
ore.client.handler.BaseSyncClientHandler.invoke(BaseSyncClientHandler.java:91)","software.amazon.awssdk.core.client.handler.BaseSyncClientHandler.execute(BaseSyncClientHandler.java:103)","software.amazon.awssdk
.core.client.handler.BaseSyncClientHandler.execute(BaseSyncClientHandler.java:68)","software.amazon.awssdk.core.client.handler.SdkSyncClientHandler.execute(SdkSyncClientHandler.java:44)","software.amazon.awssdk
.awscore.client.handler.AwsSyncClientHandler.execute(AwsSyncClientHandler.java:53)","software.amazon.awssdk.services.dynamodb.DefaultDynamoDbClient.scan(DefaultDynamoDbClient.java:2456)","com.amazonaws.dao.Orde
rDao.getOrders(OrderDao.java:152)","com.amazonaws.handler.GetOrdersHandler.handleRequest(GetOrdersHandler.java:64)","sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)","sun.reflect.NativeMethodAccesso
rImpl.invoke(NativeMethodAccessorImpl.java:62)","sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)","java.lang.reflect.Method.invoke(Method.java:498)"]}}
2019-06-07 06:07:41 127.0.0.1 - - [07/Jun/2019 06:07:41] "GET /orders HTTP/1.1" 502 -
2019-06-07 06:07:42 127.0.0.1 - - [07/Jun/2019 06:07:42] "GET /favicon.ico HTTP/1.1" 403 -
  • PS:

I tried running other containers in docker and exposing ports which work perfectly example

`docker run -d -p 80:80 nginx

`
So I don't think it something in docker that's missing here

Not working out of the box

One has to use the following command:
aws cloudformation deploy --template-file /Users/nmas409/aws-sam-java-rest/aws-sam-java-rest/packaged.yaml --stack-name sam-orderHandler --capabilities CAPABILITY_IAM
Waiting for changeset to be created..

But getting this error.

Failed to create the changeset: Waiter ChangeSetCreateComplete failed: Waiter encountered a terminal failure state Status: FAILED. Reason: [/Resources/DeleteOrderFunction/Type/Environment/Variables/TABLE_NAME] 'null' values are not allowed in templates

This doesn't work at all:
sam deploy
--template-file packaged.yaml
--stack-name sam-orderHandler
--capabilities CAPABILITY_IAM

Gradle implementation

A lot of projects have abandoned Maven out of preference to use Gradle - can we get an updated example that uses Gradle instead of Maven?

How to best send command line args to local dynamodb docker container

Sorry if this is the wrong git repo - I couldn't find where the dockerfile for amazon/dynamodb-local was being maintained.

2 questions here:

  1. Currently, to send command line args as described here https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.UsageNotes.html it looks like I need to send the full args to the java process instead of just the args to configure the dynamodb server. So instead of running docker run -it --rm amazon/dynamodb-local -sharedDb I need to run docker run -it --rm amazon/dynamodb-local -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb
    Would it be possible to change the entrypoint/cmd of the dockerfile to handle the java args for you and the user just pass in the extra arguments? I think the more common use case is to just specify the dynamodb args, but if a user wanted to modify the java args they should be able to override the entrypoint in their own docker run

  2. What directory in the container should I mount if I want to persist the .db file?

DaggerOrderComponent is not found.

In my develop environment (Eclipse IDE), an error occurs that DaggerOrderComponent is not found. Where is the DaggerOrderComponent ? Is there in the source code?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.