diff --git a/examples/serverless-agent/fargate/orchestrator/README.md b/examples/serverless-agent/fargate/orchestrator/README.md new file mode 100644 index 00000000..c528b975 --- /dev/null +++ b/examples/serverless-agent/fargate/orchestrator/README.md @@ -0,0 +1,27 @@ +# Serverless Orchestrator Agent + +This example deploys an AWS ECS Fargate cluster to run the Serverless Orchestrator Agent. This Agent acts as a proxy between the Collector and many Serverless Workload Agents. + +## Prerequisites + +The following AWS prerequisites are required to deploy this cluster: +- VPC +- 2 subnets + +## Components + +The cluster will be called `-cluster` and will deploy the following: +- 1 Service (called `OrchestratorAgent`) + - 1 Task (with the latest version of the Serverless Orchestrator Agent) +- Network Load balancer +- Cloudwatch log group +- Security group + +## Layout +| **File** | **Purpose** | +| --- | --- | +| `main.tf` | AWS provider configuration | +| `orchestrator.tf` | Orchestrator cluster definition | +| `output.tf` | Defines the output variables | +| `variables.tf` | AWS and Agent configuration | +| `versions.tf` | Defines TF provider versions | diff --git a/examples/serverless-agent/fargate/orchestrator/orchestrator.tf b/examples/serverless-agent/fargate/orchestrator/orchestrator.tf new file mode 100644 index 00000000..102d9604 --- /dev/null +++ b/examples/serverless-agent/fargate/orchestrator/orchestrator.tf @@ -0,0 +1,36 @@ +module "fargate-orchestrator-agent" { + source = "sysdiglabs/fargate-orchestrator-agent/aws" + version = "0.5.0" + + vpc_id = var.vpc_id + subnets = [var.subnet_1, var.subnet_2] + + access_key = var.access_key + + collector_host = var.collector_host + collector_port = var.collector_port + + name = var.prefix + agent_image = var.agent_orchestrator_image + + # True if the VPC uses an InternetGateway, false otherwise + assign_public_ip = true + + tags = var.tags +} + + +data "aws_ecs_cluster" "fargate-orchestrator" { + depends_on = [ + module.fargate-orchestrator-agent + ] + cluster_name = "${var.prefix}-cluster" +} + +data "aws_ecs_service" "orchestrator-service" { + depends_on = [ + module.fargate-orchestrator-agent + ] + service_name = "OrchestratorAgent" + cluster_arn = data.aws_ecs_cluster.fargate-orchestrator.arn +} diff --git a/examples/serverless-agent/fargate/orchestrator/output.tf b/examples/serverless-agent/fargate/orchestrator/output.tf new file mode 100644 index 00000000..0088749d --- /dev/null +++ b/examples/serverless-agent/fargate/orchestrator/output.tf @@ -0,0 +1,11 @@ +output "orchestrator_cluster_name" { + value = data.aws_ecs_cluster.fargate-orchestrator.cluster_name +} + +output "orchestrator_cluster_arn" { + value = data.aws_ecs_cluster.fargate-orchestrator.arn +} + +output "orchestrator_service_arn" { + value = data.aws_ecs_service.orchestrator-service.arn +} diff --git a/examples/serverless-agent/fargate/orchestrator/providers.tf b/examples/serverless-agent/fargate/orchestrator/providers.tf new file mode 100644 index 00000000..f6f28cca --- /dev/null +++ b/examples/serverless-agent/fargate/orchestrator/providers.tf @@ -0,0 +1,4 @@ +provider "aws" { + region = var.region + profile = var.profile +} diff --git a/examples/serverless-agent/fargate/orchestrator/variables.tf b/examples/serverless-agent/fargate/orchestrator/variables.tf new file mode 100644 index 00000000..92af8fc9 --- /dev/null +++ b/examples/serverless-agent/fargate/orchestrator/variables.tf @@ -0,0 +1,51 @@ +# AWS configuration +variable "prefix" { + description = "All resources created by Terraform have this prefix prepended to them" +} + +variable "profile" { + description = "AWS profile name" + type = string +} + +variable "region" { + description = "AWS Region for deployment" + default = "us-east-1" +} + +variable "subnet_1" { + description = "Subnet-1 Id" +} + +variable "subnet_2" { + description = "Subnet-2 Id" +} + +variable "vpc_id" { + description = "VPC Id" +} + +variable "tags" { + type = map(string) + description = "Tags to assign to resources in module" + default = {} +} + +# Serverless Agent Configuration +variable "access_key" { + description = "Sysdig Agent access key" +} + +variable "agent_orchestrator_image" { + description = "Orchestrator Agent image to use" + default = "quay.io/sysdig/orchestrator-agent:latest" +} + +variable "collector_host" { + description = "Collector host where agent will send the data" +} + +variable "collector_port" { + description = "Collector port where agent will send the data" + default = "6443" +} diff --git a/examples/serverless-agent/fargate/orchestrator/versions.tf b/examples/serverless-agent/fargate/orchestrator/versions.tf new file mode 100644 index 00000000..37120d0a --- /dev/null +++ b/examples/serverless-agent/fargate/orchestrator/versions.tf @@ -0,0 +1,18 @@ +terraform { + required_version = ">=1.7.2" + + required_providers { + aws = { + source = "hashicorp/aws" + version = "~> 5.35.0" + } + local = { + source = "hashicorp/local" + version = "~> 2.4.1" + } + sysdig = { + source = "sysdiglabs/sysdig" + version = "~> 1.24.5" + } + } +} \ No newline at end of file diff --git a/examples/serverless-agent/fargate/workload/README.md b/examples/serverless-agent/fargate/workload/README.md new file mode 100644 index 00000000..f5b79e87 --- /dev/null +++ b/examples/serverless-agent/fargate/workload/README.md @@ -0,0 +1,28 @@ +# Workload with Serverless Workload Agent + +This example deploys a cluster with a workload and the Serverless Workload Agent as a sidecar to secure the workload. + +## Prerequisites + +The following prerequisites are required to deploy this cluster: +- Orchestrator Agent deployed +- VPC +- 2 subnets + +## Components + +The cluster will be called `-instrumented-workload` and will deploy the following: +- 1 Service (called `