in packages/blueprints/launch-blueprint/src/blueprint.ts [183:241]
protected mapParametersToAction(action: { [id: string]: any }) {
//set variables with options where applicable
const variables = action.Inputs?.Variables as InputVariable[] | undefined;
for (const variable of variables ?? []) {
const optionName = variable.Name as string;
const specifiedValue =
this.state.options.launchOptions?.find(option => option.key == optionName)?.value ??
this.state.options.parameters.find(parameter => `${OPTIONS_PREFIX}${parameter.key}` == optionName)?.value;
if (specifiedValue) {
variable.Value = specifiedValue.toString();
}
}
//set action environments from options where applicable
const actionEnvironment = action.Environment as WorkflowEnvironment | undefined;
if (actionEnvironment?.Name) {
const launchEnvironment = (this.state.options.launchOptions?.find(
option => option.displayType == 'environment' && option.value?.name == actionEnvironment.Name,
)?.value ?? this.state.options.environments?.find(env => env.name == actionEnvironment.Name)) as EnvironmentDefinition<{
awsAccountConnection: AccountConnection<{
launchRole: Role<['codecatalyst*']>;
}>;
}>;
if (launchEnvironment?.awsAccountConnection?.name) {
const connection = launchEnvironment.awsAccountConnection;
actionEnvironment.Connections = [
{
Name: connection.name,
Role: connection.launchRole?.name ?? 'No role selected',
} as ConnectionDefinition,
];
}
}
//set parameter overrides
if (action.Identifier?.startsWith('aws/cfn-deploy@')) {
const overrides = action.Configuration?.['parameter-overrides'];
if (overrides) {
const parameters: { key: string; value: string }[] = overrides.split(',').map((p: string) => {
const tuple = p.split('=');
return { key: tuple[0], value: tuple[1] };
});
let newOverrides = '';
for (const parameter of parameters) {
const override =
this.state.options.launchOptions?.find(option => option.key == parameter.key)?.value ??
this.state.options.parameters?.find(option => `${OPTIONS_PREFIX}${option.key}` == parameter.key);
newOverrides += `${parameter.key}=${override ?? parameter.value},`;
}
//remove trailing comma and overwrite
if (newOverrides) {
action.Configuration['parameter-overrides'] = newOverrides.substring(0, newOverrides.length - 1);
}
}
}
}