most-lighter-95902
11/22/2021, 10:45 PMawait stack.setAllConfig(configMap)
to set multiple configs at the same timered-match-15116
11/22/2021, 10:46 PMmost-lighter-95902
11/22/2021, 10:47 PMexport const run = async ({
projectName,
stackName,
program,
plugins,
configMap = {},
}) => {
const args: InlineProgramArgs = {
projectName,
stackName,
program,
}
const stack = await LocalWorkspace.createOrSelectStack(args)
if (Array.isArray(plugins) && plugins.length > 0) {
const pluginPromises = plugins.map(({ name, version, kind }) => {
return stack.workspace.installPlugin(name, version, kind)
})
await Promise.all(pluginPromises)
}
console.log('configs inside Pulumi Run...', configMap)
<http://console.info|console.info>(infoColor('Setting up config...\n'))
await stack.setAllConfig(configMap)
<http://console.info|console.info>(successColor('Config set\n'))
await stack.refresh({ onOutput: <http://console.info|console.info> })
const upRes = await stack.up({ onOutput: <http://console.info|console.info> })
return upRes.outputs
}
const program = async () => {
const customDomain = config.require('custom_domain')
const currentAwsAccount = await aws.getCallerIdentity({})
const awsAccountId = currentAwsAccount.accountId
const currentAwsRegion = await aws.getRegion()
const awsRegion = currentAwsRegion.name
}
const configMap = {
'aws:region': { value: 'us-west-1' },
'custom_domain': { value: '<http://sidetrek.com|sidetrek.com>' },
}
red-match-15116
11/22/2021, 10:51 PMgetAllConfig
?most-lighter-95902
11/22/2021, 10:55 PM{
'aws:region': { value: 'us-west-1', secret: false },
'create-knative-cluster:custom_domain': { value: '<http://sidetrek.com|sidetrek.com>', secret: false },
}
import * as aws from '@pulumi/aws'
red-match-15116
11/22/2021, 10:57 PMmost-lighter-95902
11/22/2021, 10:58 PMconst main = async () => {}
and then export = main
const mainPulumiProgram = require('./main')
await run({
projectName,
stackName: 'cluster',
program: mainPulumiProgram,
configMap: {
'aws:region': { value: 'us-west-1' },
'custom_domain': { value: '<http://sidetrek.com|sidetrek.com>' },
},
options: { destroy: false },
})
red-match-15116
11/22/2021, 11:04 PMmost-lighter-95902
11/22/2021, 11:04 PMred-match-15116
11/22/2021, 11:05 PMstack.up()
?most-lighter-95902
11/22/2021, 11:08 PMconst customDomain = config.require('custom_domain')
seems to work - so configs seem to be setting OK* missing required configuration key "aws:region": The region where AWS operations will take place. Examples are us-east-1, us-west-2, etc.
red-match-15116
11/22/2021, 11:15 PMconst awsConfig = new pulumi.Config("aws")
const region = awsConfig.require("region")
most-lighter-95902
11/22/2021, 11:26 PMup
, it runs without errorred-match-15116
11/23/2021, 12:20 AMconst currentAwsRegion = await aws.getRegion()
const awsRegion = currentAwsRegion.name
with
const awsConfig = new pulumi.Config("aws")
const region = awsConfig.require("region")
And maybe omit the lines:
const currentAwsAccount = await aws.getCallerIdentity({})
const awsAccountId = currentAwsAccount.accountId
If it no longer throws that error then it's related to the functions and refresh...most-lighter-95902
11/23/2021, 2:54 AMred-match-15116
11/23/2021, 3:00 AMaws.GetRegion()
and aws.getCallerIdentity()
are pulumi Functions. They are different than Resources because they fetch data about existing cloud state instead of create a resource in the cloud. This is just a hunch on my part but I'm wondering if there's a link between the issue of refresh
throwing that error and the fact that your program contains pulumi functions.