https://pulumi.com logo
Title
l

little-river-49422

02/09/2019, 9:54 AM
another question, how do I create custom resources? not custom resource definitions in kubernetes
c

creamy-potato-29402

02/10/2019, 7:20 AM
we’re working on it.
l

little-river-49422

02/10/2019, 7:22 AM
hey, thanks. a bit sad. i have another question though. no yaml with python as well for now?
c

creamy-potato-29402

02/10/2019, 7:22 AM
there’s an issue for that too.
I think we expect to make progress on this in the next couple weeks.
l

little-river-49422

02/10/2019, 7:25 AM
ok, can I use regular python code inside pulumi, right? Like call a function with the output of the resource? the thing is, output is delayed
doesnt seem to work for me 😞
its always being run during the planning
any ideas?
@incalculable-sundown-82514 you mind taking a quick look at this?
i

incalculable-sundown-82514

02/11/2019, 7:07 PM
can you post a repro?
l

little-river-49422

02/11/2019, 7:49 PM
well, there's not much to repro, its just a provider initialization, followed by some resources and kubectl call in the end, i dont know how to make it only work during real run, i suppose I can create a condition, something like
if pulumi.process == "up":
but I dont really know where to look for ideas
i

incalculable-sundown-82514

02/11/2019, 7:56 PM
Ah, you only want to run something during an update? We have this function which returns whether or not you’re doing a preview: https://pulumi.io/reference/pkg/python/pulumi/index.html#pulumi.runtime.is_dry_run
😛artypus: 1
l

little-river-49422

02/11/2019, 8:34 PM
thanks, i didnt find that, sorry
i

incalculable-sundown-82514

02/11/2019, 8:34 PM
no worries! 🙂
l

little-river-49422

02/12/2019, 7:20 AM
hm, it still executes "first" despite it being the last one in the file, so before namespace gets created
so because I cant create custom resources I need to call kubectl to create a cert-manager issuer. looking at the same page, do I need to implement customresource?
hey sorry folks, can you point me in the right direction with some links? I'm off to sleep already, but if you can give me some ideas how to implement that I can start trying tomorrow 😉 thanks, sorry for bugging
i

incalculable-sundown-82514

02/12/2019, 9:23 PM
I’m not sure - @gorgeous-egg-16927 @creamy-potato-29402 do you know how to do this with k8s?
c

creamy-potato-29402

02/12/2019, 9:24 PM
why not just implement customresource?
/**
     * CustomResource represents an instance of a CustomResourceDefinition (CRD). For example, the
     * CoreOS Prometheus operator exposes a CRD `<http://monitoring.coreos.com/ServiceMonitor`;|monitoring.coreos.com/ServiceMonitor`;> to
     * instantiate this as a Pulumi resource, one could call `new CustomResource`, passing the
     * `ServiceMonitor` resource definition as an argument.
     */
    export class CustomResource extends pulumi.CustomResource {
      /**
       * APIVersion defines the versioned schema of this representation of an object. Servers should
       * convert recognized schemas to the latest internal value, and may reject unrecognized
       * values. More info:
       * <https://git.k8s.io/community/contributors/devel/api-conventions.md#resources>
       */
      public readonly apiVersion: pulumi.Output<string>;

      /**
       * Kind is a string value representing the REST resource this object represents. Servers may
       * infer this from the endpoint the client submits requests to. Cannot be updated. In
       * CamelCase. More info:
       * <https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds>
       */
      public readonly kind: pulumi.Output<string>;

      /**
       * Standard object metadata; More info:
       * <https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata>.
       */
      public readonly metadata: pulumi.Output<outputApi.meta.v1.ObjectMeta>;

      /**
       * Get the state of an existing `CustomResource`, as identified by `id`.
       * Typically this ID  is of the form <namespace>/<name>; if <namespace> is omitted, then (per
       * Kubernetes convention) the ID becomes default/<name>.
       *
       * Pulumi will keep track of this resource using `name` as the Pulumi ID.
       *
       * @param name _Unique_ name used to register this resource with Pulumi.
       * @param opts Uniquely specifies a CustomResource to select.
       */
      public static get(name: string, opts: CustomResourceGetOptions): CustomResource {
          // NOTE: `selectOpts` will be type `pulumi.CustomResource`. If we add a field that does
          // not satisfy that interface, it will cause a compilation error in `...selectOpts` in
          // the constructor call below.
          const {apiVersion, kind, id, ...selectOpts} = opts;
          return new CustomResource(name, {apiVersion: apiVersion, kind: kind}, { ...selectOpts, id: id });
      }

      public getInputs(): CustomResourceArgs { return this.__inputs; }
      private readonly __inputs: CustomResourceArgs;

      /**
      * Create a CustomResource resource with the given unique name, arguments, and options.
      *
      * @param name The _unique_ name of the resource.
      * @param args The arguments to use to populate this resource's properties.
      * @param opts A bag of options that control this resource's behavior.
      */
      constructor(name: string, args: CustomResourceArgs, opts?: pulumi.CustomResourceOptions) {
          let inputs: pulumi.Inputs = {};
          for (const key of Object.keys(args)) {
              inputs[key] = (args as any)[key];
          }
          super(`kubernetes:${args.apiVersion}:${args.kind}`, name, inputs, opts);
          this.__inputs = args;
      }
    }
we’d accept that PR if you ported it to python.
if not, it is on the roadmap for the next couple weeks.
l

little-river-49422

02/13/2019, 6:34 AM
I'm not talking about kubernetes right now. we might have a scenario where we need to create an atlas mongodb database, you dont support that, so I need to call their api, which is ok, I just need to understand how to "make" pulumi treat it like a first grade citizen
is this possible at all?
i

incalculable-sundown-82514

02/13/2019, 7:44 PM
we support such a thing in JavaScript, but unfortunately it depends on a feature that isn’t easy to replicate in Python (the serialization of code across process boundaries).
your answer is probably “no”.
l

little-river-49422

02/13/2019, 7:46 PM
dang, i guess I'll do it outside and just pass in connection string or something. thanks!
i

incalculable-sundown-82514

02/13/2019, 7:46 PM
sure!