Good afternoon. New to Pulumi, and to automation-...
# automation-api
m
Good afternoon. New to Pulumi, and to automation-api. I'm trying to do completely "inline" code. I'm using C#/Visual Studio 2022. How would one set a "nested" config option? The example in github only does a single value like so:
await stack.SetConfigAsync("aws:region", new ConfigValue("us-west-2"));
l
This section of the docs has most of the answers: https://www.pulumi.com/docs/iac/concepts/config/#structured-configuration
But you probably also want to read up on scoped configuration, to understand how "myproject:var", "aws:var" and "pulumi:autonaming.pattern" are all different. https://www.pulumi.com/docs/iac/concepts/config/#code
m
i do understand they are different, but like i said, i just need to know how to set it correctly in the "inline" configuration.
l
Same syntax as in the first link. Only one colon.
So you need to create a Config in the
pulumi
scope, not in the app scope. And then you can set
autonaming:pattern
.
m
Copy code
var projectName = "inline_dev";
var stackName = "dev";

// create or select a stack matching the specified name and project
// this will set up a workspace with everything necessary to run our inline program (program)
var stackArgs = new InlineProgramArgs(projectName, stackName, program);
var stack = LocalWorkspace.CreateOrSelectStackAsync(stackArgs).Result;

//Console.WriteLine("successfully initialized stack");

// for inline programs, we must manage plugins ourselves
//Console.WriteLine("installing plugins...");
stack.Workspace.InstallPluginAsync("aws", "v6.66.3");
//Console.WriteLine("plugins installed");

// set stack configuration specifying the region to deploy
//Console.WriteLine("setting up config...");
stack.SetConfigAsync("aws:region", new ConfigValue("us-east-1"));
stack.SetConfigAsync("aws:profile", new ConfigValue("devadmin"));
are you saying i need to do it like one by one..like..
var config = new Pulumi.Config() and THEN use like config.SetConfigAsync("autonaming:pattern", <blah>);?
well, that did not work.
"Trying to acquire Deployment.Instance before 'Run' was called."
l
You need different configs.
Copy code
const awsConfig = new pulumi.Config('aws');
const pulumiConfig = new pulumi.Config('pulumi');
Etc.
I don't know what the equivalent is for
stack.setConfig()
is, sorry.
m
pretty sure its the SetConfigAsync
l
So, Async is addressing a separate problem. However, it could be
setConfig(key, value, path?)
.
There may be an Async version of that, to solve both issues at once.
What language? C#?
m
c# yes.
l
Wow those docs. I have no idea how to read those. Where's the automation namespace?
m
all of that is the automation namespace
oh, thats what you mean 😄
l
Hmm. There's no equivalent to the JS/TS
setConfig(key, value, path?)
. Maybe that's a problem?
I think you're going to need to ask on #CQ2QFLNFL and maybe even in https://github.com/pulumi/pulumi-dotnet/issues. It's too far from what I'm familiar with, sorry.
m
no worries, lol.