Skip to main content

aws_ecs_service Resource

Use the aws_ecs_service InSpec audit resource to test properties of a single AWS ECS Service.

The AWS ECS Service resource creates an Amazon Elastic Container Service (Amazon ECS) service that runs and maintains the requested number of tasks and associated load balancers.

For additional information, including details on parameters and properties, see the AWS documentation on ECS Service.

Installation

This resource is available in the Chef InSpec AWS resource pack.

See the Chef InSpec documentation on cloud platforms for information on configuring your AWS environment for InSpec and creating an InSpec profile that uses the InSpec AWS resource pack.

Syntax

Ensure that a services exists.

describe aws_ecs_service(cluster: "default", service: "SERVICE_ARN") do
  it { should exist }
end

Parameters

cluster

The short name or full Amazon Resource Name (ARN) of the cluster on which your service is running.

service (required)

The ECS service ARN or service name.

Properties

service_arn
The ARN of the service.
service_name
The name of the service.
cluster_arn
The Amazon Resource Name (ARN) of the cluster that hosts the service.
status
The status of the service. The valid values are ACTIVE, DRAINING, or INACTIVE.
desired_count
The desired number of instantiations of the task definition to keep running on the service.
running_count
The number of tasks in the cluster that are in the RUNNING state.
pending_count
The number of tasks in the cluster that are in the PENDING state.
launch_type
The infrastructure on which your service is running.
task_definition
The task definition to use for tasks in the service.
platform_version
The AWS Fargate platform version on which the tasks in the task set are running.

For additional information, see the AWS documentation on ECS describe services method.

Examples

Ensure a work group name is available.

describe aws_ecs_service(cluster: "default", service: "SERVICE_ARN") do
  its('service_name') { should eq 'service_name' }
end

Ensure that the status is ACTIVE or not.

describe aws_ecs_service(cluster: "default", service: "SERVICE_ARN") do
    its('status') { should eq 'ACTIVE' }
end

Matchers

This InSpec audit resource has the following special matchers. For a full list of available matchers, please visit our Universal Matchers page.

The controls will pass if the describe method returns at least one result.

exist

Use should to test that the entity exists.

describe aws_ecs_service(cluster: "CLUSTER_NAME", service: "SERVICE_ARN") do
  it { should exist }
end

Use should_not to test the entity does not exist.

describe aws_ecs_service(cluster: "CLUSTER_NAME", service: "SERVICE_NAME") do
  it { should_not exist }
end

be_available

Use should to check if the services is available.

describe aws_ecs_service(cluster: "default", service: "SERVICE_ARN") do
  it { should be_available }
end

AWS Permissions

Your Principal will need the ECS:Client:DeleteServiceResponse action with Effect set to Allow.

Edit this page on GitHub.

Thank you for your feedback!

×









Search Results