polite-napkin-90098
05/11/2023, 3:49 PMimport * as values from './src/config/values';
// export aws config options.
export const awsConfigOptions = values.awsConfigOptions;
where values has
// export aws config object.
export const awsConfigOptions = {
// aws region.
region: <aws.Region>awsConfig.require('region'),
// allow EC2 instance metadata authentication.
skipMetadataApiCheck: awsConfig.requireBoolean('skipMetadataApiCheck'),
// also for EC2 metadata auth.
skipCredentialsValidation: awsConfig.requireBoolean('skipCredentialsValidation'),
// assume role.
assumeRole: <aws.types.input.ProviderAssumeRole>awsConfig.requireObject('assumeRole'),
}
and the config for each stack could be sensibly set the pulumi config set
I then imported the exported config into the descendent stacks thusly:
in a file called src/stacks/vpc.ts
const config = new pulumi.Config()
const vpcStack = new pulumi.StackReference(config.require('vpcStackName'));
// get the awsConfig from the vpcStackName
const awsConfig = vpcStack.requireOutput('awsConfigOptions');
to use this I found I needed an apply to convert the Output back to a string so:
export const awsProvider = awsConfig.apply((awsC) => {
return new aws.Provider(`${stackName}-awsProvider`, {
...awsC,
});
});
then I used that as a provider in my stack files which generate the resources with another apply thusly
// Make all the AWS parameter store secure strings for the api deployments.
import * as pulumi from '@pulumi/pulumi';
import * as aws from '@pulumi/aws';
import { awsProvider, vpcId } from '../src/stacks/vpc';
import { albStack } from '../src/stacks/alb';
import { stackName } from '../src/config/values';
const nom = stackName.split('-')[0];
export const targetGroups = (hostHeader: string) => {
const tGroups = awsProvider.apply(prov => {
const reactTarget = new aws.lb.TargetGroup(name,
...
}, {provider: prov});
});
};
little-cartoon-10569
05/11/2023, 8:53 PMgetOutputDetails()
here: https://www.pulumi.com/docs/intro/concepts/stack/#reading-outputs-from-stack-referencespolite-napkin-90098
05/11/2023, 9:02 PMlittle-cartoon-10569
05/11/2023, 9:05 PM