
Q-Bits: Testing Amazon ECS Network Resilience with AWS FIS
This article demonstrates how Amazon Q Developer can help quickly ramp-up on features of AWS services through an example of Amazon ECS tasks and AWS FIS.
Welcome to another installment of Q-Bits, our regular series showcasing cool ways Amazon employees are leveraging Amazon Q Developer. Today, we're diving into how Q Developer can help create Amazon ECS Task Definitions for fault injection.
Help me create an ECS fargate task definition that implements network fault injection endpoints for testing resilience.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
{
"family": "fault-injection-task",
"networkMode": "awsvpc",
"requiresCompatibilities": ["FARGATE"],
"cpu": "256",
"memory": "512",
"enableFaultInjection": true,
"containerDefinitions": [
{
"name": "app-container",
"image": "your-app-image:latest",
"essential": true,
"portMappings": [
{
"containerPort": 80,
"hostPort": 80,
"protocol": "tcp"
}
]
}
]
}
enableFaultInjection
property caught my attention, so I asked Q Developer to explain its purpose.Tell me more about the enableFaultInjection property.
true,
it allows fault injection requests to be accepted from the task's containers. Now I wanted to understand more about the prerequisites for the ability inject network faults and asked Q Developer to help with this.What are the prerequisites for using the fault injection feature?
networkMode
is set to awsvpc
( which is the default for Fargate) and setpidMode
to task
if you plan to use certain fault injection actions like process killing or network manipulation.With the task definition configured to support fault injection, the next step was to create an experiment that would actually test our application's resilience using AWS Fault Injection Service (FIS).
Tell me about the requirements for using AWS Fault Injection Service (FIS) with Amazon ECS tasks.
Add the SSM agent container mentioned to the ECS task definition json provided earlier.
Create an FIS experiment template in yaml for the ECS fargate network latency fault action.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
description: "ECS Fargate Network Latency Fault Injection Experiment"
stopConditions:
- source: "aws:cloudwatch:alarm"
value: "arn:aws:cloudwatch:us-east-1:123456789012:alarm:MyAlarm"
targets:
ecsTarget:
resourceType: "aws:ecs:task"
selectionMode: "ALL"
resourceTags:
Application: "MyApp"
Environment: "Production"
actions:
injectNetworkLatency:
actionId: "aws:ecs:task-network-latency"
description: "Inject network latency into ECS Fargate tasks"
parameters:
duration: "PT5M"
delayMilliseconds: "100"
jitterMilliseconds: "50"
useEcsFaultInjectionEndpoints: "true"
targets:
Tasks: "ecsTarget"
roleArn: "arn:aws:iam::123456789012:role/FISExperimentRole"
tags:
Project: "Resilience-Testing"
Owner: "DevOps-Team"
enableFaultInjection
property, and generated the FIS experiment template. The interactive Q&A format reduced the research time to minutes. Q Developer guided me through the configuration steps needed and explained the prerequisites. This experience demonstrated Q Developer's value as a learning tool for AWS services and features.Any opinions in this post are those of the individual author and may not reflect the opinions of AWS.