export function getAmiParameters()

in src/riff-raff-yaml-file/deployments/cloudformation.ts [51:75]


export function getAmiParameters(autoScalingGroups: GuAutoScalingGroup[]): RiffRaffDeploymentParameters {
  return autoScalingGroups.reduce<RiffRaffDeploymentParameters>((acc, asg) => {
    const { imageRecipe, app, amiParameter } = asg;

    if (!imageRecipe) {
      throw new Error(`Unable to produce a working riff-raff.yaml file; imageRecipe missing from ASG ${app}`);
    }

    const Recipe = typeof imageRecipe === "string" ? imageRecipe : imageRecipe.Recipe;
    const AmigoStage = typeof imageRecipe === "string" ? "PROD" : (imageRecipe.AmigoStage ?? "PROD");

    // In YAML `true` is a Boolean. Riff-Raff expects a String here, so call `toString` to make it `'true'`.
    const Encrypted = (typeof imageRecipe === "string" ? true : (imageRecipe.Encrypted ?? true)).toString();

    return {
      ...acc,
      [amiParameter.node.id]: {
        BuiltBy: "amigo",
        AmigoStage,
        Recipe,
        Encrypted,
      },
    };
  }, {});
}