Does anyone know how to pass mandatory properties ...
# java
c
Does anyone know how to pass mandatory properties to provider when doing import via Java SDK, but via CLI will do as a work around. E.g. the https://developers.cloudflare.com/api/operations/email-routing-routing-rules-get-routing-rule requires "zone" id and not just "tag" (CF's object id). As a result TF CF provider that pulumi provider wraps, needs it for "Read" @ https://github.com/cloudflare/terraform-provider-cloudflare/blob/master/internal/provider/resource_cloudflare_email_routing_rule.go#L58 But for the life of me I cannot find a way to pass that extra information with the import java call or via cli.
Copy code
private static Map<String, String> emailToId = Map.of(
            "email@mydomain", "123456789deadbeef000000000",
    );


public static EmailRoutingRule createRule(final String from, final String to)
{
    final var name = from + ":rule";
    final var rule = EmailRoutingRuleArgs.builder()
            .actions(
                    EmailRoutingRuleActionArgs.builder()
                            .type("forward")
                            .values(to)
                            .build()
            )
            .enabled(true)
            .matchers(
                    EmailRoutingRuleMatcherArgs.builder()
                            .field("to")
                            .type("literal")
                            .value(from)
                            .build()
            )
            .name(name)
            .zoneId(ZONE_ID_MY_DOMAIN)
            .build();

    final var optionsBuilder = CustomResourceOptions.builder();
    Optional.ofNullable(emailToId.get(from)).ifPresent(optionsBuilder::importId);

    return  new EmailRoutingRule
    (
            name,
            rule,
            optionsBuilder.build()
            );
}
results in
Copy code
cloudflare:index:EmailRoutingRule (email@mydomain:rule):
    error: Preview failed: refreshing urn:pulumi:dev::cloudflare::cloudflare:index/emailRoutingRule:EmailRoutingRule::email@mydomain:rule: 1 error occurred:
        * error reading email routing rule "123456789deadbeef000000000": required missing zone ID
same error with "pulumi import"
c
I think this is very similar, if not the same, issue I had with a different provider. https://github.com/pulumi/pulumi/issues/11279
c
Yes, this sounds like the same issue I ran into
c
Feel free to add a comment on that issue. Your use-case is of course specific to Cloudflare but I believe it to be an underlying issue that needs to be addressed in the core Pulumi engine first.