To install a AWS CLI in a Jenkins running on a docker container, you can follow the below steps. But it would be better if you create a custom Jenkins docker file with AWS CLI and then create a custom image to spin up the Jenkins container. But sometimes, you may need to install various packages.
Install AWS CLI in Jenkins Docker Container
- Take a note of the running Jenkins containers and then run to login as a root
docker exec -u 0 -it 85f0af1f40e4 bash
- Next, update the packages list:
apt-get update
- Download AWS CLI zip file from AWS.
curl “https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip” -o “awscliv2.zip”
Reference: updating the lastest version of AWS CLI
4 Unzip the package
unzip awscliv2.zip
- Install the AWS CLI by running the script
./aws/install
6. Check if the AWS CLI has been installed properly.
aws –version
Install Terraform in Jenkins Docker Container
apt-get install -y lsb-release
apt install -y curl
lsb_release -a
apt-get install -y software-properties-common
curl -fsSL https://apt.releases.hashicorp.com/gpg | apt-key add –
apt-add-repository “deb [arch=$(dpkg –print-architecture)] https://apt.releases.hashicorp.com $(lsb_release -cs) main”
apt update
apt install terraform
Test that Terraform has been installed correctly:
terraform -version