better-shampoo-48884
03/26/2021, 3:36 PMimport * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure-native";
export const createFunction = async () => { // edit: exported createFunction in addition to stackInfo based on discussion in thread :)
....pulumistuff...
/** edit: Adding more fluff to show how I actually return something from the created variable **/
const rg = new azure.resources.ResourceGroup("myResourceGroup", {
location: "location",
resourceGroupName: "myResourceGroup",
},{
protect: false // prevents this resource from being deleted. unprotect with `pulumi state unprotect <resource URN>`
})
let created : any = {
parameters: {
name: rg.name.apply(name => name),
location: rg.location.apply(location => location),
id: rg.id.apply(id => id),
resource: rg
}
}
....pulumistuff...
return created
}
export const stackInfo = createFunction();
would I be able to import createFunction as my pulumiProgram in automation?bored-oyster-3147
03/26/2021, 3:57 PMTStack
lemon-agent-27707
03/26/2021, 4:03 PMlemon-agent-27707
03/26/2021, 4:04 PMbetter-shampoo-48884
03/26/2021, 4:16 PMbetter-shampoo-48884
03/26/2021, 4:17 PMbetter-shampoo-48884
03/26/2021, 4:18 PMbetter-shampoo-48884
03/26/2021, 4:27 PMfolder\index.ts
folder\Pulumi.yaml
folder\stacks\Pulumi.stack1.yaml
folder\stacks\Pulumi.stack2.yaml
where Pulumi.yaml has this:
name: baseline-infra
runtime: nodejs
description: Baseline infrastructure
config: stacks
backend:
url: <azblob://pulumi-state>
better-shampoo-48884
03/26/2021, 4:28 PMfolder\automation.ts
- can my LocalWorkspace have an empty projectSettings and it will pick up and use Pulumi.yaml correctly (i.e. find my stacks in the stacks folder)?lemon-agent-27707
03/26/2021, 4:30 PMworkDir: folder
and the project settings file should be picked upbetter-shampoo-48884
03/26/2021, 4:33 PMbetter-shampoo-48884
03/26/2021, 4:36 PMbetter-shampoo-48884
03/26/2021, 5:52 PMbetter-shampoo-48884
03/26/2021, 5:52 PMλ ts-node automation.ts --skip-project
c:\<path>\node_modules\@pulumi\pulumi\config.js:276
throw new ConfigMissingError(this.fullKey(key));
^
Error: Missing required configuration variable 'azure:myvar'
better-shampoo-48884
03/26/2021, 5:54 PMimport * as current from "./index"
and used like:
const stack = await pulumiAutomation.LocalWorkspace.createOrSelectStack({
projectName: "baseline-infra",
program: current.createFunction,
stackName: `${envState}.infra.${stackSuffix}`
},{
workDir: "."
}
better-shampoo-48884
03/26/2021, 5:55 PMprogram
perhaps?better-shampoo-48884
03/26/2021, 5:58 PMbetter-shampoo-48884
03/26/2021, 6:19 PM