-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* UML-3114 Use global DynamoDB tables
- Loading branch information
Sam Ainsworth
authored
Oct 16, 2023
1 parent
8b2e943
commit e617e18
Showing
11 changed files
with
222 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,26 @@ | ||
locals { | ||
policy_region_prefix = lower(replace(data.aws_region.current.name, "-", "")) | ||
} | ||
|
||
# The primary region is the region where the DynamoDB tables are created and replicated to the secondary region. | ||
primary_region = keys({ for region, region_data in var.regions : region => region_data if region_data.is_primary })[0] | ||
is_primary_region = local.primary_region == data.aws_region.current.name ? true : false | ||
is_active_region = var.regions[data.aws_region.current.name].is_active | ||
|
||
# Desired count of the ECS services. Only an active region will have a desired count greater than 0. | ||
use_desired_count = local.is_active_region ? var.autoscaling.use.minimum : 0 | ||
pdf_desired_count = local.is_active_region ? var.autoscaling.pdf.minimum : 0 | ||
view_desired_count = local.is_active_region ? var.autoscaling.view.minimum : 0 | ||
api_desired_count = local.is_active_region ? var.autoscaling.api.minimum : 0 | ||
admin_desired_count = local.is_active_region ? 1 : 0 | ||
|
||
# Replace the region in the ARN of the DynamoDB tables with the region of the current stack as the tables are created in the primary region | ||
# and replicated to the secondary region. This allows use to grant access to the tables in the secondary region for applications running in the secondary region. | ||
dynamodb_tables_arns = { | ||
actor_codes_table_arn = replace(var.dynamodb_tables.actor_codes_table.arn, local.primary_region, data.aws_region.current.name) | ||
stats_table_arn = replace(var.dynamodb_tables.stats_table.arn, local.primary_region, data.aws_region.current.name) | ||
actor_users_table_arn = replace(var.dynamodb_tables.actor_users_table.arn, local.primary_region, data.aws_region.current.name) | ||
viewer_codes_table_arn = replace(var.dynamodb_tables.viewer_codes_table.arn, local.primary_region, data.aws_region.current.name) | ||
viewer_activity_table_arn = replace(var.dynamodb_tables.viewer_activity_table.arn, local.primary_region, data.aws_region.current.name) | ||
user_lpa_actor_map_arn = replace(var.dynamodb_tables.user_lpa_actor_map.arn, local.primary_region, data.aws_region.current.name) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.