diff --git a/system-x/services/aws/pom.xml b/system-x/services/aws/pom.xml index 2fb5f12a0..bd172b7f8 100644 --- a/system-x/services/aws/pom.xml +++ b/system-x/services/aws/pom.xml @@ -27,8 +27,9 @@ kinesis-firehose lambda redshift - s3 - sqs + ses sns + sqs + s3 diff --git a/system-x/services/aws/ses/pom.xml b/system-x/services/aws/ses/pom.xml new file mode 100644 index 000000000..d8f760430 --- /dev/null +++ b/system-x/services/aws/ses/pom.xml @@ -0,0 +1,28 @@ + + + + system-x-aws + software.tnb + 1.0-SNAPSHOT + + 4.0.0 + + system-x-aws-ses + 1.0-SNAPSHOT + TNB :: System-X :: Services :: AWS :: SES + + + + software.tnb + system-x-aws-common + 1.0-SNAPSHOT + + + software.amazon.awssdk + ses + ${aws.clients.version} + + + diff --git a/system-x/services/aws/ses/src/main/java/software/tnb/aws/ses/account/SESAccount.java b/system-x/services/aws/ses/src/main/java/software/tnb/aws/ses/account/SESAccount.java new file mode 100644 index 000000000..3ee2495a9 --- /dev/null +++ b/system-x/services/aws/ses/src/main/java/software/tnb/aws/ses/account/SESAccount.java @@ -0,0 +1,20 @@ +package software.tnb.aws.ses.account; + +import software.tnb.aws.common.account.AWSAccount; + +import java.util.Map; + +/** + * You need to verify that you own either a domain or an email address, so the identities need to be pre-configured in SES + */ +public class SESAccount extends AWSAccount { + private Map identities; + + public String identity(String key) { + return identities.get(key); + } + + public void setIdentities(Map identities) { + this.identities = identities; + } +} diff --git a/system-x/services/aws/ses/src/main/java/software/tnb/aws/ses/service/SES.java b/system-x/services/aws/ses/src/main/java/software/tnb/aws/ses/service/SES.java new file mode 100644 index 000000000..918bb5597 --- /dev/null +++ b/system-x/services/aws/ses/src/main/java/software/tnb/aws/ses/service/SES.java @@ -0,0 +1,30 @@ +package software.tnb.aws.ses.service; + +import software.tnb.aws.common.service.AWSService; +import software.tnb.aws.ses.account.SESAccount; +import software.tnb.aws.ses.validation.SESValidation; +import software.tnb.common.account.Accounts; + +import org.junit.jupiter.api.extension.ExtensionContext; + +import com.google.auto.service.AutoService; + +import software.amazon.awssdk.services.ses.SesClient; + +@AutoService(SES.class) +public class SES extends AWSService { + @Override + public SESAccount account() { + if (account == null) { + LOG.debug("Creating new SES account"); + account = Accounts.get(SESAccount.class); + } + return account; + } + + @Override + public void beforeAll(ExtensionContext extensionContext) throws Exception { + LOG.debug("Creating new SQS validation"); + validation = new SESValidation(client(SesClient.class), account()); + } +} diff --git a/system-x/services/aws/ses/src/main/java/software/tnb/aws/ses/validation/SESValidation.java b/system-x/services/aws/ses/src/main/java/software/tnb/aws/ses/validation/SESValidation.java new file mode 100644 index 000000000..f8db752c2 --- /dev/null +++ b/system-x/services/aws/ses/src/main/java/software/tnb/aws/ses/validation/SESValidation.java @@ -0,0 +1,21 @@ +package software.tnb.aws.ses.validation; + +import software.tnb.aws.ses.account.SESAccount; +import software.tnb.common.service.Validation; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import software.amazon.awssdk.services.ses.SesClient; + +public class SESValidation implements Validation { + private static final Logger LOG = LoggerFactory.getLogger(SESValidation.class); + + private final SesClient client; + private final SESAccount account; + + public SESValidation(SesClient client, SESAccount account) { + this.client = client; + this.account = account; + } +}