Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SES: Email template unicode support is broken #33285

Open
1 task
dkuzmenko-dsr opened this issue Feb 4, 2025 · 2 comments
Open
1 task

SES: Email template unicode support is broken #33285

dkuzmenko-dsr opened this issue Feb 4, 2025 · 2 comments
Labels
@aws-cdk/aws-ses Related to Amazon Simple Email Service bug This issue is a bug. needs-cfn This issue is waiting on changes to CloudFormation before it can be addressed. p2

Comments

@dkuzmenko-dsr
Copy link

Describe the bug

I run into the issue on using CDK import of aws_ses.CfnTemplate resource. Imported email templates into a CDK stack I've started to get errors on each following cdk import run reporting that email templates has been modified and cdk cannot do import on modified stacks.

Meanwhile not CDK diff nor drift detection report any difference.

I've tried to perform a modification in a template and got that little modification will rewrite all the fields in the template. Also server side template is looking like all unicode characters was replaced with question marks (?).

Removing all unicode symbols from email template fixes the issue.

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Version

No response

Expected Behavior

Resources
[~] AWS::SES::Template SesEmailTemplates/UnicodeTestTemplate SesEmailTemplatesUnicodeTestTemplateB22B733D may be replaced
 └─ [~] Template (may cause replacement)
     └─ [~] .SubjectPart:
         ├─ [-] Unicode ® char.
         └─ [+] Unicode ® char

Current Behavior

Resources
[~] AWS::SES::Template SesEmailTemplates/UnicodeTestTemplate SesEmailTemplatesUnicodeTestTemplateB22B733D may be replaced
 └─ [~] Template (may cause replacement)
     ├─ [~] .HtmlPart:
     │   ├─ [-] Unicode ? char.
     │   └─ [+] Unicode ® char.
     ├─ [~] .SubjectPart:
     │   ├─ [-] Unicode ? char.
     │   └─ [+] Unicode ® char.
     └─ [~] .TextPart:
         ├─ [-] Unicode ? char.
         └─ [+] Unicode ® char

Reproduction Steps

  1. Deploy this construct in a stack.
    new ses.CfnTemplate(
      this,
      "UnicodeTestTemplate",
      {

        template: {
          templateName: "UnicodeTestTemplate",
          subjectPart: "Unicode ® char.",
          textPart: "Unicode ® char.",
          htmlPart: "Unicode ® char.",

        },
      }
    );

The result is good and diff is empty after deploy.

  1. Update one field in the template, like remove point from subjectPart.
  2. Run cdk diff (I've also tried cdk diff --strict, result is the same) and look at the result.

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.177.0

Framework Version

No response

Node.js Version

22.13.1

OS

Arch Linux

Language

TypeScript

Language Version

5.6.3

Other information

No response

@dkuzmenko-dsr dkuzmenko-dsr added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Feb 4, 2025
@github-actions github-actions bot added the @aws-cdk/aws-ses Related to Amazon Simple Email Service label Feb 4, 2025
@ashishdhingra ashishdhingra self-assigned this Feb 4, 2025
@ashishdhingra ashishdhingra added package/tools Related to AWS CDK Tools or CLI p2 investigating This issue is being investigated and/or work is in progress to resolve the issue. and removed needs-triage This issue or PR still needs to be triaged. labels Feb 4, 2025
@ashishdhingra
Copy link
Contributor

Reproducible locally where cdk diff displays the below output after following reproduction steps:

Resources
[~] AWS::SES::Template UnicodeTestTemplate UnicodeTestTemplate may be replaced
 └─ [~] Template (may cause replacement)
     ├─ [~] .HtmlPart:
     │   ├─ [-] Unicode ? char.
     │   └─ [+] Unicode ® char.
     ├─ [~] .SubjectPart:
     │   ├─ [-] Unicode ? char.
     │   └─ [+] Unicode ® char
     └─ [~] .TextPart:
         ├─ [-] Unicode ? char.
         └─ [+] Unicode ® char.


✨  Number of stacks with differences: 1

Manually updating the template in AWS CloudFormation console (upload from cdk.out directory) and viewing Changeset displays the following differences:

Image

Notice that in CloudFormation, it displays ? character for ® character.

Using AWS CLI:

  • Command aws cloudformation list-change-sets --stack-name CdktestStack displays the below output:
      {
        "Summaries": [
            {
                "StackId": "arn:aws:cloudformation:us-east-2:<<ACCOUNT-ID>>:stack/CdktestStack/5a8234c0-e331-11ef-a3d3-0af098d028b9",
                "StackName": "CdktestStack",
                "ChangeSetId": "arn:aws:cloudformation:us-east-2:<<ACCOUNT-ID>>:changeSet/CdktestSta-tajqkgrkem-sfyju1c13m/3c63df56-1890-4cf5-a69c-d029c2993d33",
                "ChangeSetName": "CdktestSta-tajqkgrkem-sfyju1c13m",
                "ExecutionStatus": "AVAILABLE",
                "Status": "CREATE_COMPLETE",
                "CreationTime": "2025-02-04T19:55:10.873000+00:00",
                "IncludeNestedStacks": false
            }
        ]
    }
  • Command aws cloudformation describe-change-set --change-set-name arn:aws:cloudformation:us-east-2:<<ACCOUNT-ID>>:changeSet/CdktestSta-tajqkgrkem-sfyju1c13m/3c63df56-1890-4cf5-a69c-d029c2993d33 --include-property-values displays the below output:
    {
        "Changes": [
            {
                "Type": "Resource",
                "ResourceChange": {
                    "Action": "Modify",
                    "LogicalResourceId": "UnicodeTestTemplate",
                    "PhysicalResourceId": "UnicodeTestTemplate",
                    "ResourceType": "AWS::SES::Template",
                    "Replacement": "False",
                    "Scope": [
                        "Properties"
                    ],
                    "Details": [
                        {
                            "Target": {
                                "Attribute": "Properties",
                                "Name": "Template",
                                "RequiresRecreation": "Never",
                                "Path": "/Properties/Template/SubjectPart",
                                "BeforeValue": "Unicode ? char.",
                                "AfterValue": "Unicode ? char",
                                "AttributeChangeType": "Modify"
                            },
                            "Evaluation": "Static",
                            "ChangeSource": "DirectModification"
                        }
                    ],
                  "BeforeContext": "{\"Properties\":{\"Template\":{\"HtmlPart\":\"Unicode ? char.\",\"TextPart\":\"Unicode ? char.\",\"TemplateName\":\"UnicodeTestTemplate\",\"SubjectPart\":\"Unicode ? char.\"}},\"Metadata\":{\"aws:cdk:path\":\"CdktestStack/UnicodeTestTemplate\"}}",
                  "AfterContext": "{\"Properties\":{\"Template\":{\"HtmlPart\":\"Unicode ? char.\",\"TextPart\":\"Unicode ? char.\",\"TemplateName\":\"UnicodeTestTemplate\",\"SubjectPart\":\"Unicode ? char\"}},\"Metadata\":{\"aws:cdk:path\":\"CdktestStack/UnicodeTestTemplate\"}}"
                }
            }
        ],
        "ChangeSetName": "CdktestSta-tajqkgrkem-sfyju1c13m",
        "ChangeSetId": "arn:aws:cloudformation:us-east-2:<<ACCOUNT-ID>>:changeSet/CdktestSta-tajqkgrkem-sfyju1c13m/3c63df56-1890-4cf5-a69c-d029c2993d33",
        "StackId": "arn:aws:cloudformation:us-east-2:<<ACCOUNT-ID>>:stack/CdktestStack/5a8234c0-e331-11ef-a3d3-0af098d028b9",
        "StackName": "CdktestStack",
        "Description": null,
        "Parameters": [
            {
                "ParameterKey": "BootstrapVersion",
                "ParameterValue": "/cdk-bootstrap/hnb659fds/version",
                "ResolvedValue": "25"
            }
        ],
        "CreationTime": "2025-02-04T19:55:10.873000+00:00",
        "ExecutionStatus": "AVAILABLE",
        "Status": "CREATE_COMPLETE",
        "StatusReason": null,
        "NotificationARNs": [],
        "RollbackConfiguration": {
            "RollbackTriggers": []
        },
        "Capabilities": [],
        "Tags": null,
        "ParentChangeSetId": null,
        "IncludeNestedStacks": false,
        "RootChangeSetId": null,
        "OnStackFailure": null,
        "ImportExistingResources": null
    }

If we examine the template in AWS CloudFormation console, below are the contents:

{
  "Resources": {
    "UnicodeTestTemplate": {
      "Type": "AWS::SES::Template",
      "Properties": {
        "Template": {
          "HtmlPart": "Unicode ? char.",
          "SubjectPart": "Unicode ? char",
          "TemplateName": "UnicodeTestTemplate",
          "TextPart": "Unicode ? char."
        }
      },
      "Metadata": {
        "aws:cdk:path": "CdktestStack/UnicodeTestTemplate"
      }
    },
    "CDKMetadata": {
      "Type": "AWS::CDK::Metadata",
      "Properties": {
        "Analytics": "v2:deflate64:H4sIAAAAAAAA/yXFSw5AMBAA0LN03w4VSe3dAHupGknpRzqlC3F3C2/zGpBKQc10IWHWQzi7wDNmbQ6uC82EBP0WJvSn0xl5v4UBKV7J4MtDXBF2qm7ZQVNDy3ayVqQrZOsRhv8PvGWMX2EAAAA="
      },
      "Metadata": {
        "aws:cdk:path": "CdktestStack/CDKMetadata/Default"
      }
    }
  },
  "Parameters": {
    "BootstrapVersion": {
      "Type": "AWS::SSM::Parameter::Value<String>",
      "Default": "/cdk-bootstrap/hnb659fds/version",
      "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
    }
  },
  "Rules": {
    "CheckBootstrapVersion": {
      "Assertions": [
        {
          "Assert": {
            "Fn::Not": [
              {
                "Fn::Contains": [
                  [
                    "1",
                    "2",
                    "3",
                    "4",
                    "5"
                  ],
                  {
                    "Ref": "BootstrapVersion"
                  }
                ]
              }
            ]
          },
          "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
        }
      ]
    }
  }
}

Examining SES template
Using AWS CLI,

  • Command aws sesv2 list-email-templates gives below output:
    {
        "TemplatesMetadata": [
            {
                "TemplateName": "UnicodeTestTemplate",
                "CreatedTimestamp": "2025-02-04T11:51:07.088000-08:00"
            }
        ]
    }
  • Command aws sesv2 get-email-template --template-name UnicodeTestTemplate gives below output:
    {
        "TemplateName": "UnicodeTestTemplate",
        "TemplateContent": {
            "Subject": "Unicode ® char.",
            "Text": "Unicode ® char.",
            "Html": "Unicode ® char."
        }
    }

So looks like correct SES email template is being deployed via CDK/CloudFormation, but CloudFormation is not displaying or returning Unicode characters properly.

Unsure how CDK could handle this scenario when CloudFormation API is not handling properly.

@ashishdhingra ashishdhingra removed the investigating This issue is being investigated and/or work is in progress to resolve the issue. label Feb 4, 2025
@kaizencc
Copy link
Contributor

kaizencc commented Feb 4, 2025

I can reproduce the same as @ashishdhingra. Can confirm that CDK synthesizes the correct template with ® and it is uploaded to s3 correctly. Beyond that, it's CloudFormation that takes the template from s3 as input, and it must not be converting unicode characters correctly. I will open up an internal ticket with them

@kaizencc kaizencc added needs-cfn This issue is waiting on changes to CloudFormation before it can be addressed. and removed package/tools Related to AWS CDK Tools or CLI labels Feb 4, 2025
@ashishdhingra ashishdhingra removed their assignment Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-ses Related to Amazon Simple Email Service bug This issue is a bug. needs-cfn This issue is waiting on changes to CloudFormation before it can be addressed. p2
Projects
None yet
Development

No branches or pull requests

3 participants