AWS ECS Exec
Execute commands inside a running container (Tasks) in a ECS Cluster,
this type is useful when there’s a necessity to change the state of a
running system. It’s possible to pass any kind of command to a container
through Runops.
Type:
ecs-exec
In order for this to work the ECS need to be configured properly with
the steps:
- Use this tool to validate if the setup is working properly
2. Grant permissions to execute command
Run the script bellow to create an AWS user for Runops.
It has the permissions to access ECS clusters with the tag:
access=runops
.plain textexport AWS_REGION=us-east-2 mkdir runops; cd runops curl -s https://www.runops.io/docs/quickstarts/ecs-exec.tf -o main.tf terraform init; terraform apply
After execution get the terraform output for the next step:
plain textterraform output id terraform output secret
Then add a tag with key=
access
, and
value=runops
to any cluster you want to connect to
Runops.3. Create a connection with the configurations
Name | Required | Description |
ECS_CLUSTER | yes | The name of the ECS Cluster. |
ECS_SERVICE_NAME | yes | The name of the ECS service. |
ECS_CONTAINER | yes | The name of the running container of the ECS Task. |
ECS_AWS_ACCESS_KEY_ID | yes | ECS AWS Access Key ID. |
ECS_AWS_SECRET_ACCESS_KEY | yes | ECS AWS Secret Access Key. |
ECS_AWS_REGION | yes | ECS AWS Region. |
The ECS task id is obtained dynamically listing it by its service
name
Examples
Run
env
command to dump the environment variables of a
container instance.shellrunops tasks create --target my-ecs-service --script 'env'
Limitations
- Executing an invalid ECS task will not result in an Runops Task error.