diff --git a/app/components/AppComponents.scala b/app/components/AppComponents.scala index af0192c5..eca695a4 100644 --- a/app/components/AppComponents.scala +++ b/app/components/AppComponents.scala @@ -1,42 +1,40 @@ package components -import org.apache.pekko.actor.typed.ActorSystem -import org.apache.pekko.actor.{ActorSystem => UntypedActorSystem} -import com.amazonaws.{ - AmazonClientException, - AmazonWebServiceRequest, - ClientConfiguration -} +import com.amazonaws.auth.profile.ProfileCredentialsProvider import com.amazonaws.auth.{ AWSCredentialsProviderChain, InstanceProfileCredentialsProvider } -import com.amazonaws.auth.profile.ProfileCredentialsProvider import com.amazonaws.regions.Regions -import com.amazonaws.retry.{PredefinedRetryPolicies, RetryPolicy} import com.amazonaws.retry.PredefinedRetryPolicies.SDKDefaultRetryCondition -import software.amazon.awssdk.services.dynamodb.DynamoDbClient +import com.amazonaws.retry.{PredefinedRetryPolicies, RetryPolicy} import com.amazonaws.services.ec2.{AmazonEC2, AmazonEC2ClientBuilder} import com.amazonaws.services.s3.{AmazonS3, AmazonS3ClientBuilder} +import com.amazonaws.services.securitytoken.model.GetCallerIdentityRequest import com.amazonaws.services.securitytoken.{ AWSSecurityTokenService, AWSSecurityTokenServiceClientBuilder } -import com.amazonaws.services.securitytoken.model.GetCallerIdentityRequest -import com.amazonaws.services.sns.{ - AmazonSNSAsync, - AmazonSNSAsyncClientBuilder, - AmazonSNSClientBuilder +import com.amazonaws.services.sns.AmazonSNSClientBuilder +import com.amazonaws.{ + AmazonClientException, + AmazonWebServiceRequest, + ClientConfiguration +} +import com.google.auth.oauth2.ServiceAccountCredentials +import com.gu.googleauth.{ + AntiForgeryChecker, + AuthAction, + GoogleAuthConfig, + GoogleGroupChecker } -import com.gu.{AppIdentity, AwsIdentity, DevIdentity} -import com.gu.googleauth.{AntiForgeryChecker, AuthAction, GoogleAuthConfig} import com.gu.play.secretrotation.aws.parameterstore.{AwsSdkV2, SecretSupplier} import com.gu.play.secretrotation.{ RotatingSecretComponents, SnapshotProvider, TransitionTiming } -import java.time.Duration +import com.gu.{AppIdentity, AwsIdentity, DevIdentity} import controllers._ import data.{Dynamo, Recipes} import event.{ActorSystemWrapper, BakeEvent, Behaviours} @@ -44,11 +42,13 @@ import housekeeping._ import housekeeping.utils.{BakesRepo, PackerEC2Client} import models.NotificationConfig import notification.{LambdaDistributionBucket, NotificationSender, SNS} +import org.apache.pekko.actor.typed.ActorSystem +import org.apache.pekko.actor.{ActorSystem => UntypedActorSystem} import org.quartz.Scheduler import org.quartz.impl.StdSchedulerFactory import packer.{PackerConfig, PackerRunner} -import play.api.BuiltInComponentsFromContext import play.api.ApplicationLoader.Context +import play.api.BuiltInComponentsFromContext import play.api.i18n.I18nComponents import play.api.libs.ws.ahc.AhcWSComponents import play.api.mvc.{AnyContent, EssentialFilter} @@ -59,26 +59,23 @@ import prism.Prism import router.Routes import schedule.{BakeScheduler, ScheduledBakeRunner} import services.{AmiMetadataLookup, Loggable, PrismData} -import software.amazon.awssdk.services.ssm.SsmClient import software.amazon.awssdk.auth.credentials.{ - StaticCredentialsProvider, AwsCredentialsProviderChain => AwsCredentialsProviderChainV2, InstanceProfileCredentialsProvider => InstanceProfileCredentialsProviderV2, ProfileCredentialsProvider => ProfileCredentialsProviderV2 } import software.amazon.awssdk.regions.Region +import software.amazon.awssdk.services.dynamodb.DynamoDbClient +import software.amazon.awssdk.services.sns.SnsAsyncClient +import software.amazon.awssdk.services.ssm.SsmClient +import java.io.FileInputStream +import java.time.Duration import java.time.Duration.{ofHours, ofMinutes} import scala.concurrent.Await import scala.concurrent.duration._ import scala.language.postfixOps -import java.io.FileInputStream -import com.google.api.client.googleapis.auth.oauth2.GoogleCredential import scala.util.Try -import com.gu.googleauth.GoogleGroupChecker -import com.google.auth.oauth2.ServiceAccountCredentials -import com.google.api.client -import com.google.auth.oauth2.ServiceAccountCredentials class LoggingRetryCondition extends SDKDefaultRetryCondition with Loggable { private def exceptionInfo(e: Throwable): String = { @@ -222,11 +219,11 @@ class AppComponents(context: Context, identity: AppIdentity) .withClientConfiguration(clientConfiguration) .build() - val anghammaradSNSClient: AmazonSNSAsync = - AmazonSNSAsyncClientBuilder.standard - .withRegion(region) - .withCredentials(awsCredsForV1) - .withClientConfiguration(clientConfiguration) + val anghammaradSNSClient: SnsAsyncClient = + SnsAsyncClient + .builder() + .region(Region.of(region.getName)) + .credentialsProvider(awsCredsForV2) .build() val amigoUrl: String = configuration diff --git a/app/models/NotificationConfig.scala b/app/models/NotificationConfig.scala index c4cb7eea..0987a176 100644 --- a/app/models/NotificationConfig.scala +++ b/app/models/NotificationConfig.scala @@ -1,10 +1,10 @@ package models -import com.amazonaws.services.sns.AmazonSNSAsync +import software.amazon.awssdk.services.sns.SnsAsyncClient case class NotificationConfig( baseUrl: String, snsTopicArn: String, - snsClient: AmazonSNSAsync, + snsClient: SnsAsyncClient, amigoStage: String ) diff --git a/build.sbt b/build.sbt index de4524f6..038dc971 100644 --- a/build.sbt +++ b/build.sbt @@ -112,7 +112,7 @@ libraryDependencies ++= Seq( "org.scalatest" %% "scalatest-shouldmatchers" % "3.2.19" % Test, "org.scalatestplus" %% "mockito-3-4" % "3.2.10.0" % Test, "fun.mike" % "diff-match-patch" % "0.0.2", - "com.gu" %% "anghammarad-client" % "3.0.0" + "com.gu" %% "anghammarad-client" % "4.0.0" ) routesGenerator := InjectedRoutesGenerator routesImport += "models._"