Does the arg structure need to be flat and use `pu...
# multi-language-hackathon
g
Does the arg structure need to be flat and use
pulumi.Input
types? I'm using typescript but am curious about Go, too. It looks like Go has a converter https://github.com/jaxxstorm/runmydamncontainer/blob/64064f31565fb96157387202a854a4af1ffdf083/provider/pkg/provider/provider.go#L65 Option A - flat with pulumi types:
Copy code
export interface StaticPageArgs {
    indexContent: pulumi.Input<string>;
}
Or can there be more complex inputs that use standard language (eg. typescript) types or previously defined types? For example, if I wanted to create a cloudfront distribution where the user can access ~ most ~ of the ordinary Cloudfront config arguments, would something like this work? Option B:
Copy code
import { DistributionArgs } from '@pulumi/aws/cloudfront';

export interface StaticPageArgs {
  indexContent: pulumi.Input<string>;
  someRandomHardcodedConfigValue: number;

  // cloudfront distribution args would be available at `args.cloudfront`
  cloudfront: DistributionArgs;
}
Option B reeemixx:
Copy code
import { DistributionArgs } from '@pulumi/aws/cloudfront';

export interface StaticPageArgs extends DistributionArgs{
  indexContent: pulumi.Input<string>;

  //Cloudfront Distribution args would be available here at the root of args
}
Option C:
Copy code
import { DistributionArgs } from '@pulumi/aws/cloudfront';

export interface StaticPageArgs extends DistributionArgs{
  indexContent: pulumi.Input<string>;
  
  // only provide the user with very limited sets of options because pulumi wants to provide heavily
  // opinionated "best practice" components
  cloudfrontName: pulumi.Input<string>;
}
b
@white-balloon-205 do you have an answer here? I don't 😞
g
After taking a look at how the underlying cloudfront CustomResource works [1], it seems like pulumi.Input can wrap standard typescript types (eg.
<<http://pulumi.as>|pulumi.Input<string>
as> well as other nested types (eg.
Pulumi.Input<inputs.cloudfront.DistributionDefaultCacheBehavior>
where inputs.cloudfront.DistributionCacheBehavior is defined in the
./types/input
file: https://raw.githubusercontent.com/pulumi/pulumi-aws/master/sdk/nodejs/types/input.ts [1] https://github.com/pulumi/pulumi-aws/blob/master/sdk/nodejs/cloudfront/distribution.ts
Note: thanks @flaky-ghost-73674 for pointing out that types can be added to the
schema.json
, just like the "bucket" type is provided here: https://github.com/pulumi/pulumi-component-provider-ts-boilerplate/blob/048f04a8c021e951eeac47b193a1ae819343c4e7/schema.json#L17
@flaky-ghost-73674, having trouble finding the resource definitions for other resource types, any ideas? ie.
/aws/v4.0.0/schema.json#/resources/aws:s3%2Fbucket:Bucket
for cloudfront.Distribution
b
f
that particular one is awscloudfront/distributionDistribution
In the future, I’ve found it’s helpful to search with the type name you’re looking for (“Distribution”) with a
:
in front (e.g.
:Distribution
)
🙌 1
This is definitely an area we need to improve