Skip to content

Commit

Permalink
Update dynamo client creation
Browse files Browse the repository at this point in the history
  • Loading branch information
lindseydew committed Mar 11, 2024
1 parent e66f00d commit b45fc8a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import org.scanamo.{
import com.gu.sfl.Logging
import com.gu.sfl.lib.Jackson._
import com.gu.sfl.model._
import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider
import software.amazon.awssdk.services.dynamodb.DynamoDbClient
import software.amazon.awssdk.services.dynamodb.model.AttributeValue

Expand Down Expand Up @@ -97,10 +96,7 @@ class SavedArticlesPersistenceImpl(persistanceConfig: PersistenceConfig)
SavedArticles(dynamoSavedArticles.version, articles)
}

private val client = DynamoDbClient
.builder()
.credentialsProvider(DefaultCredentialsProvider.create())
.build()
private val client = DynamoDbClient.create()
//TODO confirm that it's ok to share the same client concurrently in all requests.. I guess if this is a lambda there won't be concurrent requests anyway ?
private val scanamo = Scanamo(client)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
package coml.gu.sfl.userdeletion.db

import com.amazonaws.auth.DefaultAWSCredentialsProviderChain
import software.amazon.awssdk.services.dynamodb.DynamoDbClient
import org.scanamo.{Scanamo, Table}
import org.scanamo.syntax._
import com.gu.sfl.Logging
import com.gu.sfl.persistence.{DynamoSavedArticles, PersistenceConfig}
import com.gu.sfl.userdeletion.model.UserDeleteMessage
import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider

class SflDynamoDb(persistanceConfig: PersistenceConfig) extends Logging {

private val table = Table[DynamoSavedArticles](persistanceConfig.tableName)
private val client =
DynamoDbClient
.builder()
.credentialsProvider(DefaultCredentialsProvider.create())
.build()
private val client = DynamoDbClient.create()
private val scanamo = Scanamo(client)

def deleteSavedArticleasForUser(user: UserDeleteMessage) = {
Expand Down

0 comments on commit b45fc8a

Please sign in to comment.