When we want to execute AWS CLI commands to create tags, add AWS keys on AWS instances with the AWS Chef cookbook, first, we need to install the AWS CLI.
On Linux the following lines complete the installation
bash "install_aws_cli" do code <<-EOF curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" unzip -o awscliv2.zip # Install AWS CLI and create a symbolic link to it at /usr/bin, otherwise the rest of the AWS CLI calls fail. sudo ./aws/install -b /usr/bin --update EOF not_if 'which aws' end
Make sure you use the -b /usr/bin option to instruct the installer to create a symbolic link at /usr/bin
The Amazon recommended -b
/usr/local/bin location only works on Amazon Linux and Ubuntu. On CentOS 7 and Red Hat 7 (RHEL7) we get the error message when the aws cookbook is executed
aws: command not found