-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Added auto-scaling functionality to the consumer and redoer. #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
daeaa84
feat: Added auto-scaling functionality to the consumer and redoer.
jamesiarmes 6276523
ci: Added new variables to workflows.
jamesiarmes 935323e
fix: Missing version constraint.
jamesiarmes ebe55b2
docs: Added some comments for inline documentation.
jamesiarmes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
locals { | ||
prefix = join("-", compact([var.project, var.environment, var.service])) | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
resource "aws_appautoscaling_policy" "up" { | ||
for_each = var.scale_up_policy.enabled ? toset(["this"]) : toset([]) | ||
|
||
name = "${local.prefix}-up" | ||
policy_type = "StepScaling" | ||
resource_id = module.scaling_target.resource_id | ||
scalable_dimension = module.scaling_target.scalable_dimension | ||
service_namespace = module.scaling_target.service_namespace | ||
|
||
step_scaling_policy_configuration { | ||
adjustment_type = "ExactCapacity" | ||
cooldown = 60 | ||
|
||
dynamic "step_adjustment" { | ||
for_each = range(1, var.max_containers + 1) | ||
|
||
content { | ||
scaling_adjustment = step_adjustment.value | ||
|
||
# If we're scaling from 0 to 1, we want the lower bound to be set to our | ||
# starting value, minus 1 to make it inclusive. Otherwise, we want to | ||
# calculate the lower bound based on the step size and current step | ||
# value, and add 1 to make sure we're into the next step. | ||
metric_interval_lower_bound = (step_adjustment.value == 1 | ||
? var.scale_up_policy.start - 1 | ||
: (step_adjustment.value - 1) * var.scale_up_policy.step + 1 | ||
) | ||
|
||
# If we're at the max containers, we don't want to set an upper bound | ||
# since we can't scale any higher. Otherwise, we calculate the upper | ||
# bound based on the step size and current step value, and add 1 because | ||
# the upper bound is exclusive. | ||
metric_interval_upper_bound = (step_adjustment.value == var.max_containers | ||
? null | ||
: step_adjustment.value * var.scale_up_policy.step + 1 | ||
) | ||
} | ||
} | ||
} | ||
} | ||
|
||
resource "aws_appautoscaling_policy" "down" { | ||
for_each = var.scale_down_policy.enabled ? toset(["this"]) : toset([]) | ||
|
||
name = "${local.prefix}-down" | ||
policy_type = "StepScaling" | ||
resource_id = module.scaling_target.resource_id | ||
scalable_dimension = module.scaling_target.scalable_dimension | ||
service_namespace = module.scaling_target.service_namespace | ||
|
||
step_scaling_policy_configuration { | ||
# We've already waited for the queue to be empty for a threshold of time, so | ||
# we don't need a big delay here. | ||
adjustment_type = "ExactCapacity" | ||
cooldown = 60 | ||
|
||
step_adjustment { | ||
metric_interval_upper_bound = 0 | ||
scaling_adjustment = 0 | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.