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

aws_s3: python CfnBucket.EventBridgeConfigurationProperty ignored #26282

Closed
mmaeng opened this issue Jul 7, 2023 · 4 comments
Closed

aws_s3: python CfnBucket.EventBridgeConfigurationProperty ignored #26282

mmaeng opened this issue Jul 7, 2023 · 4 comments
Labels
@aws-cdk/aws-s3 Related to Amazon S3 bug This issue is a bug. effort/medium Medium work item – several days of effort p2

Comments

@mmaeng
Copy link
Contributor

mmaeng commented Jul 7, 2023

Describe the bug

Trying to enable event bridge events on an s3 bucket using the L1 CfnBucket.

        testbucket = aws_s3.CfnBucket(self, "testingBucketCfnBucket")
        testbucket.EventBridgeConfigurationProperty(
            event_bridge_enabled=True,
        )

event_bridge_enabled property looks to be ignored.

cdk synth, generates this snippet

  "testingBucketCfnBucket": {
   "Type": "AWS::S3::Bucket",
   "Metadata": {
    "aws:cdk:path": "s3-python/testingBucketCfnBucket"
   }

Expected Behavior

Expecting cdk synth to generate

  "testingBucketCfnBucket": {
   "Type": "AWS::S3::Bucket",
   "Metadata": {
    "aws:cdk:path": "s3-python/testingBucketCfnBucket"
   },
   "Properties": {
    "NotificationConfiguration": {
     "EventBridgeConfiguration": {
      "EventBridgeEnabled": true
     }
    }
   }

Current Behavior

testbucket = aws_s3.CfnBucket(self, "testingBucketCfnBucket")
testbucket.EventBridgeConfigurationProperty(
    event_bridge_enabled=True,
)

event_bridge_enabled setting is ignored.

  "testingBucketCfnBucket": {
   "Type": "AWS::S3::Bucket",
   "Metadata": {
    "aws:cdk:path": "s3-python/testingBucketCfnBucket"
   }

Reproduction Steps

from aws_cdk import aws_s3

testbucket = aws_s3.CfnBucket(self, "testingBucketCfnBucket")
testbucket.EventBridgeConfigurationProperty(
    event_bridge_enabled=True,
)

Possible Solution

Broke out into an override to add the parameter

testbucket.add_property_override("NotificationConfiguration.EventBridgeConfiguration.EventBridgeEnabled", True)

Additional Information/Context

No response

CDK CLI Version

2.87.0

Framework Version

No response

Node.js Version

18.16.0

OS

MacOS Ventura 13.4

Language

Python

Language Version

Python 3.9.6

Other information

No response

@mmaeng mmaeng added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jul 7, 2023
@github-actions github-actions bot added the @aws-cdk/aws-s3 Related to Amazon S3 label Jul 7, 2023
@pahud pahud self-assigned this Jul 7, 2023
@pahud
Copy link
Contributor

pahud commented Jul 7, 2023

According to this, EventBridgeConfiguration is under NotificationConfiguration. If you really need to configure that with L1 construct(i.e. CfnBucket) you will need to configure that under NotificationConfiguration. Check this out for more details about the NotificationConfigurationProperty.

Is there any reason you have to use CfnBucket L1 construct like that?

Check EventBridge notifications for more details.

@pahud pahud added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Jul 7, 2023
@pahud pahud removed their assignment Jul 7, 2023
@pahud pahud added p2 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Jul 7, 2023
@mmaeng
Copy link
Contributor Author

mmaeng commented Jul 7, 2023

Using the L2 construct for notifications does not fulfill the cloudformation guard rules that Control Tower uses to ensure notifications are set. Tested using cdk-validator

https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_s3/CfnBucket.html#eventbridgeconfigurationproperty
was followed and the property looks to be ignored.

As you mentioned also tested using the notificationconfigurationproperty, no change in cdk synth output
https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_s3/CfnBucket.html#notificationconfigurationproperty

        testbucket = aws_s3.CfnBucket(self, "testingBucketCfnBucket")
        testbucket.NotificationConfigurationProperty( 
            event_bridge_configuration = testbucket.EventBridgeConfigurationProperty(
                event_bridge_enabled=True,
            )
        )

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Jul 7, 2023
@peterwoodworth
Copy link
Contributor

from aws_cdk import aws_s3

testbucket = aws_s3.CfnBucket(self, "testingBucketCfnBucket")
testbucket.EventBridgeConfigurationProperty(
    event_bridge_enabled=True,
)

This isn't the right syntax if you're trying to modify the property in this manner.

Prefer to use add_property_override or setting the property in the constructor, but the following should work using the method you submitted:

from aws_cdk import aws_s3

testbucket = aws_s3.CfnBucket(self, "testingBucketCfnBucket")
testbucket.notification_configuration.event_bridge_configuration.event_bridge_enabled = True

@github-actions
Copy link

github-actions bot commented Jul 7, 2023

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-s3 Related to Amazon S3 bug This issue is a bug. effort/medium Medium work item – several days of effort p2
Projects
None yet
Development

No branches or pull requests

3 participants