question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

aws_s3.CfnBucket "bucket_encryption" required properties not implemented in Python

See original GitHub issue

Hi,

I’m trying to set the default server-side encryption in S3, using the aws_s3.CfnBucket module.

The problem is that if I implement a setting of the type AWS::S3::Bucket.BucketEncryption in the bucket_encryption parameter (as stated here in the docs), using a value like {"ServerSideEncryptionByDefault": {"SSEAlgorithm": "AES256"}} throws out an error, saying that it expects an object reference.

The problem is that I also tried to use the same object as used in the aws_s3.Bucket Construct (e.g. aws_s3.BucketEncryption.S3_MANAGED), but it is not recognised as well - it seems to me that this reference (@aws-cdk/aws-s3.CfnBucket.BucketEncryptionProperty: serverSideEncryptionConfiguration) is not correctly implemented for Python.

Reproduction Steps

Create a CDK App using Python and add the following code inside the Stack:

bucket = aws_s3.CfnBucket(
    self,
    "bucket",
    bucket_name="my_bucket",
    bucket_encryption={"ServerSideEncryptionByDefault": {"SSEAlgorithm": "AES256"}},
)

Then try to run any CDK command, like cdk ls or cdk synth.

Error Log

When using a direct reference:

jsii.errors.JSIIError: Value did not match any type in union: Expected object reference, got {"ServerSideEncryptionByDefault":{"SSEAlgorithm":"AES256"}},Missing required properties for @aws-cdk/aws-s3.CfnBucket.BucketEncryptionProperty: serverSideEncryptionConfiguration

When using aws_s3.BucketEncryption:

jsii.errors.JSIIError: Value did not match any type in union: Expected object reference, got {"$jsii.enum":"@aws-cdk/aws-s3.BucketEncryption/S3_MANAGED"},Missing required properties for @aws-cdk/aws-s3.CfnBucket.BucketEncryptionProperty: serverSideEncryptionConfiguration

Environment

  • CLI Version : 1.15.0 (build bdbe3aa)
  • Framework Version: 1.15.0
  • OS : MacOS X Mojave
  • Language : Python/3.7.5

Other


This is 🐛 Bug Report

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
eladbcommented, Nov 10, 2019

@eduardohki it should still be possible to use s3.Bucket and only patch the specific properties using escape hatches.

@RomainMuller what would it take to support passing this by-value in Python?

0reactions
eladbcommented, Nov 11, 2019

Closing for now. Please reopen if this is still an issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

CfnBucket — AWS Cloud Development Kit 1.182.0 ...
Configuration for replicating objects in an S3 bucket. To enable replication, you must also enable versioning by using the VersioningConfiguration property.
Read more >
Top 5 @aws-cdk/aws-s3 Code Examples | Snyk
To help you get started, we've selected a few @aws-cdk/aws-s3 examples, based on popular ways it is used in public projects.
Read more >
S3 Bucket Default Encryption [Deprecated] - Trend Micro
With encryption at rest enabled, the Amazon S3 service can encrypt and decrypt your S3 objects using either AWS S3-managed keys (SSE-S3) or...
Read more >
AWS CDK - How to add an event notification to an existing S3 ...
I managed to get this working with a custom resource. It's TypeScript, but it should be easily translated to Python:
Read more >
Package Diff: @aws-cdk/aws-s3 @ 0.25.3 .. 0.27.0
"comment": "External KMS key to use for bucket encryption.\n\nThe 'encryption' property must be either not specified or set to \"Kms\".
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found