Hi there, can someone help me take a look, i’m try...
# general
c
Hi there, can someone help me take a look, i’m trying to use automation api with
Copy code
stack_auto = auto.select_stack(stack_name, work_dir='../stacks')
        print(f"successfully select stack {stack_name}")
        print("Previewing stack")
        stack_auto.preview(on_output=print, target=stack_target)
        print("Preview complete")
since
stack_target
is an array like [‘**DOMAIN_abc’] and what I expect is pulumi will preview only on urn matched
**DOMAIN_abc
but python script above running on all urn even not matched with
**DOMAIN_abc
p/s: ran with
pulumi preview --stack <stack_name> --target "**DOMAIN_abc"
was worked well
e
That looks like it should work. Especially if the plain command line version works. Can you get the logs out (maybe run with log_to_std_err=true & log_verbosity=5)
c
Hi, after added your suggestion and output look like below
Copy code
successfully select stack <redacted>.cloudflare-dns
Previewing stack
Previewing update (<redacted>.cloudflare-dns):
@ previewing update........
    pulumi:pulumi:Stack pulum-<redacted>.cloudflare-dns running
    pulumi:pulumi:Stack pulum-<redacted>.cloudflare-dns running read pulumi:pulumi:StackReference <redacted>.cloudflare
    pulumi:pulumi:Stack pulum-<redacted>.cloudflare-dns running read pulumi:pulumi:StackReference <redacted>.cloudflare
@ previewing update.....
    cloudflare:index:Record <redacted>.com_CNAME_DOMAIN_<redacted>.com
    cloudflare:index:Record <redacted>.com_mx.zohomail.com_10_MX_DOMAIN_<redacted>.com
    cloudflare:index:Record <redacted>.com_mx2.zohomail.com_20_MX_DOMAIN_<redacted>.com
    cloudflare:index:Record <redacted>.com_v=spf1 mx include:<http://zoho.com|zoho.com> ~all_TXT_DOMAIN_<redacted>.com
    cloudflare:index:Record img_CNAME_DOMAIN_<redacted>.com
    cloudflare:index:Record www_CNAME_DOMAIN_<redacted>.com
@ previewing update....
    cloudflare:index:Record autodiscover_CNAME_DOMAIN_<redacted>.com
    cloudflare:index:Record srv186-187-nat_<redacted>_A_DOMAIN_<redacted>.com
    cloudflare:index:Record <redacted>.com_v=spf1_TXT_DOMAIN_<redacted>.com
    cloudflare:index:Record <redacted>.com_CNAME_DOMAIN_<redacted>.com
    cloudflare:index:Record <redacted>.cms-angel.staging_CNAME_DOMAIN_<redacted>.com
@ previewing update.....
    pulumi:pulumi:Stack pulum-<redacted>.cloudflare-dns

Resources:
    + 1 to create
    1228 unchanged

Preview complete
e
And it doesn't look like that when using the CLI directly? I haven't played with targets for a while, but I thought it was normal they still listed all the other resources, they just wouldn't change them.
c
here is from CLI
Copy code
pulumi preview --stack <redacted>.cloudflare-dns --target "**DOMAIN_<redacted>" 
Previewing update (<redacted>.cloudflare-dns):
     Type                        Name                                                     Plan       
     pulumi:pulumi:Stack         pulum-<redacted>.cloudflare-dns                                     
 +   └─ cloudflare:index:Record  uservpn-695_v=spf1 a:smtp.<redacted> -all_TXT_DOMAIN_<redacted>  create     


Resources:
    + 1 to create
    1228 unchanged
e
I think this is just the display is different. If you try running the cli with "--non-interactive" or piping the output to text file I think you'll see the same as what your getting with autoapi.
The final summary:
Copy code
Resources:
    + 1 to create
    1228 unchanged
Is the same in both.
c
the context when using automation api is I want to share the resource change to review before run
pulumi.up
, so with the long list result may cause some mistake 😄
e
Understood, we had a similar ask the other day. Might be worth raising question at https://github.com/pulumi/pulumi/discussions, we can reply with some code to help and it will be discoverable by others as well. Long term I really want to overhaul the autoapi interface to give much better summary results to make things like this easier.
c
great! I’ve opened discussion at https://github.com/pulumi/pulumi/discussions/12013, let me know if I need update something on it
e
I'll ask our support guy for the week to take a look 👍
c
@echoing-dinner-19531 I found a trick by apply
diff=True
into
pulumi.preview
then result output now look like shorter than ever
Copy code
Previewing update (<redacted>.cloudflare-dns):
    pulumi:pulumi:Stack: (same)
      [urn=urn:pulumi:<redacted>.cloudflare-dns::pulum::pulumi:pulumi:Stack::pulum-<redacted>.cloudflare-dns]
      > pulumi:pulumi:StackReference: (read)
          [id=<redacted>.cloudflare]
          [urn=urn:pulumi:<redacted>.cloudflare-dns::pulum::pulumi:pulumi:StackReference::<redacted>.cloudflare]
          name: "<redacted>.cloudflare"
      + cloudflare:index/record:Record: (create)
          [urn=urn:pulumi:<redacted>.cloudflare-dns::pulum::cloudflare:index/record:Record::uservpn-691_v=spf1 a:smtp.<redacted> -all_TXT_DOMAIN_<redacted>]
          [provider=urn:pulumi:<redacted>.cloudflare-dns::pulum::pulumi:providers:cloudflare::default_4_15_0::e8b1d660-d36f-4047-8096-71e0cc8c8c6a]
          allowOverwrite: false
          name          : "uservpn-691"
          type          : "TXT"
          value         : "v=spf1 a:smtp.<redacted> -all"
          zoneId        : "<redacted>"
  Resources:
      + 1 to create
      1228 unchanged
but still hope you guys have better human readable output like when running with cli 😛