(aws_s3): CfnBucket.public_access_block_configuration property cannot be accessed
- Dominant language
- TypeScript
- Stars
- 2.9k
- Forks
- 267
- Avg merge
- 1d 25m
- Merged PRs (30d)
- 14
Description
### What is the problem?
If you try to access the `public_access_block_configuration` property of a `CfnBucket` that is non-null, you get an error message from JSII.
https://docs.aws.amazon.com/cdk/api/v1/python/aws_cdk.aws_s3/CfnBucket.html#aws_cdk.aws_s3.CfnBucket.public_access_block_configuration
### Reproduction Steps
```python
from aws_cdk import (
aws_s3,
core
)
def main():
app = core.App()
env = core.Environment(region='us-east-1')
stack = core.Stack(app, 'cdk-test', env=env)
bucket = aws_s3.Bucket(stack, 'my-bucket', block_public_access=aws_s3.BlockPublicAccess.BLOCK_ALL)
app.synth()
print(bucket.node.default_child.public_access_block_configuration)
if __name__ == "__main__":
main()
```
### What did you expect to happen?
It should get the configuration without issue.
### What actually happened?
```
Traceback (most recent call last):
File "/Users/rittneje/cdk-test/cdk.py", line 17, in
main()
File "/Users/rittneje/cdk-test/cdk.py", line 13, in main
print(bucket.node.default_child.public_access_block_configuration)
File "/usr/local/lib/python3.9/site-packages/aws_cdk/aws_s3/__init__.py", line 2823, in public_access_block_configuration
return typing.cast(typing.Optional[typing.Union[aws_cdk.core.IResolvable, "CfnBucket.PublicAccessBlockConfigurationProperty"]], jsii.get(self, "publicAccessBlockConfiguration"))
File "/usr/local/lib/python3.9/site-packages/jsii/_kernel/__init__.py", line 143, in wrapped
return _recursize_dereference(kernel, fn(kernel, *args, **kwargs))
File "/usr/local/lib/python3.9/site-packages/jsii/_kernel/__init__.py", line 133, in _recursize_dereference
return _reference_map.resolve_reference(kernel, d)
File "/usr/local/lib/python3.9/site-packages/jsii/_reference_map.py", line 74, in resolve
[inst] + self.build_interface_proxies_for_ref(ref)
File "/usr/local/lib/python3.9/site-packages/jsii/_reference_map.py", line 132, in build_interface_proxies_for_ref
ifaces = [_interfaces[fqn] for fqn in ref.interfaces or []]
File "/usr/local/lib/python3.9/site-packages/jsii/_reference_map.py", line 132, in
ifaces = [_interfaces[fqn] for fqn in ref.interfaces or []]
KeyError: '@aws-cdk/aws-s3.CfnBucket.PublicAccessBlockConfigurationProperty'
```
### CDK CLI Version
1.140.0 (build 789f2dc)
### Framework Version
_No response_
### Node.js Version
v16.13.2
### OS
Alpine 3.15
### Language
Python
### Language Version
3.9.10
### Other information
This bug is also reproducible with the latest v2 CDK (v2.15.0).
Copy of https://github.com/aws/aws-cdk/issues/19314.
Contributor guide
Research direction
Start by running the Python reproduction against the jsii version in the report, then read jsii/_kernel/__init__.py and jsii/_reference_map.py around the failing interface lookup. Done means accessing CfnBucket.public_access_block_configuration no longer raises a KeyError for the PublicAccessBlockConfigurationProperty reference.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, typescript
- Domain
- developer-experience, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100