Skip to content

Add code snippets for common Pulumi Boilerplate #15

@zbuchheit

Description

@zbuchheit

Hello!

  • Vote on this issue by adding a 👍 reaction
  • If you want to implement this feature, comment to let us know (we'll work with you on design, scheduling, etc.)

Issue details

It would be nice as part of the vscode extension to get some code snippets. For example having a snippet for component resources or dynamic resources would save time and make it easier on users. It would also help to guide them in best practices.

Example Typescript Component Resource Code Snippet
{
	"Pulumi Component Resource": {
		"prefix": "pulumi-component",
		"body": [
			"import * as pulumi from '@pulumi/pulumi';",
			"",
			"export interface ${1:ComponentResourceArgs} {",
			"  ${2:property1}?: pulumi.Input<string>;",
			"  ${3:property2}?: pulumi.Input<number>;",
			"}",
			"",
			"export class ${4:MyComponentResource} extends pulumi.ComponentResource {",
			"  public readonly ${5:outputProperty}: pulumi.Output<string>;",
			"",
			"  constructor(name: string, args: ${1:ComponentResourceArgs}, opts?: pulumi.CustomResourceOptions) {",
			"    super('${6:my:module:ComponentResource}', name, {}, opts);",
			"",
			"    // Example of using the args to define resources",
			"    const exampleResource = new pulumi.resource.${7:SomeResource}('${8:exampleResource}', {",
			"      ${2:property1}: args.${2:property1},",
			"    }, { parent: this });",
			"",
			"    // Example of exporting a property from the component",
			"    this.${5:outputProperty} = pulumi.output('${9:some-output-value}');",
			"",
			"    this.registerOutputs({",
			"      ${5:outputProperty}: this.${5:outputProperty}",
			"    });",
			"  }",
			"}"
		],
		"description": "Pulumi TypeScript Component Resource template"
	}
}

Affected area/feature

Metadata

Metadata

Assignees

No one assigned

    Labels

    good-first-issueStart here if you'd like to start contributing to Pulumikind/enhancementImprovements or new features

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions