JetBrains / kotless

Kotlin Serverless Framework
Apache License 2.0
1.15k stars 57 forks source link

[Request] Add details on AWS emulation #100

Closed cc189 closed 3 years ago

cc189 commented 3 years ago

When you talked AWS emulation in the README, what exactly are you referring to? Can you give some more details?

I have the gradle port config:

kotless {
    extensions {
        local {
            port = 4566
            useAWSEmulation = true
        }
    }
}

And tried some possible AWS emulation:

I was able to talk with DynamoDB with aws-cli:

# https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/getting-started-step-1.html
aws dynamodb create-table \
    --endpoint-url http://localhost:4566 \
    --table-name Music \
    --attribute-definitions \
        AttributeName=Artist,AttributeType=S \
        AttributeName=SongTitle,AttributeType=S \
    --key-schema \
        AttributeName=Artist,KeyType=HASH \
        AttributeName=SongTitle,KeyType=RANGE \
    --provisioned-throughput \
        ReadCapacityUnits=10,WriteCapacityUnits=5

But I get error message from Ktor API call:

com.amazonaws.services.dynamodbv2.model.ResourceNotFoundException: 
Cannot do operations on a non-existent table (
  Service: AmazonDynamoDBv2; 
  Status Code: 400; 
  Error Code: ResourceNotFoundException; 
  Request ID: xxxx; 
  Proxy: null
)
cc189 commented 3 years ago

AWS emulation assumption is valid. Update details in the doc would be helpful.

Resolved the error by create table and then call API:

aws dynamodb create-table \
    --endpoint-url http://localhost:4566 \
    --table-name short-url-table \
    --attribute-definitions \
        AttributeName=URLHash,AttributeType=S \
    --key-schema \
        AttributeName=URLHash,KeyType=HASH \
    --provisioned-throughput \
        ReadCapacityUnits=10,WriteCapacityUnits=5