If you wonder about the need to restart the EC2 instance, there is no need. After that, I set the flag value InstallAWSFlag.txt to true.
#Configure aws cli for windows install#
I first downloaded the installer and then used the PowerShell Start-Process block with the -Wait flag to install the CLI. Step 2: If AWS CLI is not installed, install the latest version and restart the EC2 instance.
![configure aws cli for windows configure aws cli for windows](https://i.ytimg.com/vi/n3KacV0UlSM/mqdefault.jpg)
If the desired end state (AWS CLI installed) is achieved, do not download the installer or proceed with the installation. The idea behind this step is due to the need to create idempotent scripts. To install AWS CLI and to make the process idempotent, I classified it into the following steps: If you are new to the AWS EC2 user data script, I have a separate note to discuss the steps to start using the user data script -working with AWS EC2 user data and Terraform. Hence, all the functions within the user data script must be idempotent, including the AWS CLI installation. Moreover, I prefer to have the user data script be persistent (starts each time after a machine restart). I used EC2 user data and Terraform to automate AWS CLI installation as part of the EC2 provisioning process. This post lists the steps to install the AWS CLI on an AWS Windows EC2 instance.
![configure aws cli for windows configure aws cli for windows](https://www.kodyaz.com/images/aws/edit-environment-variable-path-for-aws-cli.png)
In the last post, I discussed the steps involved in installing AWS.Tools module for PowerShell on AWS EC2 using user data and Terraform.