aws / aws-tools-for-powershell

The AWS Tools for PowerShell lets developers and administrators manage their AWS services from the PowerShell scripting environment.
Apache License 2.0
235 stars 78 forks source link

Stack Overflow when accessing or setting bucket inventory encryption configuration #159

Closed mikereinhold closed 3 years ago

mikereinhold commented 4 years ago

When attempting to access or set bucket inventory encryption configuration, the command crashes with a stack overflow.

Expected Behavior

When accessing the bucket inventory configuration, the inventory encryption configuration should be returned.

When writing the bucket inventory configuration, the inventory encryption configuration should be built and applied to the bucket.

Current Behavior

When accessing the bucket inventory configuration or attempting to write the bucket inventory configuration, a stack overflow occurs.

No stack trace or other debugging information is provided, simply a single line output to the console "Stack overflow." and the session is dead.

image

Steps to Reproduce (for bugs)

$bucketName = "example-test-overflow-bucket"
$inventoryId = "overflow-example"

New-S3Bucket -BucketName 
Write-S3BucketInventoryConfiguration -BucketName $bucketName -InventoryConfiguration_InventoryId $inventoryId -InventoryEncryption_SSES3 ([Amazon.S3.Model.SSES3]::new()) -Schedule_Frequency "Daily" -S3BucketDestination_BucketName "arn:aws:s3:::$bucketName" -S3BucketDestination_Prefix "inventory" -S3BucketDestination_InventoryFormat "CSV"

Also occurs when a bucket has been configured to use encrypted inventory (via another method, aka console) and you attempt to access the inventory encryption configuration

$bucketName = "example-test-overflow-bucket"
$inventoryId = "overflow-example"

$inventoryConfig = Get-S3BucketInventoryConfiguration -bucket $bucketName -InventoryId $inventoryId
$inventoryConfig.Destination.S3BucketDestination.InventoryEncryption

Context

Trying to automate standard bucket configurations for use in our organization to ensure we have consistent configuration and process.

Your Environment

Include as many relevant details about the environment where the bug was discovered.

ashishdhingra commented 3 years ago

Reproducible using the below commands:

ashishdhingra commented 3 years ago

Following works in AWS CLI:

aws s3api put-bucket-inventory-configuration --bucket example-test-overflow-bucket-159 --id overflow-example-159 --inventory-configuration '{"Destination": {"S3BucketDestination":{"Bucket":"arn:aws:s3:::example-test-overflow-bucket-159", "Format":"CSV", "Prefix":"inventory", "Encryption": {"SSES3":{}}}}, "Id": "overflow-example-159", "IsEnabled": true, "Schedule": {"Frequency": "Daily"}, "IncludedObjectVersions": "All"}'

Kindly note that IsEnabled and IncludedObjectVersions properties are required.

ashishdhingra commented 3 years ago

The following PowerShell commands works in the latest version of AWS Powershell Tools (4.1.6.0):