From 3e0cd437d760b2215b8d92a8040574edc068c969 Mon Sep 17 00:00:00 2001 From: Jimmy Liu Jia <91264074+JimmyLiuJia@users.noreply.github.com> Date: Mon, 16 Nov 2026 20:40:08 +0800 Subject: [PATCH] feat(cloudformation): provision SES configuration sets (#8551) * feat(cloudformation): provision SES configuration sets * refactor(cloudformation): simplify SES configuration set provisioning --- docs/services/cloudformation.md | 2 +- .../provisioners/SesCfnProvisioner.java | 59 +++++- .../create-only-properties.json | 3 + ...ionSesConfigurationSetIntegrationTest.java | 164 ++++++++++++++++ .../provisioners/ProvisionContexts.java | 1 + .../provisioners/SesCfnProvisionerTest.java | 183 ++++++++++++++++++ .../cloudformation/schema-surface.tsv | 1 + .../supported-resource-types.tsv | 1 + .../cloudformation/writable-property-gaps.tsv | 8 + tools/docs/cfn_resource_types.yaml | 1 + 10 files changed, 419 insertions(+), 4 deletions(-) create mode 100644 src/test/java/io/floci/aws/services/cloudformation/CloudFormationSesConfigurationSetIntegrationTest.java diff --git a/docs/services/cloudformation.md b/docs/services/cloudformation.md index a1ebeb9e21..f6cc14cde1 100644 --- a/docs/services/cloudformation.md +++ b/docs/services/cloudformation.md @@ -207,7 +207,7 @@ cross-resource references. | S3 Vectors | `VectorBucket`, `Index` | | SQS | `Queue`, `QueuePolicy` (accepted; policy not enforced) | | SNS | `Topic`, `Subscription`, `TopicPolicy` | -| SES | `EmailIdentity` (BYODKIM is not supported by this resource; Easy DKIM DNS attributes use the shared emulator signing zone `dkim.amazonses.com` rather than AWS's region- and identity-specific zone assignment), `ReceiptRule` (stored in an existing SES receipt rule set; Ref and RuleName return the rule name; management plane only, with no inbound mail delivery) | +| SES | `ConfigurationSet` (only `Name` is supported; option and tag properties fail validation instead of being silently ignored; Ref returns the set name), `EmailIdentity` (BYODKIM is not supported by this resource; Easy DKIM DNS attributes use the shared emulator signing zone `dkim.amazonses.com` rather than AWS's region- and identity-specific zone assignment), `ReceiptRule` (stored in an existing SES receipt rule set; Ref and RuleName return the rule name; management plane only, with no inbound mail delivery) | | DynamoDB | `Table` (`TimeToLiveSpecification` applied on create and update; to rename an enabled TTL attribute, disable TTL in one update and enable the new attribute in a later one. `KinesisStreamSpecification` applied on create and update; with the DynamoDB Local backend, `StreamArn` is checked as on AWS but nothing is forwarded), `GlobalTable` | | Lambda | `Function` (Zip via S3/inline `ZipFile`, Image, and the `hot-reload` bind-mount bucket), `LayerVersion`, `EventSourceMapping` (SQS, Kinesis, DynamoDB Streams; `ParallelizationFactor` and `TumblingWindowInSeconds` are ignored), `Version`, `Alias` (also what SAM's `AutoPublishAlias` expands into), `Permission`, `CodeSigningConfig`, `EventInvokeConfig` (also what a SAM function's `EventInvokeConfig` expands into), `MicrovmImage`, `NetworkConnector`, `Url`, `WebFunction` (control plane only; the endpoint domain does not serve requests yet), `WebFunctionEndpoint`, `WebFunctionRevision` (every property is createOnly, so a change mints a new revision). Inline `ZipFile` packages include the `cfn-response` (Node.js) / `cfnresponse` (Python) module AWS injects for that code path, so Solutions-style custom-resource handlers work. | | Signer | `SigningProfile` (identifiers only; Floci has no Signer API) | diff --git a/src/main/java/io/floci/aws/services/cloudformation/provisioners/SesCfnProvisioner.java b/src/main/java/io/floci/aws/services/cloudformation/provisioners/SesCfnProvisioner.java index b6614b6e67..e85ba3d9e8 100644 --- a/src/main/java/io/floci/aws/services/cloudformation/provisioners/SesCfnProvisioner.java +++ b/src/main/java/io/floci/aws/services/cloudformation/provisioners/SesCfnProvisioner.java @@ -8,6 +8,7 @@ import io.floci.aws.core.common.AwsException; import io.floci.aws.services.cloudformation.model.StackResource; import io.floci.aws.services.ses.SesIdentityService; import io.floci.aws.services.ses.SesService; +import io.floci.aws.services.ses.model.ConfigurationSet; import io.floci.aws.services.ses.model.Identity; import io.floci.aws.services.ses.model.Tag; import jakarta.enterprise.context.ApplicationScoped; @@ -25,6 +26,7 @@ import java.util.Set; public class SesCfnProvisioner implements CfnResourceProvisioner { private static final String TYPE = "AWS::SES::EmailIdentity"; + private static final String CONFIGURATION_SET_TYPE = "AWS::SES::ConfigurationSet"; private static final String DEFAULT_KEY_LENGTH = "RSA_2048_BIT"; private static final String MANAGED_TAGS_ATTR = "__FlociSesManagedTags"; private static final String UPDATE_SNAPSHOT_ATTR = "__FlociSesUpdateSnapshot"; @@ -40,11 +42,19 @@ public class SesCfnProvisioner implements CfnResourceProvisioner { @Override public Set resourceTypes() { - return Set.of(TYPE); + return Set.of(TYPE, CONFIGURATION_SET_TYPE); } @Override public void provision(StackResource resource, JsonNode props, ProvisionContext ctx) { + switch (resource.getResourceType()) { + case CONFIGURATION_SET_TYPE -> provisionConfigurationSet(resource, props, ctx); + case TYPE -> provisionIdentity(resource, props, ctx); + default -> throw invalid("Unsupported SES resource type " + resource.getResourceType() + "."); + } + } + + private void provisionIdentity(StackResource resource, JsonNode props, ProvisionContext ctx) { Properties desired = readProperties(props, ctx); boolean recoveredSnapshot = false; if (resource.getAttributes().containsKey(UPDATE_SNAPSHOT_ATTR)) { @@ -113,7 +123,46 @@ public class SesCfnProvisioner implements CfnResourceProvisioner { @Override public void delete(String resourceType, String physicalId, String region) { - sesService.deleteIdentity(physicalId, region); + if (CONFIGURATION_SET_TYPE.equals(resourceType)) { + CfnDeletes.safeDelete("SES configuration set", physicalId, + () -> sesService.deleteConfigurationSet(physicalId, region), "ConfigurationSetDoesNotExist"); + } else { + sesService.deleteIdentity(physicalId, region); + } + } + + private void provisionConfigurationSet(StackResource resource, JsonNode props, ProvisionContext ctx) { + JsonNode resolved = props == null ? null : ctx.engine().resolveNodeOmittingNoValue(props); + if (resolved != null && !resolved.isObject()) { + throw invalid("Properties must be an object."); + } + if (resolved != null) { + validateKeys(resolved, Set.of("Name"), "Properties"); + } + String explicitName = optionalText(resolved, "Name"); + if (explicitName != null && explicitName.isBlank()) { + throw invalid("Name must not be empty."); + } + boolean declaredReplacement = ctx.isUpdate() + && ctx.changes(CONFIGURATION_SET_TYPE, props).requiresReplacement(); + String name = declaredReplacement && explicitName == null + ? ctx.generatePhysicalName(resource.getLogicalId(), 64, false) + : ctx.stablePhysicalName(explicitName, resource.getLogicalId(), 64, false); + boolean replacing = ctx.isUpdate() + && (declaredReplacement || !name.equals(ctx.priorPhysicalId())); + if (replacing && name.equals(ctx.priorPhysicalId())) { + throw CfnExceptions.customNamedReplacement(name); + } + + Map attributesBefore = new HashMap<>(resource.getAttributes()); + boolean priorStub = ctx.isUpdate() + && CfnResourceDispatcher.isStub(ctx.priorPhysicalId(), attributesBefore); + boolean created = !ctx.reusesPriorEntity(name) || priorStub; + if (created) { + sesService.createConfigurationSet(new ConfigurationSet(name), ctx.region()); + } + resource.setPhysicalId(name); + ReplacementCleanup.record(resource, ctx, attributesBefore, replacing); } @Override @@ -121,7 +170,7 @@ public class SesCfnProvisioner implements CfnResourceProvisioner { UpdateCleanupResult cleanup = ReplacementCleanup.complete(resource, this::delete); if (cleanup.applicable() && !cleanup.complete()) { throw new AwsException("InternalFailure", - "Could not delete displaced SES identity " + cleanup.previousPhysicalId() + "Could not delete displaced SES resource " + cleanup.previousPhysicalId() + ": " + cleanup.failureReason(), 500); } delete(resource.getResourceType(), resource.getPhysicalId(), region); @@ -185,6 +234,10 @@ public class SesCfnProvisioner implements CfnResourceProvisioner { @Override public boolean rollbackUpdate(StackResource resource) { + if (CONFIGURATION_SET_TYPE.equals(resource.getResourceType())) { + ReplacementCleanup.rollback(resource, this::delete); + return true; + } if (ReplacementCleanup.rollback(resource, this::delete)) { restoreManagedTags(resource, readSnapshot(resource)); resource.getAttributes().remove(UPDATE_SNAPSHOT_ATTR); diff --git a/src/main/resources/cloudformation/create-only-properties.json b/src/main/resources/cloudformation/create-only-properties.json index 378be72e6c..c61e3169ce 100644 --- a/src/main/resources/cloudformation/create-only-properties.json +++ b/src/main/resources/cloudformation/create-only-properties.json @@ -905,6 +905,9 @@ "VectorBucketName", "EncryptionConfiguration" ], + "AWS::SES::ConfigurationSet": [ + "Name" + ], "AWS::SES::EmailIdentity": [ "EmailIdentity" ], diff --git a/src/test/java/io/floci/aws/services/cloudformation/CloudFormationSesConfigurationSetIntegrationTest.java b/src/test/java/io/floci/aws/services/cloudformation/CloudFormationSesConfigurationSetIntegrationTest.java new file mode 100644 index 0000000000..08a3777c9c --- /dev/null +++ b/src/test/java/io/floci/aws/services/cloudformation/CloudFormationSesConfigurationSetIntegrationTest.java @@ -0,0 +1,164 @@ +package io.floci.aws.services.cloudformation; + +import io.floci.aws.services.ses.SesConfigurationSetService; +import io.floci.aws.services.ses.SesIdentityService; +import io.floci.aws.testing.AwsTestClients; +import io.floci.aws.testing.CfnStackWaits; +import io.quarkus.test.junit.QuarkusTest; +import jakarta.inject.Inject; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import software.amazon.awssdk.regions.Region; +import software.amazon.awssdk.services.cloudformation.CloudFormationClient; +import software.amazon.awssdk.services.cloudformation.model.CloudFormationException; +import software.amazon.awssdk.services.cloudformation.model.Stack; + +import java.time.Duration; + +import static org.awaitility.Awaitility.await; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; + +@QuarkusTest +class CloudFormationSesConfigurationSetIntegrationTest { + private CloudFormationClient cfn; + private String stackName; + private boolean deleted; + + @Inject + SesConfigurationSetService configurationSets; + + @Inject + SesIdentityService identities; + + @BeforeEach + void setUp() { + cfn = AwsTestClients.create(CloudFormationClient.builder(), "test", Region.US_EAST_1); + stackName = "cfn-ses-set-" + Long.toString(System.nanoTime(), 36); + deleted = false; + } + + @AfterEach + void cleanUp() { + try { + if (!deleted) { + cfn.deleteStack(request -> request.stackName(stackName)); + await().atMost(Duration.ofSeconds(15)).until(this::stackIsGone); + } + } finally { + cfn.close(); + } + } + + @Test + void configurationSetRefCreatesTheSetBeforeItsEmailIdentityAndDeletesBoth() { + String setName = stackName + "-delivery"; + String email = stackName + "@example.com"; + String template = """ + { + "AWSTemplateFormatVersion": "2010-09-09", + "Resources": { + "ConfigurationSet": { + "Type": "AWS::SES::ConfigurationSet", + "Properties": {"Name": "%s"} + }, + "Identity": { + "Type": "AWS::SES::EmailIdentity", + "Properties": { + "EmailIdentity": "%s", + "ConfigurationSetAttributes": { + "ConfigurationSetName": {"Ref": "ConfigurationSet"} + } + } + } + }, + "Outputs": { + "ConfigurationSetRef": {"Value": {"Ref": "ConfigurationSet"}} + } + } + """.formatted(setName, email); + + cfn.createStack(request -> request.stackName(stackName).templateBody(template)); + Stack stack = CfnStackWaits.awaitStatus(cfn, stackName, "CREATE_COMPLETE"); + + assertEquals(setName, stack.outputs().getFirst().outputValue()); + assertEquals(setName, configurationSets.get(setName, "us-east-1").getName()); + assertEquals(setName, identities.getIdentityVerificationAttributes(email, "us-east-1") + .getConfigurationSetName()); + + cfn.deleteStack(request -> request.stackName(stackName)); + await().atMost(Duration.ofSeconds(15)).untilAsserted(() -> { + assertNull(configurationSets.find(setName, "us-east-1").orElse(null)); + assertNull(identities.getIdentityVerificationAttributes(email, "us-east-1")); + }); + await().atMost(Duration.ofSeconds(15)).until(this::stackIsGone); + deleted = true; + } + + @Test + void addingTheExistingGeneratedNameRollsBackAfterADependentResourceFails() { + String generated = createUnnamedConfigurationSet(); + updateWithDependentFailure(generated); + + Stack rolledBack = CfnStackWaits.awaitStatus(cfn, stackName, "UPDATE_ROLLBACK_COMPLETE"); + assertEquals(generated, rolledBack.outputs().getFirst().outputValue()); + assertEquals(generated, configurationSets.get(generated, "us-east-1").getName()); + } + + @Test + void replacingTheGeneratedNameRollsBackAfterADependentResourceFails() { + String generated = createUnnamedConfigurationSet(); + String replacement = stackName + "-named"; + updateWithDependentFailure(replacement); + + Stack rolledBack = CfnStackWaits.awaitStatus(cfn, stackName, "UPDATE_ROLLBACK_COMPLETE"); + assertEquals(generated, rolledBack.outputs().getFirst().outputValue()); + assertEquals(generated, configurationSets.get(generated, "us-east-1").getName()); + assertNull(configurationSets.find(replacement, "us-east-1").orElse(null)); + } + + private String createUnnamedConfigurationSet() { + String initialTemplate = """ + { + "Resources": { + "ConfigurationSet": {"Type": "AWS::SES::ConfigurationSet", "Properties": {}} + }, + "Outputs": {"ConfigurationSetRef": {"Value": {"Ref": "ConfigurationSet"}}} + } + """; + cfn.createStack(request -> request.stackName(stackName).templateBody(initialTemplate)); + return CfnStackWaits.awaitStatus(cfn, stackName, "CREATE_COMPLETE") + .outputs().getFirst().outputValue(); + } + + private void updateWithDependentFailure(String name) { + String updatedTemplate = """ + { + "Resources": { + "ConfigurationSet": { + "Type": "AWS::SES::ConfigurationSet", + "Properties": {"Name": "%s"} + }, + "BadSecret": { + "Type": "AWS::SecretsManager::Secret", + "Properties": { + "SecretString": {"Ref": "ConfigurationSet"}, + "GenerateSecretString": {"PasswordLength": 8} + } + } + }, + "Outputs": {"ConfigurationSetRef": {"Value": {"Ref": "ConfigurationSet"}}} + } + """.formatted(name); + cfn.updateStack(request -> request.stackName(stackName).templateBody(updatedTemplate)); + } + + private boolean stackIsGone() { + try { + return cfn.describeStacks(request -> request.stackName(stackName)).stacks().isEmpty(); + } catch (CloudFormationException expected) { + return expected.statusCode() == 400; + } + } +} diff --git a/src/test/java/io/floci/aws/services/cloudformation/provisioners/ProvisionContexts.java b/src/test/java/io/floci/aws/services/cloudformation/provisioners/ProvisionContexts.java index 8b770b0434..4ad4f66142 100644 --- a/src/test/java/io/floci/aws/services/cloudformation/provisioners/ProvisionContexts.java +++ b/src/test/java/io/floci/aws/services/cloudformation/provisioners/ProvisionContexts.java @@ -31,6 +31,7 @@ public final class ProvisionContexts { return node == null || node.isMissingNode() || node.isNull() ? null : node.asText(); }); when(engine.resolveNode(any())).thenAnswer(inv -> inv.getArgument(0)); + when(engine.resolveNodeOmittingNoValue(any())).thenAnswer(inv -> inv.getArgument(0)); return engine; } diff --git a/src/test/java/io/floci/aws/services/cloudformation/provisioners/SesCfnProvisionerTest.java b/src/test/java/io/floci/aws/services/cloudformation/provisioners/SesCfnProvisionerTest.java index cc4e734663..bf4846212a 100644 --- a/src/test/java/io/floci/aws/services/cloudformation/provisioners/SesCfnProvisionerTest.java +++ b/src/test/java/io/floci/aws/services/cloudformation/provisioners/SesCfnProvisionerTest.java @@ -7,6 +7,7 @@ import io.floci.aws.services.cloudformation.CloudFormationTemplateEngine; import io.floci.aws.services.cloudformation.model.StackResource; import io.floci.aws.services.ses.SesIdentityService; import io.floci.aws.services.ses.SesService; +import io.floci.aws.services.ses.model.ConfigurationSet; import io.floci.aws.services.ses.model.Identity; import io.floci.aws.services.ses.model.Tag; import org.junit.jupiter.api.Test; @@ -16,14 +17,17 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertSame; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.isNull; import static org.mockito.Mockito.doThrow; @@ -576,6 +580,171 @@ class SesCfnProvisionerTest { assertFalse(provisioner.hasReplacementUpdate(resource)); } + @Test + void createUsesNameAsRefAndDeletesTheBackingSet() throws Exception { + StackResource resource = configurationSetResource(null); + + provisioner.provision(resource, props("{\"Name\":\"delivery\"}"), context(null)); + + assertEquals("delivery", resource.getPhysicalId()); + verify(ses).createConfigurationSet(argThat(set -> "delivery".equals(set.getName())), eq("us-east-1")); + provisioner.delete(resource, "us-east-1"); + verify(ses).deleteConfigurationSet("delivery", "us-east-1"); + } + + @Test + void generatedNameRemainsStableOnAnInPlaceUpdate() throws Exception { + StackResource resource = configurationSetResource(null); + JsonNode properties = props("{}"); + provisioner.provision(resource, properties, context(null)); + String generated = resource.getPhysicalId(); + + provisioner.provision(resource, properties, configurationSetUpdateContext(generated, properties)); + + assertTrue(generated.startsWith("ses-stack-ConfigurationSet-")); + assertTrue(generated.length() <= 64); + assertEquals(generated, resource.getPhysicalId()); + verify(ses, times(1)).createConfigurationSet(any(ConfigurationSet.class), eq("us-east-1")); + } + + @Test + void declaringTheExistingGeneratedNameNeedsNoReplacementOrRollbackWork() throws Exception { + StackResource resource = configurationSetResource(null); + JsonNode previous = props("{}"); + provisioner.provision(resource, previous, context(null)); + String generated = resource.getPhysicalId(); + + provisioner.provision(resource, props("{\"Name\":\"" + generated + "\"}"), + configurationSetUpdateContext(generated, previous)); + + assertFalse(provisioner.hasReplacementUpdate(resource)); + assertTrue(provisioner.rollbackUpdate(resource)); + assertEquals(generated, resource.getPhysicalId()); + verify(ses, never()).deleteConfigurationSet(any(), any()); + } + + @Test + void renameCreatesReplacementAndDeletesOldSetAfterCommit() throws Exception { + StackResource resource = configurationSetResource("old"); + JsonNode previous = props("{\"Name\":\"old\"}"); + + provisioner.provision(resource, props("{\"Name\":\"new\"}"), + configurationSetUpdateContext("old", previous)); + + assertEquals("new", resource.getPhysicalId()); + assertTrue(provisioner.hasReplacementUpdate(resource)); + verify(ses).createConfigurationSet(argThat(set -> "new".equals(set.getName())), eq("us-east-1")); + assertTrue(provisioner.completeUpdate(resource).complete()); + verify(ses).deleteConfigurationSet("old", "us-east-1"); + } + + @Test + void removingAnExplicitNameGeneratesAReplacement() throws Exception { + StackResource resource = configurationSetResource("old"); + + provisioner.provision(resource, props("{}"), + configurationSetUpdateContext("old", props("{\"Name\":\"old\"}"))); + + assertNotEquals("old", resource.getPhysicalId()); + assertTrue(resource.getPhysicalId().startsWith("ses-stack-ConfigurationSet-")); + assertTrue(provisioner.hasReplacementUpdate(resource)); + provisioner.completeUpdate(resource); + verify(ses).deleteConfigurationSet("old", "us-east-1"); + } + + @Test + void assigningAnExplicitNameReplacesAndDeletesTheGeneratedSet() throws Exception { + StackResource resource = configurationSetResource(null); + JsonNode previous = props("{}"); + provisioner.provision(resource, previous, context(null)); + String generated = resource.getPhysicalId(); + + provisioner.provision(resource, props("{\"Name\":\"named\"}"), + configurationSetUpdateContext(generated, previous)); + + assertEquals("named", resource.getPhysicalId()); + assertTrue(provisioner.hasReplacementUpdate(resource)); + assertTrue(provisioner.completeUpdate(resource).complete()); + verify(ses).deleteConfigurationSet(generated, "us-east-1"); + } + + @Test + void assigningAnExplicitNameRollsBackToTheGeneratedSet() throws Exception { + StackResource resource = configurationSetResource(null); + JsonNode previous = props("{}"); + provisioner.provision(resource, previous, context(null)); + String generated = resource.getPhysicalId(); + + provisioner.provision(resource, props("{\"Name\":\"named\"}"), + configurationSetUpdateContext(generated, previous)); + + assertTrue(provisioner.rollbackUpdate(resource)); + assertEquals(generated, resource.getPhysicalId()); + verify(ses).deleteConfigurationSet("named", "us-east-1"); + verify(ses, never()).deleteConfigurationSet(generated, "us-east-1"); + } + + @Test + void failedStackUpdateRestoresOldRefAndDeletesOnlyTheNewSet() throws Exception { + StackResource resource = configurationSetResource("old"); + + provisioner.provision(resource, props("{\"Name\":\"new\"}"), + configurationSetUpdateContext("old", props("{\"Name\":\"old\"}"))); + + assertTrue(provisioner.rollbackUpdate(resource)); + assertEquals("old", resource.getPhysicalId()); + assertFalse(provisioner.hasReplacementUpdate(resource)); + verify(ses).deleteConfigurationSet("new", "us-east-1"); + verify(ses, never()).deleteConfigurationSet("old", "us-east-1"); + } + + @Test + void retainPolicyLeavesDisplacedSetAndDeletesCurrentSet() throws Exception { + StackResource resource = configurationSetResource("old"); + resource.setUpdateReplacePolicy("Retain"); + provisioner.provision(resource, props("{\"Name\":\"new\"}"), + configurationSetUpdateContext("old", props("{\"Name\":\"old\"}"))); + + provisioner.completeUpdate(resource); + provisioner.delete(resource, "us-east-1"); + + verify(ses, never()).deleteConfigurationSet("old", "us-east-1"); + verify(ses).deleteConfigurationSet("new", "us-east-1"); + } + + @Test + void unsupportedOptionsFailBeforeCreation() throws Exception { + StackResource resource = configurationSetResource(null); + + AwsException failure = assertThrows(AwsException.class, () -> provisioner.provision(resource, + props("{\"Name\":\"delivery\",\"SendingOptions\":{\"SendingEnabled\":false}}"), + context(null))); + + assertEquals("ValidationError", failure.getErrorCode()); + verify(ses, never()).createConfigurationSet(any(ConfigurationSet.class), any()); + } + + @Test + void blankExplicitNameFailsBeforeCreation() throws Exception { + AwsException failure = assertThrows(AwsException.class, () -> provisioner.provision( + configurationSetResource(null), props("{\"Name\":\"\"}"), context(null))); + + assertEquals("ValidationError", failure.getErrorCode()); + verify(ses, never()).createConfigurationSet(any(ConfigurationSet.class), any()); + } + + @Test + void deletionToleratesOnlyMissingConfigurationSet() { + doThrow(new AwsException("ConfigurationSetDoesNotExist", "gone", 400)) + .when(ses).deleteConfigurationSet("gone", "us-east-1"); + doThrow(new AwsException("InternalFailure", "failed", 500)) + .when(ses).deleteConfigurationSet("failed", "us-east-1"); + + assertDoesNotThrow(() -> provisioner.delete("AWS::SES::ConfigurationSet", "gone", "us-east-1")); + assertThrows(AwsException.class, + () -> provisioner.delete("AWS::SES::ConfigurationSet", "failed", "us-east-1")); + } + private Identity domain(String name) { Identity identity = new Identity(name, "Domain"); identity.setDkimEnabled(true); @@ -591,6 +760,20 @@ class SesCfnProvisionerTest { return resource; } + private StackResource configurationSetResource(String physicalId) { + StackResource resource = resource(); + resource.setLogicalId("ConfigurationSet"); + resource.setResourceType("AWS::SES::ConfigurationSet"); + resource.setPhysicalId(physicalId); + return resource; + } + + private ProvisionContext configurationSetUpdateContext(String priorPhysicalId, JsonNode priorProperties) + throws Exception { + return ProvisionContexts.update("us-east-1", "000000000000", "ses-stack", + priorPhysicalId, priorProperties.toString()); + } + private ProvisionContext context(String priorPhysicalId) { CloudFormationTemplateEngine engine = mock(CloudFormationTemplateEngine.class); when(engine.resolveNode(any())).thenAnswer(call -> call.getArgument(0)); diff --git a/src/test/resources/cloudformation/schema-surface.tsv b/src/test/resources/cloudformation/schema-surface.tsv index 7ee3e978ce..c16783f9b8 100644 --- a/src/test/resources/cloudformation/schema-surface.tsv +++ b/src/test/resources/cloudformation/schema-surface.tsv @@ -185,6 +185,7 @@ AWS::S3::Bucket Arn,DomainName,DualStackDomainName,RegionalDomainName,WebsiteURL AWS::S3::BucketPolicy Bucket,PolicyDocument AWS::S3Vectors::Index CreationTime,IndexArn DataType,Dimension,DistanceMetric,EncryptionConfiguration,IndexName,MetadataConfiguration,Tags,VectorBucketArn,VectorBucketName AWS::S3Vectors::VectorBucket CreationTime,VectorBucketArn EncryptionConfiguration,Tags,VectorBucketName +AWS::SES::ConfigurationSet ArchivingOptions,DeliveryOptions,Name,ReputationOptions,SendingOptions,SuppressionOptions,Tags,TrackingOptions,VdmOptions AWS::SES::EmailIdentity DkimDNSTokenName1,DkimDNSTokenName2,DkimDNSTokenName3,DkimDNSTokenValue1,DkimDNSTokenValue2,DkimDNSTokenValue3 ConfigurationSetAttributes,DkimAttributes,DkimSigningAttributes,EmailIdentity,FeedbackAttributes,MailFromAttributes,Tags AWS::SES::ReceiptRule RuleName After,Rule,RuleSetName AWS::SNS::Subscription Arn DeliveryPolicy,Endpoint,FilterPolicy,FilterPolicyScope,Protocol,RawMessageDelivery,RedrivePolicy,Region,ReplayPolicy,SubscriptionRoleArn,TopicArn diff --git a/src/test/resources/cloudformation/supported-resource-types.tsv b/src/test/resources/cloudformation/supported-resource-types.tsv index 1756920ff3..516e127672 100644 --- a/src/test/resources/cloudformation/supported-resource-types.tsv +++ b/src/test/resources/cloudformation/supported-resource-types.tsv @@ -186,6 +186,7 @@ AWS::S3::Bucket S3CfnProvisioner AWS::S3::BucketPolicy S3CfnProvisioner AWS::S3Vectors::Index S3VectorsCfnProvisioner AWS::S3Vectors::VectorBucket S3VectorsCfnProvisioner +AWS::SES::ConfigurationSet SesCfnProvisioner AWS::SES::EmailIdentity SesCfnProvisioner AWS::SES::ReceiptRule SesReceiptRuleCfnProvisioner AWS::SNS::Subscription SnsCfnProvisioner diff --git a/src/test/resources/cloudformation/writable-property-gaps.tsv b/src/test/resources/cloudformation/writable-property-gaps.tsv index c7d203c80a..1292bb2d75 100644 --- a/src/test/resources/cloudformation/writable-property-gaps.tsv +++ b/src/test/resources/cloudformation/writable-property-gaps.tsv @@ -632,6 +632,14 @@ AWS::S3::Bucket ObjectLockConfiguration silently dropped, as the S3CfnProvisione AWS::S3::Bucket ObjectLockEnabled accepted and ignored AWS::S3::Bucket ReplicationConfiguration silently dropped, as the S3CfnProvisioner javadoc records AWS::S3::Bucket WebsiteConfiguration silently dropped, as the S3CfnProvisioner javadoc records +AWS::SES::ConfigurationSet ArchivingOptions explicitly rejected; only the Name property is currently provisioned +AWS::SES::ConfigurationSet DeliveryOptions explicitly rejected; only the Name property is currently provisioned +AWS::SES::ConfigurationSet ReputationOptions explicitly rejected; only the Name property is currently provisioned +AWS::SES::ConfigurationSet SendingOptions explicitly rejected; only the Name property is currently provisioned +AWS::SES::ConfigurationSet SuppressionOptions explicitly rejected; only the Name property is currently provisioned +AWS::SES::ConfigurationSet Tags explicitly rejected; only the Name property is currently provisioned +AWS::SES::ConfigurationSet TrackingOptions explicitly rejected; only the Name property is currently provisioned +AWS::SES::ConfigurationSet VdmOptions explicitly rejected; only the Name property is currently provisioned AWS::SNS::Subscription DeliveryPolicy accepted and ignored AWS::SNS::Subscription Region accepted and ignored AWS::SNS::Subscription ReplayPolicy accepted and ignored diff --git a/tools/docs/cfn_resource_types.yaml b/tools/docs/cfn_resource_types.yaml index e8a1fff252..0e50151ed3 100644 --- a/tools/docs/cfn_resource_types.yaml +++ b/tools/docs/cfn_resource_types.yaml @@ -230,6 +230,7 @@ notes: AWS::DynamoDB::Table: '`TimeToLiveSpecification` applied on create and update; to rename an enabled TTL attribute, disable TTL in one update and enable the new attribute in a later one. `KinesisStreamSpecification` applied on create and update; with the DynamoDB Local backend, `StreamArn` is checked as on AWS but nothing is forwarded' AWS::Cognito::UserPool: '`ProviderURL` is the local issuer of the tokens Floci mints, `/`; `EnabledMfas` is applied with `SetUserPoolMfaConfig`, as on AWS, and once `SMS_MFA` is on only `MfaConfiguration: OFF` turns it off' AWS::Cognito::UserPoolIdentityProvider: 'Ref returns the ProviderName; changing only `ProviderType` is refused, as on AWS, because the name is always the template''s and the replacement would need the same address' + AWS::SES::ConfigurationSet: 'only `Name` is supported; option and tag properties fail validation instead of being silently ignored; Ref returns the set name' AWS::SES::EmailIdentity: 'BYODKIM is not supported by this resource; Easy DKIM DNS attributes use the shared emulator signing zone `dkim.amazonses.com` rather than AWS''s region- and identity-specific zone assignment' AWS::SES::ReceiptRule: 'stored in an existing SES receipt rule set; Ref and RuleName return the rule name; management plane only, with no inbound mail delivery' AWS::Events::Archive: '`KmsKeyIdentifier` is ignored'