-
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.
* chore(fis): rename files of fis example * fix(fis): apply awsfis module * chore(fis): grooming awscw resources
- Loading branch information
Showing
8 changed files
with
168 additions
and
267 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,84 @@ | ||
resource "aws_ssm_association" "install-cwagent" { | ||
depends_on = [module.ec2] | ||
name = "AWS-ConfigureAWSPackage" | ||
|
||
targets { | ||
key = "tag:release" | ||
values = ["baseline,canary"] | ||
} | ||
|
||
parameters = { | ||
action = "Install" | ||
name = "AmazonCloudWatchAgent" | ||
} | ||
} | ||
|
||
resource "time_sleep" "wait" { | ||
depends_on = [aws_ssm_association.install-cwagent] | ||
create_duration = "30s" | ||
} | ||
|
||
resource "aws_ssm_association" "start-cwagent" { | ||
depends_on = [time_sleep.wait] | ||
name = "AmazonCloudWatch-ManageAgent" | ||
|
||
targets { | ||
key = "tag:release" | ||
values = ["baseline,canary"] | ||
} | ||
|
||
parameters = { | ||
action = "start" | ||
} | ||
} | ||
|
||
### application/monitoring | ||
resource "aws_cloudwatch_metric_alarm" "cpu" { | ||
alarm_name = local.cw_cpu_alarm_name | ||
alarm_description = "This metric monitors ec2 cpu utilization" | ||
tags = merge(local.default-tags, var.tags) | ||
comparison_operator = "GreaterThanOrEqualToThreshold" | ||
evaluation_periods = 3 | ||
metric_name = "CPUUtilization" | ||
namespace = "AWS/EC2" | ||
period = 60 | ||
statistic = "Average" | ||
threshold = 60 | ||
insufficient_data_actions = [] | ||
|
||
dimensions = { | ||
AutoScalingGroupName = module.ec2.cluster.data_plane.node_groups.baseline.name | ||
} | ||
} | ||
|
||
resource "aws_cloudwatch_metric_alarm" "api-p90" { | ||
alarm_name = local.cw_api_p90_alarm_name | ||
alarm_description = "This metric monitors percentile of response latency" | ||
tags = merge(local.default-tags, var.tags) | ||
comparison_operator = "GreaterThanThreshold" | ||
evaluation_periods = 1 | ||
metric_name = "TargetResponseTime" | ||
namespace = "AWS/ApplicationELB" | ||
period = 60 | ||
unit = "Seconds" | ||
threshold = 0.1 | ||
extended_statistic = "p90" | ||
|
||
dimensions = { | ||
LoadBalancer = aws_lb.alb.arn_suffix | ||
} | ||
} | ||
|
||
resource "aws_cloudwatch_metric_alarm" "api-avg" { | ||
alarm_name = local.cw_api_avg_alarm_name | ||
alarm_description = "This metric monitors average time of response latency" | ||
tags = merge(local.default-tags, var.tags) | ||
comparison_operator = "GreaterThanThreshold" | ||
evaluation_periods = 1 | ||
metric_name = "TargetResponseTime" | ||
namespace = "AWS/ApplicationELB" | ||
period = 60 | ||
unit = "Seconds" | ||
statistic = "Average" | ||
threshold = 0.1 | ||
|
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 |
---|---|---|
@@ -0,0 +1,84 @@ | ||
### systems manager document for fault injection simulator experiment | ||
|
||
resource "aws_ssm_document" "disk-stress" { | ||
name = "FIS-Run-Disk-Stress" | ||
tags = merge(local.default-tags, var.tags) | ||
document_format = "YAML" | ||
document_type = "Command" | ||
content = file("${path.module}/templates/disk-stress.yaml") | ||
} | ||
|
||
### fault injection simulator experiment templates | ||
|
||
# drawing lots for choosing a subnet | ||
resource "random_integer" "az" { | ||
min = 0 | ||
max = length(var.azs) - 1 | ||
} | ||
|
||
locals { | ||
target_vpc = module.vpc.vpc.id | ||
target_role = module.ec2.role.arn | ||
target_asg = module.ec2.cluster.data_plane.node_groups.baseline.name | ||
fis_role = module.awsfis.role.arn | ||
|
||
experiments = [ | ||
{ | ||
name = "cpu-stress" | ||
template = "${path.cwd}/templates/cpu-stress.tpl" | ||
params = { | ||
asg = local.target_asg | ||
region = var.aws_region | ||
alarm = aws_cloudwatch_metric_alarm.cpu.arn | ||
role = local.fis_role | ||
} | ||
}, | ||
{ | ||
name = "network-latency" | ||
template = "${path.cwd}/templates/network-latency.tpl" | ||
params = { | ||
asg = local.target_asg | ||
region = var.aws_region | ||
alarm = aws_cloudwatch_metric_alarm.cpu.arn | ||
role = local.fis_role | ||
} | ||
}, | ||
{ | ||
name = "terminate-instances" | ||
template = "${path.cwd}/templates/terminate-instances.tpl" | ||
params = { | ||
asg = local.target_asg | ||
az = var.azs[random_integer.az.result] | ||
vpc = local.target_vpc | ||
alarm = aws_cloudwatch_metric_alarm.cpu.arn | ||
role = local.fis_role | ||
} | ||
}, | ||
{ | ||
name = "throttle-ec2-api" | ||
template = "${path.cwd}/templates/throttle-ec2-api.tpl" | ||
params = { | ||
asg_role = local.target_role | ||
alarm = aws_cloudwatch_metric_alarm.cpu.arn | ||
role = local.fis_role | ||
} | ||
}, | ||
{ | ||
name = "disk-stress" | ||
template = "${path.cwd}/templates/disk-stress.tpl" | ||
params = { | ||
doc_arn = aws_ssm_document.disk-stress.arn | ||
region = var.aws_region | ||
alarm = aws_cloudwatch_metric_alarm.cpu.arn | ||
role = local.fis_role | ||
} | ||
}, | ||
] | ||
} | ||
|
||
module "awsfis" { | ||
source = "Young-ook/fis/aws" | ||
name = var.name | ||
tags = var.tags | ||
experiments = local.experiments | ||
} |
File renamed without changes.
Oops, something went wrong.