Store the AWS SDK return value in DynamoDB

require 'aws-sdk'
sts = Aws::STS::Client.new
ddb = Aws::DynamoDB::Client.new
ddb.put_item({
  table_name: "anytable",
  item: sts.get_caller_identity.to_h.transform_keys(&:to_s).transform_values(&:to_s)
})

Since the return value of AWS SDK is (almost all?) Struct type, it cannot be stored in the table as it is. It can be stored by hashing and then stringifying the key and value of the hash.

Recommended Posts

Store the AWS SDK return value in DynamoDB
Exceptions encountered in the AWS SDK
must not return in the for statement
Ruby methods return the last evaluated value
I want to get the value in Ruby
Return the execution result of Service class in ServiceResponse class
[Ruby / Rails] Set a unique (unique) value in the class
Find the approximate value of log (1 + x) in Swift
Credentials referenced by the AWS SDK for Java by default
[Processing] Can Perlin noise return in the opposite direction?
twitter4j java Store the searched tweets in DB (MySQL).
How to specify an array in the return value / argument of the method in the CORBA IDL file
Branch processing by the return value of RestTemplate and the status code of ResponseEntity in Spring Boot