我正在使用Amazonica,一个Clojure库来写入DynamoDB.
以下内容将项目插入DynamoDB并在第二次调用时更新其内容,这是预期的.
(ddb/put-item cred
:table-name table-name
:item payload)
Run Code Online (Sandbox Code Playgroud)
现在,以下仅在第一次插入项目.再次调用它不会做任何事情,这就是我需要的.
(ddb/put-item cred
:table-name table-name
:condition-expression "attribute_not_exists(clientId)"
:item payload)
Run Code Online (Sandbox Code Playgroud)
然而,最新的我收到一个错误:
条件请求失败(服务:AmazonDynamoDBv2;状态代码:400;错误代码:ConditionalCheckFailedException;
......这并没有真正使代码可交付.我的CloudFormation模板非常简单:
"Resources": {
"ClientTable": {
"Type": "AWS::DynamoDB::Table",
"Properties": {
"AttributeDefinitions": [
{ "AttributeName": "clientId", "AttributeType": "S" }
],
"KeySchema": [
{ "AttributeName": "clientId", "KeyType": "HASH" }
],
"ProvisionedThroughput": {
"ReadCapacityUnits": { "Ref": "ReadCapacityUnits" },
"WriteCapacityUnits": { "Ref": "WriteCapacityUnits" }
},
"TableName": "ClientTable"
}
}
}
Run Code Online (Sandbox Code Playgroud)
我错过了什么吗?
clojure amazon-web-services aws-cloudformation amazon-dynamodb amazonica
我是一个Ruby开发人员转移到Clojure,我很难理解如何根据Clojure库Amazonica中使用的约定将以下Java调用转换为Clojure .
AmazonS3 client = new AmazonS3Client(credentials);
client.setS3ClientOptions(new S3ClientOptions().withPathStyleAccess(true));
Run Code Online (Sandbox Code Playgroud)
我目前的代码是:
(ns spurious-aws-sdk-helper.core
(:use [amazonica.aws.s3]])
(:require [amazonica.core :refer [ex->map]]))
(def credentials {:access-key "development_access"
:secret-key "development_secret"
:endpoint "s3.spurious.localhost:49154"
:client-config {:protocol "http"}})
(try
(amazonica.aws.s3/set-s3client-options {:path-style-access true})
(create-bucket credentials "testing")
(catch Exception e
(clojure.pprint/write (ex->map e))))
Run Code Online (Sandbox Code Playgroud)
但是我收到以下错误:
com.amazonaws.http.AmazonHttpClient executeHelper
INFO: Unable to execute HTTP request: testing.s3.spurious.localhost
java.net.UnknownHostException: testing.s3.spurious.localhost
Run Code Online (Sandbox Code Playgroud)
这看起来不正确,因为它将存储桶名称(testing)添加到主机名前面.我需要SDK s3.spurious.localhost:49154使用路径样式与我们的本地(假)S3服务()交谈.
例如喜欢 http://s3.spurious.localhost:49154/testing
我认为这是因为我没有正确翻译Java代码......
(amazonica.aws.s3/set-s3client-options {:path-style-access true})
Run Code Online (Sandbox Code Playgroud)
...这是传递一个映射set-s3client-options而不是它应该是什么,这是传递调用withPathStyleAccess(true)新实例的结果S3ClientOptions.但我不知道该怎么办?
任何帮助将不胜感激.
这是代码的最新版本(仍然不起作用)......
(ns spurious-aws-sdk-helper.core
(:use …Run Code Online (Sandbox Code Playgroud) 我需要一个薄包装功能莲的sqs/receive-message,以添加默认的等待时间.该函数需要一个队列URL,然后接受任意数量的可选命名参数,这些参数应该传递给sqs/receive-message未触及的.我想这样称呼它:
(my-receive-message "https://sqs.us-east-1.amazonaws.com/123/test-q"
:max-number-of-messages 10
:delete true)
Run Code Online (Sandbox Code Playgroud)
这应该会导致这样的调用sqs/receive-message:
(sqs/receive-message :queue-url "https://sqs.us-east-1.amazonaws.com/123/test-q"
:wait-time-seconds 20
:max-number-of-messages 10
:delete true)
Run Code Online (Sandbox Code Playgroud)
这是我发现自己想要经常做的事情,但我还没有找到一个好方法.这是否有惯用的方法?
我使用Amazonica从 S3 下载对象:
(require '[amazonica.aws.s3 :as s3])
(s3/get-object "my-bucket" "foo")
Run Code Online (Sandbox Code Playgroud)
但是,有时下载会挂起。如何设置超时时间?