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

Pulumi Java - Examples with Map(java.Map) not working #1039

Closed
marctree opened this issue Mar 24, 2023 · 3 comments
Closed

Pulumi Java - Examples with Map(java.Map) not working #1039

marctree opened this issue Mar 24, 2023 · 3 comments
Labels
area/codegen Code generation area/examples Examples kind/bug Some behavior is incorrect or out of spec resolution/fixed This issue was fixed

Comments

@marctree
Copy link

marctree commented Mar 24, 2023

Discussed in pulumi/pulumi#12469

Originally posted by marctree March 22, 2023
Hi folks,

i tried to create a infrastructure in azure cloud with pulumi java. Unfortunately i came across some wierd errors when i try to deploy a e.g. storage account or a key vault which are using "import java.util.Map;". I get always a compile error ->

Method com.pulumi.azurenative.storage.StorageAccountArgs.Builder.encryption(com.pulumi.core.Output<com.pulumi.azurenative.storage.inputs.EncryptionArgs>) is not applicable
(No matching arguments, No instances of type variables K,V,K,V,K,V,K,V,K,V,V,K,V,V,K,V,K,V,V,K,V,V,K,V,V,V,V,K,V, so java.util.Map<K,V> matches com.pulumi.core.Output<com.pulumi.azurenative.storage.inputs.EncryptionArgs>.

The example im using is this one here (StorageAccountCreate)-> https://www.pulumi.com/registry/packages/azure-native/api-docs/storage/storageaccount/

I init my pulumi project with the standard values so i dont have to change anything in the code. Still i got this error as long as the Map is in the code. When i delete the Map it works fine. Do i miss something here?

Thank you for your answers!
cheers

@dixler dixler added the needs-triage Needs attention from the triage team label Mar 28, 2023
@Zaid-Ajaj
Copy link
Contributor

Hi @marctree, thank you for taking the time to file the issue 🙏 the example in our docs is auto-generated by our codegen tooling. The java code generator still has issues and this is one of them. It generates a Map when it doesn't know what the concrete type should be.

The correct code should look like the following snippet which uses the appropriate types:

package myproject;

import com.pulumi.Pulumi;
import com.pulumi.azurenative.resources.ResourceGroup;
import com.pulumi.azurenative.storage.StorageAccount;
import com.pulumi.azurenative.storage.StorageAccountArgs;
import com.pulumi.azurenative.storage.enums.Bypass;
import com.pulumi.azurenative.storage.enums.DefaultAction;
import com.pulumi.azurenative.storage.enums.Kind;
import com.pulumi.azurenative.storage.enums.SkuName;
import com.pulumi.azurenative.storage.inputs.NetworkRuleSetArgs;
import com.pulumi.azurenative.storage.inputs.SkuArgs;
import com.pulumi.azurenative.storage.inputs.VirtualNetworkRuleArgs;

public class App {
    public static void main(String[] args) {
        Pulumi.run(ctx -> {
            var resourceGroup = new ResourceGroup("resourceGroup");
            var storageAccount = new StorageAccount("sa", StorageAccountArgs.builder()
                    .accountName("sto4445")
                    .enableHttpsTrafficOnly(false)
                    .enableNfsV3(true)
                    .isHnsEnabled(true)
                    .kind(Kind.BlockBlobStorage)
                    .location("eastus")
                    .networkRuleSet(NetworkRuleSetArgs.builder()
                            .bypass(Bypass.AzureServices)
                            .defaultAction(DefaultAction.Allow)
                            .ipRules()
                            .virtualNetworkRules(VirtualNetworkRuleArgs.builder()
                                    .virtualNetworkResourceId("/subscriptions/{subscription-id}/resourceGroups/res9101/providers/Microsoft.Network/virtualNetworks/net123/subnets/subnet12")
                                    .build())
                            .build())
                    .resourceGroupName(resourceGroup.name())
                    .sku(SkuArgs.builder()
                            .name(SkuName.Standard_LRS)
                            .build())
                    .build());

            ctx.export("storage", storageAccount.id());
        });
    }
}

I will move this issue to pulumi-java where the codegen is implemented. We will follow up on this from there. Hope this helps!

@Zaid-Ajaj Zaid-Ajaj added the kind/bug Some behavior is incorrect or out of spec label Mar 29, 2023
@Zaid-Ajaj Zaid-Ajaj transferred this issue from pulumi/pulumi Mar 29, 2023
@Zaid-Ajaj Zaid-Ajaj added area/examples Examples area/codegen Code generation and removed needs-triage Needs attention from the triage team labels Mar 29, 2023
@marctree
Copy link
Author

Hi @Zaid-Ajaj thank you for your answer! I will test it again. Thank you for your help!

@Zaid-Ajaj Zaid-Ajaj added the resolution/fixed This issue was fixed label Aug 14, 2024
@Zaid-Ajaj
Copy link
Contributor

@marctree We no longer generate Map for nested objects, this was an issue where the type of the object wasn't properly resolved but it is now. Closing as resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/codegen Code generation area/examples Examples kind/bug Some behavior is incorrect or out of spec resolution/fixed This issue was fixed
Projects
None yet
Development

No branches or pull requests

3 participants