AWS Classroom Series – 28/Jul/2021

Executing CloudFormation from Jenkins

  • Lets install aws cli and configure aws cli in a jenkins node
  • RHEL
sudo dnf install uzip -y
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
  • UBUNTU
sudo apt update
sudo apt install unzip -y
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
  • Create an IAM User and configure in AWS CLI
  • Now Create Jenkins job with Parameters
  • In the Source Code configuration
  • Add Build Parameters in General
  • In the Build step write the following
cd Cloudformation/July21/ntier-singleregion/
aws cloudformation create-stack --stack-name ${STACK_NAME} --template-body file://ntier.json --parameters ParameterKey=web1az,ParameterValue=${WEB1_AZ} ParameterKey=web2az,ParameterValue=${WEB2_AZ} ParameterKey=app1az,ParameterValue=${APP1_AZ} ParameterKey=app2az,ParameterValue=${APP2_AZ} ParameterKey=db1az,ParameterValue=${DB1_AZ} ParameterKey=db2az,ParameterValue=${DB2_AZ} ParameterKey=webkeypair,ParameterValue=${KEY_PAIR} ParameterKey=appkeypair,ParameterValue=${KEY_PAIR} ParameterKey=vpccidr,ParameterValue=${VPC_CIDR}
#status='InProgress'
#while [ "$status" != "CREATE_COMPLETE"]
#do
#status=$(aws cloudformation describe-stacks --stack-name 'ntier' --query "Stacks[0].StackStatus")
#sleep 5s
#done

Leave a ReplyCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Animated Social Media Icons by Acurax Responsive Web Designing Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Exit mobile version
%%footer%%