Skip to content

Commit

Permalink
fix: issue making it impossible to use stack references (#162)
Browse files Browse the repository at this point in the history
Turns out putting the stack reference function in `index.ts` was a bad
idea. Now, when importing it, the full Pulumi instructions from that
project get included in the parent project as well. Really bad.

This splits it out in a separate file. Do you think it looks OK? Not
sure if this is how to do it.
  • Loading branch information
TriPSs authored Oct 2, 2023
2 parents d5eff34 + e3feae8 commit 13f3b71
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
16 changes: 0 additions & 16 deletions packages/pulumi/src/generators/init/files/index.ts.template
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,3 @@ register({

import './pulumi'
export * from './pulumi'

import * as pulumi from '@pulumi/pulumi';

type ExportTypes = typeof import('./pulumi');
type ExportTypesKey = keyof ExportTypes;
type ExportTypesValue<TKey extends ExportTypesKey> = ExportTypes[TKey];

type StrongTypedStackReference = Omit<pulumi.StackReference, 'getOutput' | 'requireOutput'> & {
getOutput<T extends ExportTypesKey>(name: pulumi.Input<T>): ExportTypesValue<T>;
requireOutput<T extends ExportTypesKey>(name: pulumi.Input<T>): ExportTypesValue<T>;
};

export function getStackReference() {
const stack = pulumi.getStack();
return new pulumi.StackReference(`organization/<%= name %>/${stack}`) as StrongTypedStackReference;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import * as pulumi from '@pulumi/pulumi';

type ExportTypes = typeof import('./pulumi');
type ExportTypesKey = keyof ExportTypes;
type ExportTypesValue<TKey extends ExportTypesKey> = ExportTypes[TKey];

type StrongTypedStackReference = Omit<pulumi.StackReference, 'getOutput' | 'requireOutput'> & {
getOutput<T extends ExportTypesKey>(name: pulumi.Input<T>): ExportTypesValue<T>;
requireOutput<T extends ExportTypesKey>(name: pulumi.Input<T>): ExportTypesValue<T>;
};

export function getStackReference() {
const stack = pulumi.getStack();
return new pulumi.StackReference(`organization/<%= name %>/${stack}`) as StrongTypedStackReference;
}

0 comments on commit 13f3b71

Please sign in to comment.