How to run an AWS CLI command with local-exec in Terraform cloud?

Is there any way to configure and run a raw AWS CLI command in Terraform Cloud?

I need something not supported by the AWS provider, but normally easily done via the local-exec provisioner with a null resource. However, with Terraform Cloud, the only mechanism I can think of is using the generic way to install additional software then using another local-exec to configure the AWS credentials and defaults.

Since AWS is such a commonly used platform with Terraform, I’m wondering if there’s an easier way to do it? Can the terraform cloud environment come preconfigured with AWS CLI?

Hello @cvrabie!

Right now, we do not have AWS CLI or cloud provider CLIs in the Terraform Cloud runners because we cannot guarantee support for different versions for each type of CLI. For future iterations, we’ve been investigating other implementations to make it easier but installation is the only method available now.

What is the functionality you are looking for? It might be that we could look into supporting directly in the AWS provider.


Thanks for the answer Rosemary. Looking forward to any updates you’ll make in this area.

Both use cases I require are already open tickets. A method to wait until an ECS service has truly been deployed and a way to create a CloudFront invalidation. However based on the discussion on the forum it doesn’t seem to be a lot of appetite for implementing this.

I guess this will always be the case with certain features. This is why a way to send a “raw” aws command could be quite useful.


I know this is well after you asked, but I was wondering what the tickets were that you mentioned, for this issue. I’d like to follow them too.


Hi Matthew. I apologise, but I’ve been looking for the links to the original tickets but can’t seem to find them

All good! Thanks for taking the time to look!

Hi, I’m looking for ways to run one-off tasks on AWS ECS. So far as they are unsupported on Terraform, the community recommends running them locally with a provisioner. But with the AWS CLI unavailable in Terraform Cloud, I am out of options here.

Hope this helps. Suggestions welcomed.

My use case is executing some setup SQL via “aws rds-data execute-statement” to initialize an RDS database. There are several reasons ‘aws cli’ would be useful in the runners:

(1) initializing a database for post-deployment verification.
(2) performing ECS one-offs for post-deployment verification.
(3) executing other arbitrary AWS CLI calls against the infrastructure to verify things before saying all is good with the changes made.