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

Inconsistency between examples and what really works #1641

Closed
1 of 4 tasks
marcosdiez opened this issue May 9, 2020 · 5 comments
Closed
1 of 4 tasks

Inconsistency between examples and what really works #1641

marcosdiez opened this issue May 9, 2020 · 5 comments
Assignees
Labels
bug This issue is a bug. effort/medium Medium work item – a couple days of effort language/python Related to Python bindings module/runtime Issues affecting the `jsii-runtime` p1

Comments

@marcosdiez
Copy link

marcosdiez commented May 9, 2020

🐛 Bug Report

Affected Languages

  • TypeScript or Javascript
  • Python
  • Java
  • .NET (C#, F#, ...)

General Information

What is the problem?

On the CDK 1.38.0 documentation, the example seems to be right (in snake_case), but what really works is in camelCase.

Here is an example:

https://docs.aws.amazon.com/cdk/api/latest/python/aws_cdk.aws_cloudfront.README.html

the example says:

# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
source_bucket = Bucket(self, "Bucket")

distribution = CloudFrontWebDistribution(self, "MyDistribution",
    origin_configs=[{
        "s3_origin_source": {
            "s3_bucket_source": source_bucket
        },
        "behaviors": [{"is_default_behavior": True}]
    }
    ]
)

but what really works is:

        source_bucket = Bucket(self, "Bucket")
        distribution = cloudfront.CloudFrontWebDistribution(self, name,
            origin_configs=[{
                "s3OriginSource": {
                    "s3BucketSource": source_bucket,
                },
                "behaviors": [{"isDefaultBehavior": True}]
            }
            ]
        )

Since CDK tries to follow pep8 and parameters and methods snake_case, the example is right but the classes themselves are not. Hence I did not fill the bug on #826

Another Example:

source: https://docs.aws.amazon.com/cdk/api/latest/python/aws_cdk.aws_cloudfront/CloudFrontWebDistribution.html

price_class (Optional[PriceClass]) – The price class for the distribution (this impacts how many locations CloudFront uses for your distribution, and billing). Default: PriceClass.PriceClass100 the cheapest option for CloudFront is picked by default.

The valid name is actually PriceClass.PRICE_CLASS_100

@marcosdiez marcosdiez added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels May 9, 2020
@SomayaB SomayaB added the language/python Related to Python bindings label May 11, 2020
RomainMuller added a commit to aws/aws-cdk that referenced this issue May 12, 2020
…eClass

The `@default` was not updated to reflect the change of enum constants
to `SHOUT_CASE`. This corrects that.

Related: aws/jsii#1641
@RomainMuller
Copy link
Contributor

Hey!

The problem on CloudFrontWebDistribution's priceClass property actually is in the source documentation. I have submitted aws/aws-cdk#7926 to address that.

The other problems are probably a bug in how the jsii runtime performs case adjustments in this particular case. I'd suppose because the configuration object/dict is nested within an array - possibly this causes the struct transformation not to happen.

So in any case, thank you for reporting this!

@RomainMuller RomainMuller added module/runtime Issues affecting the `jsii-runtime` p1 and removed needs-triage This issue or PR still needs to be triaged. labels May 12, 2020
mergify bot pushed a commit to aws/aws-cdk that referenced this issue May 12, 2020
…eClass (#7926)

The `@default` was not updated to reflect the change of enum constants
to `SHOUT_CASE`. This corrects that.

Related: aws/jsii#1641
karupanerura pushed a commit to karupanerura/aws-cdk that referenced this issue May 22, 2020
…eClass (aws#7926)

The `@default` was not updated to reflect the change of enum constants
to `SHOUT_CASE`. This corrects that.

Related: aws/jsii#1641
@MrArnoldPalmer MrArnoldPalmer added the effort/medium Medium work item – a couple days of effort label Aug 17, 2020
@MrArnoldPalmer MrArnoldPalmer removed their assignment Jun 28, 2021
@github-actions
Copy link
Contributor

This issue has not received any attention in 2 years. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Jun 29, 2023
@marcosdiez
Copy link
Author

This issue is important

@github-actions github-actions bot removed the closing-soon This issue will automatically close in 4 days unless further comments are made. label Jun 30, 2023
@otaviomacedo otaviomacedo self-assigned this Apr 22, 2024
@otaviomacedo
Copy link
Contributor

The documentation is now correct, showing the "structified" Python version, rather than the bare JSON (which is sent unmodified over the wire):

source_bucket = s3.Bucket(self, "Bucket")

distribution = cloudfront.CloudFrontWebDistribution(self, "MyDistribution",
    origin_configs=[cloudfront.SourceConfiguration(
        s3_origin_source=cloudfront.S3OriginConfig(
            s3_bucket_source=source_bucket
        ),
        behaviors=[cloudfront.Behavior(is_default_behavior=True)]
    )
    ]
)

Copy link
Contributor

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. effort/medium Medium work item – a couple days of effort language/python Related to Python bindings module/runtime Issues affecting the `jsii-runtime` p1
Projects
None yet
Development

No branches or pull requests

5 participants