Amazon ECS
This guide shows you how to deploy Prisma Cloud Defenders in an ECS cluster.
Defender protects your containerized environment according to the policies you set in Prisma Cloud Console.
It runs as a service in your ECS cluster.
The parameters of the service are described in a task definition, and the task definition is written in JSON format.
To automatically deploy an instance of Defender on each node in your cluster, you’ll run the Defender task as a daemon service.
This guide assumes you know very little about AWS ECS.
As such, it is extremely prescriptive, and includes step for building your cluster.
If you are already familiar with AWS ECS and do not need assistance navigating the interface, simply read the section synopsis, which summarizes all key configurations.
To better understand clusters, read our cluster context topic.
Create a cluster
Create an empty cluster named pc-ecs-cluster.
Later, you will create launch configurations and auto-scaling groups to start EC2 instances in the cluster.
- Log into the AWS Management Console.
- Go toServices > Containers > Elastic Container Service.
- ClickCreate Cluster.
- SelectNetworking only, then clickNext Step.
- Enter a cluster name, such aspc-ecs-cluster.
- ClickCreate.
Deploy Defender
Create worker nodes in your ECS cluster, create a task definition for the Prisma Cloud Defender, and then create a service of type Daemon to deploy Defender to every node in the cluster.
If you already have worker nodes in your cluster, skip directly to creating the Defender task definition.
Create a launch configuration for worker nodes
Create a launch configuration named pc-worker-node that:
- Runs the Amazon ECS-Optimized Amazon Linux 2 AMI.
- Uses the ecsInstanceRole IAM role.
- Runs a user data script that joins the pc-ecs-cluster and runs the commands required to install Defender.
- Go toServices > Compute > EC2.
- In the left menu, clickAuto Scaling > Launch Configurations.
- ClickCreate Launch Configuration
- InName, enter a name for your launch configuration, such aspc-worker-node.
- In Amazon machine image, selectAmazon ECS-Optimized Amazon Linux 2 AMI.You can get a complete list of per-region Amazon ECS-optimized AMIs from here.
- Choose an instance type, such ast2.medium.
- UnderAdditional configuration:
- InIAM instance profile, selectecsInstanceRole.
- UnderUser data, selectText, and paste the following code snippet:#!/bin/bash echo ECS_CLUSTER=pc-ecs-cluster >> /etc/ecs/ecs.configWhere:
- ECS_CLUSTER must match your cluster name. If you’ve named your cluster something other than pc_ecs_cluster, then modify your user data script accordingly.
(Optional) InIP Address Type, selectAssign a public IP address to every instance.With this option, you can easily SSH to this instance to troubleshoot issues. - UnderSecurity groups:
- SelectSelect an existing security group.
- Selectpc-security-group.
- UnderKey pair (login), select an existing key pair, or create a new key pair so that you can access your instances.
- ClickCreate launch configuration.
Create an auto scaling group for worker nodes
Launch two worker nodes into your cluster.
- Go toServices > Compute > EC2.
- In the left menu, clickAuto Scaling > Auto Scaling Groups.
- ClickCreate an Auto Scaling group.
- InChoose launch template or configuration:
- InAuto Scaling group Name, enterpc-worker-autoscaling.
- InLaunch template, clickSwitch to launch configuration.
- Selectpc-worker-node.
- ClickNext.
- UnderConfigure settings:
- InVPC, select your default VPC.
- InSubnet, select a public subnet, such as 172.31.0.0/20.
- ClickNext.
- InConfigure advanced options, accept the defaults, and clickNext.
- InConfigure group size and scaling policies:
- SetDesired capacityto2.
- LeaveMinimum capacityat1.
- SetMaximum capacityto2.
- ClickSkip to review.
- Review the configuration and clickCreate Auto Scaling Group.After the auto scaling group spins up (it will take some time), validate that your cluster has three container instances.
- Go toServices > Containers > Elastic Container Service.
- The count forContainer instancesin your cluster should now be a total of two.
Create a Prisma Cloud Defender task definition
Generate a task definition for Defender in Prisma Cloud Console.
- Log into Prisma Cloud Compute Console.
- Go toManage > Defenders > Deploy > Defenders.
- InDeployment method, selectOrchestrator.
- For orchestrator type, selectECS.
- InSpecify a cluster name, leave the field blank.Console will automatically retrieve the cluster name from AWS. Only enter a value if you want to override the cluster name assigned in AWS.
- InSpecify ECS task name, leave the field blank.By default, the task name ispc-defender.
- ClickDownloadto download the task definition.
- Log into AWS.
- Go toServices > Containers > Elastic Container Service.
- In the left menu, clickTask Definitions.
- ClickCreate new Task Definition.
- InStep 1: Select launch type compatibility, selectEC2, then clickNext step.
- InStep 2: Configure task and container definitions, scroll to the bottom of the page and clickConfigure via JSON.