(opts: {
stackName: string;
region: string;
awsProfile?: string;
})
| 141 | * Used after `samDeploy` to populate the local state file. |
| 142 | */ |
| 143 | export function fetchStackOutputs(opts: { |
| 144 | stackName: string; |
| 145 | region: string; |
| 146 | awsProfile?: string; |
| 147 | }): StackOutputBag { |
| 148 | assertAwsCliAvailable(); |
| 149 | const args = [ |
| 150 | "cloudformation", |
| 151 | "describe-stacks", |
| 152 | "--stack-name", |
| 153 | opts.stackName, |
| 154 | "--region", |
| 155 | opts.region, |
| 156 | "--query", |
| 157 | "Stacks[0].Outputs", |
| 158 | "--output", |
| 159 | "json", |
| 160 | ]; |
| 161 | if (opts.awsProfile) { |
| 162 | args.unshift("--profile", opts.awsProfile); |
| 163 | } |
| 164 | const out = execFileSync("aws", args, { encoding: "utf-8" }); |
| 165 | const parsed = JSON.parse(out) as { OutputKey: string; OutputValue: string }[]; |
| 166 | const byKey = new Map(parsed.map((o) => [o.OutputKey, o.OutputValue])); |
| 167 | const bucketName = byKey.get("RenderBucketName"); |
| 168 | const functionName = byKey.get("RenderFunctionArn"); |
| 169 | const stateMachineArn = byKey.get("RenderStateMachineArn"); |
| 170 | if (!bucketName || !functionName || !stateMachineArn) { |
| 171 | throw new Error( |
| 172 | `[lambda] stack ${opts.stackName} is missing one of RenderBucketName/RenderFunctionArn/RenderStateMachineArn. Got keys: ${[...byKey.keys()].join(", ")}`, |
| 173 | ); |
| 174 | } |
| 175 | return { |
| 176 | bucketName, |
| 177 | // RenderFunctionArn is the full ARN; the Lambda function name is the |
| 178 | // last colon-segment, which downstream `getRenderProgress` calls use |
| 179 | // for cost math + CloudWatch lookups. |
| 180 | functionName: functionName.split(":").pop() ?? functionName, |
| 181 | stateMachineArn, |
| 182 | }; |
| 183 | } |
no test coverage detected