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

Error when creating SES Rule with s3 action from existing rule set #3726

Closed
hanstf opened this issue Aug 20, 2019 · 2 comments · Fixed by #4163
Closed

Error when creating SES Rule with s3 action from existing rule set #3726

hanstf opened this issue Aug 20, 2019 · 2 comments · Fixed by #4163
Assignees
Labels
@aws-cdk/aws-ses Related to Amazon Simple Email Service bug This issue is a bug. needs-reproduction This issue needs reproduction. needs-triage This issue or PR still needs to be triaged.

Comments

@hanstf
Copy link

hanstf commented Aug 20, 2019

🐛 Bug Report

What is the problem?

Unable to create SES Rule with s3 action from existing rule set.

Reproduction Steps

I am trying to create a SES Rule from an existing rule set which actions are to s3 bucket and sns topic as shown below.

        const ruleSet = ReceiptRuleSet.fromReceiptRuleSetName(this, 'RuleSet', props.ruleSetName);
const emailTopic = new Topic(this, 'Topic', {
            displayName: 'Email Scrapper'
        });
        const emailBucket = new Bucket(this, 'Bucket');
        ruleSet.addRule(
            'Rules',
            {
                recipients: ['reflaunt.email'],
                actions: [
                    new ReceiptRuleS3Action({
                        bucket: emailBucket,
                        topic: emailTopic
                    })
                ]
            }
        );

But everytime I deploy, I always receive this error

Could not write to bucket: emailscrapperstack-dev-emailscrapperobjectobjectb-1xx3t61zt8bxb (Service: AmazonSimpleEmailService; Status Code: 400; Error Code: InvalidS3Configuration; Request ID: faff6bc9-e2ae-4c34-863c-39d3b59f23d1)

Then I realized that the s3 bucket policy was not configured when the rule is added, so for now I did a hacky-fix by adding s3 resource policy dependency to the rule set.

        const cfnBucketPolicy = emailBucket.node.findChild("Policy").node.findChild("Resource") as CfnBucketPolicy;
        ruleSet.node.addDependency(cfnBucketPolicy);

Is there any better way to achieve this ?
Also the strange thing is, I don't have the issue with the sns topic, even the rule set is not depending on the sns policy.

Verbose Log

Could not write to bucket: emailscrapperstack-dev-emailscrapperobjectobjectb-1xx3t61zt8bxb (Service: AmazonSimpleEmailService; Status Code: 400; Error Code: InvalidS3Configuration; Request ID: faff6bc9-e2ae-4c34-863c-39d3b59f23d1)

Environment

  • CDK CLI Version: 1.4.0
  • Module Version: 1.4.0
  • OS: ubuntu 18.04
  • Language: TypeScript

Other information

@hanstf hanstf added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Aug 20, 2019
@hanstf hanstf changed the title SES fromReceiptRuleSetName with S3 Action error Error when creating SES Rule with s3 action from existing rule set Aug 20, 2019
@jogold
Copy link
Contributor

jogold commented Aug 20, 2019

There is indeed a race condition here that can only be solved with a CF DependsOn.

With the current implementation of ReceiptRuleS3Action it's not that easy to solve this.

I would say that anyway those receipt rule actions should be refactored as integrations and moved to another package (aws-ses-actions/aws-ses-receipt-actions?), same pattern as aws-events-targets, aws-sns-subscriptions... @rix0rrr?

@hanstf
Copy link
Author

hanstf commented Aug 21, 2019

Yes it is quite confusing to addDependency from the ruleset resource itself as the declaration in cf is only for the action.

@SomayaB SomayaB added @aws-cdk/aws-ses Related to Amazon Simple Email Service needs-reproduction This issue needs reproduction. labels Sep 11, 2019
jogold added a commit to jogold/aws-cdk that referenced this issue Sep 19, 2019
Move cross-service integrations for receipt rule actions to their own package in accordance with
the CDK guidelines.

Closes aws#3726

BREAKING CHANGE: adding an action to a receipt rule now requires an integration
object from the `@aws-cdk/aws-ses-actions` package.
jogold added a commit to jogold/aws-cdk that referenced this issue Sep 19, 2019
Move cross-service integrations for receipt rule actions to their own package in accordance with
the CDK guidelines.

Closes aws#3726

BREAKING CHANGE: adding an action to a receipt rule now requires an integration
object from the `@aws-cdk/aws-ses-actions` package.
jogold added a commit to jogold/aws-cdk that referenced this issue Sep 19, 2019
Move cross-service integrations for receipt rule actions to their own package in accordance with
the CDK guidelines.

Closes aws#3726

BREAKING CHANGE: adding an action to a receipt rule now requires an integration
object from the `@aws-cdk/aws-ses-actions` package.
jogold added a commit to jogold/aws-cdk that referenced this issue Sep 19, 2019
Move cross-service integrations for receipt rule actions to their own package in accordance with
the CDK guidelines.

Closes aws#3726

BREAKING CHANGE: adding an action to a receipt rule now requires an integration
object from the `@aws-cdk/aws-ses-actions` package.
jogold added a commit to jogold/aws-cdk that referenced this issue Sep 19, 2019
Move cross-service integrations for receipt rule actions to their own package in accordance with
the CDK guidelines.

Closes aws#3726

BREAKING CHANGE: adding an action to a receipt rule now requires an integration
object from the `@aws-cdk/aws-ses-actions` package.
shivlaks pushed a commit that referenced this issue Sep 27, 2019
Move cross-service integrations for receipt rule actions to their own package in accordance with the CDK guidelines.

Closes #3726

BREAKING CHANGE: adding an action to a receipt rule now requires an integration
object from the `@aws-cdk/aws-ses-actions` package.
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-reproduction This issue needs reproduction. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants