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

CloudFront argument lost during synth #1403

Closed
cmclaughlin opened this issue Dec 9, 2021 · 2 comments · Fixed by #1405
Closed

CloudFront argument lost during synth #1403

cmclaughlin opened this issue Dec 9, 2021 · 2 comments · Fixed by #1405
Labels
bug Something isn't working

Comments

@cmclaughlin
Copy link
Contributor

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

cdktf & Language Versions

  • nodejs 12.22.7
  • python 3.10.0
  • cdktf 0.8.1
  • cdktf-cdktf-provider-aws 3.0.1

Affected Resource(s)

CloudfrontDistributionDefaultCacheBehaviorForwardedValues has the problem

I find it interesting that CloudfrontDistributionOrderedCacheBehaviorForwardedValues does not have the problem, despite having a similar method signature, e.g. both have query_string as an argument.

Debug Output

Here's a repo that reproduce the problem:

https://github.com/cmclaughlin/cdktf-cloudfront-query-string-bug

Running cdktf deploy generates this Terraform error:

╷
│ Error: Missing required argument
│
│   on cdk.tf.json line 54, in resource.aws_cloudfront_distribution.cloudfronttest_distro_CAF0A17E.default_cache_behavior.forwarded_values:
│   54:           }
│
│ The argument "query_string" is required, but no definition was found.
╵

However, changing query_string on line 48 of main.py to True will get the plan to pass (but that's not the desired value)

Expected Behavior

Plan cleanly w/ query_string=False

Actual Behavior

Terraform Missing required argument error

Steps to Reproduce

Important Factoids

We recently upgraded from cdktf 0.3 to 0.7.0. We didn't get very far with 0.7.0 before seeing more breaking changes in 0.8.0, so we upgraded to 0.8.1.

I haven't yet narrowed down when or where this problem started... but I don't think we had the problem prior to the recent upgrades.

@cmclaughlin cmclaughlin added bug Something isn't working new Un-triaged issue labels Dec 9, 2021
@cmclaughlin cmclaughlin changed the title CloudFront arguments are lost during synth CloudFront argument are lost during synth Dec 9, 2021
@cmclaughlin cmclaughlin changed the title CloudFront argument are lost during synth CloudFront argument lost during synth Dec 9, 2021
@jsteinich
Copy link
Collaborator

I think this started with the change to having single item blocks omit the array. There have been a few fixes made since then, but it seems like this case slipped through the cracks.

I believe the issue is caused by

this.code.openBlock(`if (this.${att.storageName})`);

This is doing a "truthy" test rather than an is defined test. I think we can simply update to check that it isn't undefined.

@github-actions
Copy link
Contributor

I'm going to lock this issue because it has been closed for 30 days. This helps our maintainers find and focus on the active issues. If you've found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants