pulumi / pulumi/pulumi-java

Importing wafv2 results in incorrect and missing code.

Open
#947 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area/codegen kind/bug language/java pulumi/pulumi-java
Dominant language
Java
Stars
85
Forks
26
Avg merge
11h 49m
Merged PRs (30d)
22

Description

What happened?

Imported WafV2 ACL into Java and although the resource imported into state successfully, the generated code had errors.

Specifically, it generated code like this:

var importedAcl = new WebAcl("importedAcl", WebAclArgs.builder()        
            .defaultAction()
...

Where .defaultAction() is not valid. Similarly for the rules section (not shown above) it was missing a .action()` block which is needed for the code to work.

Note: Importing to Typescript and YAML also produced incorrect code for the analogous defaultAction block and missing action block for the rule.

See below for details steps related to the Java use-case.

Steps to reproduce
  1. Use the code in this file to deploy a stack that creates a WafV2 ACL:
    createWafv2Acl_ts.txt
    Note the output of the above program since it provides a pulumi import command you can use in later steps.
  2. In a separate folder, run pulumi new aws-java to create a base stack to use for the import.
  3. Run the pulumi import command generated by the create stack in step 1
  4. Copy/paste the generated code into the program generated in step 2
  5. Run pulumi up on the import stack and note the errors.
  6. Modify the import stack code to correctly specify the .defaultAction block and to add a required .action block to the rule.
    See the code in this file for a correct version:
    Corrected-Imported_java.txt
Expected Behavior

The generated import code should correctly specify all required properties.

Actual Behavior

The generated import code incorrectly specified .defaultAction and was missing the rule-level .action property altogether.

Output of pulumi about

CLI
Version 3.51.1
Go Version go1.19.4
Go Compiler gc

Plugins
NAME VERSION
aws 5.27.0
java unknown

Host
OS darwin
Version 12.5.1
Arch x86_64

This project is written in java: executable='/usr/bin/java' version='java 19.0.2 2023-01-17
Java(TM) SE Runtime Environment (build 19.0.2+7-44)
Java HotSpot(TM) 64-Bit Server VM (build 19.0.2+7-44, mixed mode, sharing)' gradle='7.4.2' java='/usr/bin/java' javac='19.0.2' maven='Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63)'

Current Stack: xxxxxx/import-java-2/dev

TYPE URN
pulumi:pulumi:Stack urn:pulumi:dev::import-java-2::pulumi:pulumi:Stack::import-java-2-dev
pulumi:providers:aws urn:pulumi:dev::import-java-2::pulumi:providers:aws::default_5_27_0
aws:wafv2/webAcl:WebAcl urn:pulumi:dev::import-java-2::aws:wafv2/webAcl:WebAcl::importedAcl

Found no pending operations associated with dev

Backend
Name pulumi.com

No dependencies found

Additional context

I noticed that running pulumi convert --language java for a properly defined yaml version of the code would produce better but still incorrect version of the java code.

Contributing

Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the attached createWafv2Acl_ts.txt and Corrected-Imported_java.txt files, using pulumi import and pulumi convert --language java. Compare the generated Java, TypeScript, and YAML output with the corrected example; done means defaultAction and each rule's action are emitted as valid required blocks.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, typescript, yaml
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.