Skip to content

Commit

Permalink
fix: clean up deployment code
Browse files Browse the repository at this point in the history
  • Loading branch information
scottydawg committed Aug 11, 2022
1 parent d7885fc commit e585045
Showing 1 changed file with 0 additions and 14 deletions.
14 changes: 0 additions & 14 deletions packages/events-example/src/deployments/PulumiAwsDeployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,17 @@ export default class PulumiAwsDeployment {
}

async getStack(stackName: string, program: PulumiFn): Promise<Stack> {
console.log(`PulumiAwsDeployments.getStack ${stackName}`);

const args: InlineProgramArgs = {
stackName,
projectName: this.projectName,
program,
};
console.log('\tcreateOrSelectStat', args);
const stack = await LocalWorkspace.createOrSelectStack(args);

console.log('\tstack retrieved');
//await stack.setConfig('aws:region', { value: 'us-east-2' });
return stack;
}

async createStack(instance: Instance): Promise<UpResult> {
console.log(`createStack ${ instance.id }`);
const stack = await this.getStack(instance.id, this.pulumiProgram(instance));
await this.configureStack(stack, instance);
await this.waitOnStack(stack);
Expand All @@ -82,21 +76,15 @@ export default class PulumiAwsDeployment {
const instanceProps = instance.properties as {[key: string]: any} | undefined;
const stackConfig = instanceProps?.config as ConfigMap ? instanceProps!.config : { "aws:region": "us-east-2" };

console.log(`Config for instance ${ instance.id }`);
console.log(stackConfig);

for (const key of Object.keys(stackConfig)) {
console.log(`setting config ${key} = ${stackConfig[key]}`);
await stack.setConfig(key, { value: `${stackConfig[key]}` });
}
}

private async waitOnStack(stack: Stack): Promise<void> {
console.log('waitOnStack');
let stackInfo;
do {
stackInfo = await stack.info();
console.log(stackInfo);
} while (this.isUnresolved(stackInfo));
}

Expand All @@ -108,10 +96,8 @@ export default class PulumiAwsDeployment {
}

async destroyStack(id: string): Promise<DestroyResult> {
console.log(`destroyStack ${id}`);
const stack = await this.getStack(id, this.pulumiProgram());
await this.waitOnStack(stack);
console.log('proceeding with destroy...');
try {
CliUx.ux.action.start(`Destroying a stack id=${id}`);
return await stack.destroy({ onOutput: console.log });
Expand Down

0 comments on commit e585045

Please sign in to comment.