execute_command
async
¶
execute_command(
command: String,
interactive: Boolean,
task: String,
*,
config_overrides: Optional[AsyncECSClientConfig] = None,
cluster: Optional[String] = None,
container: Optional[String] = None,
) -> ExecuteCommandResponse
Runs a command remotely on a container within a task.
If you use a condition key in your IAM policy to refine the conditions for the policy statement, for example limit the actions to a specific cluster, you receive an AccessDeniedException when there is a mismatch between the condition key value and the corresponding parameter value.
For information about required permissions and considerations, see Using Amazon ECS Exec for debugging in the Amazon ECS Developer Guide.
Parameters:
-
cluster(Optional[String], default:None) –The Amazon Resource Name (ARN) or short name of the cluster the task is running in. If you do not specify a cluster, the default cluster is assumed.
-
container(Optional[String], default:None) –The name of the container to execute the command on. A container name only needs to be specified for tasks containing multiple containers.
-
command(String) –The command to run on the container.
-
interactive(Boolean) –Use this flag to run your command in interactive mode.
-
task(String) –The Amazon Resource Name (ARN) or ID of the task the container is part of.
Raises:
-
AccessDeniedException–You don't have authorization to perform the requested action.
-
ClientException–These errors are usually caused by a client action. This client action might be using an action or resource on behalf of a user that doesn't have permissions to use the action or resource. Or, it might be specifying an identifier that isn't valid.
-
ClusterNotFoundException–The specified cluster wasn't found. You can view your available clusters with ListClusters. Amazon ECS clusters are Region specific.
-
InvalidParameterException–The specified parameter isn't valid. Review the available parameters for the API request.
For more information about service event errors, see Amazon ECS service event messages.
-
ServerException–These errors are usually caused by a server issue.
-
TargetNotConnectedException–The execute command cannot run. This error can be caused by any of the following configuration issues:
-
Incorrect IAM permissions
-
The SSM agent is not installed or is not running
-
There is an interface Amazon VPC endpoint for Amazon ECS, but there is not one for Systems Manager Session Manager
For information about how to troubleshoot the issues, see Troubleshooting issues with ECS Exec in the Amazon Elastic Container Service Developer Guide.
-
-
UnknownServiceError–The service returned an error code this client does not model.
Examples:
To run a command remotely on a container in a task This example runs an interactive /bin/sh command on a container MyContainer.
>>> await client.execute_command(cluster='MyCluster', container='MyContainer', command='/bin/sh', interactive=True, task='arn:aws:ecs:us-east-1:123456789012:task/MyCluster/d789e94343414c25b9f6bd59eEXAMPLE')
Source code in docs_src/capo_ecs/_services/async_ecs.py
2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 | |