Amazon ECS
Anchore uses a go binary called anchore-ecs-inventory that leverages the AWS Go SDK to gather an inventory of containers and their images running on Amazon ECS and report back to Anchore Enterprise.
The Amazon ECS Inventory Agent can be installed via Helm Chart or as an ECS Service on AWS Fargate.
Deploying via Helm on Kubernetes
You can install the chart via the Anchore Enterprise repository:
helm repo add anchore https://charts.anchore.io
helm install <release-name> -f <values.yaml> anchore/ecs-inventory
A basic values file can be found here.
IAM Role Configuration
The following IAM role permissions should be used in order to allow the Anchore ECS Inventory Agent to poll the ECS service API for running inventory:
cat <<EOF > ecs-read-only-policy.json
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"ecs:Describe*",
"ecs:List*"
],
"Effect": "Allow",
"Resource": "*"
}
]
}
EOF
aws iam create-policy \
--policy-name ECSReadOnly \
--policy-document file://ecs-read-only-policy.json
Follow the AWS instructions found here to assign your IAM role to a Kubernetes service account in your cluster where the Anchore ECS Inventory Agent will be running. Then configure the following in your values.yaml to ensure the agent has access to the ECS service API:
serviceAccountName: "service_account_name"
Using existing secrets
For those users unable to use IAM roles (e.g. the ECS Inventory Agent is not running on Kubernetes or ECS), the (ecsInventory.useExistingSecret and ecsInventory.existingSecretName) or ecsInventory.injectSecretsViaEnv keys allows you to create your own secret and provide it in the values file or place the required secret into the pod via different means such as injecting the secrets into the pod using hashicorp vault. For example:
Create a secret in kubernetes:
apiVersion: v1 kind: Secret metadata: name: ecs-inventory-secrets type: Opaque stringData: ANCHORE_ECS_INVENTORY_ANCHORE_PASSWORD: foobar AWS_ACCESS_KEY_ID: someKeyId AWS_SECRET_ACCESS_KEY: someSecretAccessKeyProvide it to the helm chart via the values file:
ecsInventory: useExistingSecret: true existingSecretName: "ecs-inventory-secrets"
Deploying as an ECS Service on AWS Fargate
You can deploy the ecs-inventory container as an ECS Service on AWS Fargate. Running the agent as a service ensures that ECS automatically restarts the task if it stops, maintaining continuous inventory reporting to Anchore Enterprise.
Set Environment Variables
Set the following environment variables before running the commands below. Replace the placeholder values with your own.
export aws_account_id=$(aws sts get-caller-identity --query Account --output text)
export AWS_DEFAULT_REGION=<your_aws_region>
# VPC and networking
export vpc_id=<your_vpc_id>
export subnet_ids=<your_subnet_id_1>,<your_subnet_id_2>
export security_group_id=<your_security_group_id>
# Anchore Enterprise connection details
export ANCHORE_URL=<your_anchore_enterprise_url>
export ANCHORE_ACCOUNT=<your_anchore_account>
export ANCHORE_USERNAME=<your_anchore_username>
export ANCHORE_PASSWORD=<your_anchore_password>
Create IAM Roles and Policies
Create the IAM policy, roles, and permissions required by the ECS task.
aws iam create-policy \
--policy-name ECSReadOnly \
--policy-document '{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"ecs:Describe*",
"ecs:List*"
],
"Effect": "Allow",
"Resource": "*"
}
]
}'
aws iam create-role \
--role-name AnchoreECSInventoryTaskRole \
--assume-role-policy-document '{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "ecs-tasks.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}'
aws iam create-role \
--role-name AnchoreECSInventoryExecutionRole \
--assume-role-policy-document '{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "ecs-tasks.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}'
aws iam attach-role-policy \
--role-name AnchoreECSInventoryExecutionRole \
--policy-arn arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy
aws iam attach-role-policy \
--role-name AnchoreECSInventoryTaskRole \
--policy-arn arn:aws:iam::${aws_account_id}:policy/ECSReadOnly
Store the Anchore Enterprise Password in AWS Systems Manager Parameter Store
aws ssm put-parameter \
--name "/ANCHORE_ECS_INVENTORY_ANCHORE_PASSWORD" \
--type "SecureString" \
--value "${ANCHORE_PASSWORD}" \
--overwrite
aws iam put-role-policy \
--role-name AnchoreECSInventoryExecutionRole \
--policy-name ECSInventorySSMAccess \
--policy-document '{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ssm:GetParameters",
"ssm:GetParameter"
],
"Resource": "arn:aws:ssm:'${AWS_DEFAULT_REGION}':'${aws_account_id}':parameter/ANCHORE_ECS_INVENTORY_ANCHORE_PASSWORD"
}
]
}'
Create the CloudWatch Log Group
aws logs create-log-group \
--log-group-name /anchore/ecs-inventory \
--region ${AWS_DEFAULT_REGION}
Register the Task Definition
cat << EOF > task-definition.json
{
"family": "anchore-ecs-inventory",
"cpu": "512",
"memory": "1024",
"networkMode": "awsvpc",
"requiresCompatibilities": ["FARGATE"],
"executionRoleArn": "arn:aws:iam::${aws_account_id}:role/AnchoreECSInventoryExecutionRole",
"taskRoleArn": "arn:aws:iam::${aws_account_id}:role/AnchoreECSInventoryTaskRole",
"containerDefinitions": [
{
"name": "ecs-inventory",
"image": "docker.io/anchore/ecs-inventory:latest",
"cpu": 0,
"essential": true,
"user": "1000",
"readonlyRootFilesystem": true,
"linuxParameters": {
"capabilities": {
"drop": ["ALL"]
}
},
"environment": [
{
"name": "ANCHORE_ECS_INVENTORY_ANCHORE_URL",
"value": "${ANCHORE_URL}"
},
{
"name": "ANCHORE_ECS_INVENTORY_ANCHORE_USER",
"value": "${ANCHORE_USERNAME}"
},
{
"name": "ANCHORE_ECS_INVENTORY_ANCHORE_ACCOUNT",
"value": "${ANCHORE_ACCOUNT}"
},
{
"name": "ANCHORE_ECS_INVENTORY_REGION",
"value": "${AWS_DEFAULT_REGION}"
}
],
"secrets": [
{
"name": "ANCHORE_ECS_INVENTORY_ANCHORE_PASSWORD",
"valueFrom": "arn:aws:ssm:${AWS_DEFAULT_REGION}:${aws_account_id}:parameter/ANCHORE_ECS_INVENTORY_ANCHORE_PASSWORD"
}
],
"healthCheck": {
"command": ["CMD", "/anchore-ecs-inventory", "version"],
"interval": 30,
"timeout": 5,
"retries": 3,
"startPeriod": 10
},
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-create-group": "true",
"awslogs-group": "/anchore/ecs-inventory",
"awslogs-region": "${AWS_DEFAULT_REGION}",
"awslogs-stream-prefix": "ecs"
}
}
}
]
}
EOF
aws ecs register-task-definition \
--cli-input-json file://task-definition.json
Create the ECS Cluster and Service
Create the ECS cluster and deploy the agent as a Fargate service with a desired count of 1.
aws ecs create-cluster \
--cluster-name anchore-ecs-inventory-cluster
aws ecs create-service \
--cluster anchore-ecs-inventory-cluster \
--service-name anchore-ecs-inventory \
--task-definition anchore-ecs-inventory \
--desired-count 1 \
--launch-type FARGATE \
--scheduling-strategy REPLICA \
--network-configuration "awsvpcConfiguration={
subnets=[${subnet_ids}],
securityGroups=[${security_group_id}],
assignPublicIp=ENABLED
}"
Usage
To verify that you are tracking Amazon ECS inventory in your Anchore Enterprise deployment you can access inventory results with the command anchorectl inventory list and look for results where the TYPE is ecs.
Auto analyze new inventory
It is possible to create a subscription to watch for new Amazon ECS inventory that is reported to Anchore Enterprise and automatically schedule those images for analysis. The subscription_key can be set to any part of an Amazon ECS ClusterARN. For example setting the subscription_key to the:
- full ClusterARN
arn:aws:ecs:us-east-1:012345678910:cluster/telemetrywill create a subscription that only watches this cluster - partial ClusterARN
arn:aws:ecs:eu-west-2:988505687240will result in a subscription that watches every cluster within the account988505687240 - All ECS clusters
arn:aws:ecseffectively auto-subscribes all ECS runtime agents.
aws-us-gov instead of aws. For example, use arn:aws-us-gov:ecs to subscribe to all GovCloud ECS clusters, or arn:aws-us-gov:ecs:us-gov-west-1:012345678910:cluster/telemetry for a specific cluster.anchorectl inventory watch activate <SUBSCRIPTION_KEY>
The least-privilege role with permission to add a subscription is image-analyzer.
UI
The UI will visually indicate when images are actively found in ECS Runtime Inventory.

ECS Runtime linkage via UI
General Runtime Management
See Data Management
Last modified April 29, 2026