Skip to content

Commit

Permalink
fix: add support for multiple providers for different regions
Browse files Browse the repository at this point in the history
  • Loading branch information
ohoareau committed Sep 2, 2024
1 parent 6f01400 commit 39a029f
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/generators/v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export default async (
[`data.tf`, replace(s, {...vars, is_data_file: true})],
[`locals.tf`, replace(s, {...vars, is_locals_file: true})],
[`variables.tf`, replace(s, {...vars, is_variables_file: true})],
[`outputs.tf`, replace(s, {...vars, is_outputs_file: true})],
[
`providers.tf`,
replace(s, {
Expand All @@ -35,6 +34,26 @@ export default async (
is_providers_file: true,
}) as unknown as string,
],
// region outputs files
...Object.entries(regions).map(
([rCode, r]: [string, layer_region_config]) => {
const isDefault = (r?.id || rCode) === defaultRegion;
return [
`outputs${isDefault ? '' : `_${rCode.replace(/-/g, '_')}`}.tf`,
replace(s, {
...vars,
region: r?.id || rCode,
is_default_outputs: isDefault,
is_outputs_file: true,
is_default_region: isDefault,
psuffix: isDefault ? '' : `.${rCode}`,
rsuffix: isDefault ? '' : `-${rCode}`,
...r,
...(vars?.id ? {id: vars.id} : {}),
}) as unknown as string,
];
},
),
// region main files
...Object.entries(regions).map(
([rCode, r]: [string, layer_region_config]) => {
Expand Down

0 comments on commit 39a029f

Please sign in to comment.