<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[DevOps Journey]]></title><description><![CDATA[DevOps Journey]]></description><link>https://rajandubey.hashnode.dev</link><image><url>https://cdn.hashnode.com/res/hashnode/image/upload/v1744955131687/7e10045e-ac1a-4317-9a73-72ffe0ff2388.png</url><title>DevOps Journey</title><link>https://rajandubey.hashnode.dev</link></image><generator>RSS for Node</generator><lastBuildDate>Mon, 07 Sep 2026 16:06:34 GMT</lastBuildDate><atom:link href="https://rajandubey.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[How to Deploy AWS CloudFormation with Jenkins Pipeline]]></title><description><![CDATA[Description
This tutorial provides a step-by-step guide on setting up a Jenkins pipeline to deploy AWS infrastructure using CloudFormation.
Prerequisites

AWS Free Tier Account

IAM User with CloudFormation and EC2 Permissions

AWS CLI installed and ...]]></description><link>https://rajandubey.hashnode.dev/how-to-deploy-aws-cloudformation-with-jenkins-pipeline</link><guid isPermaLink="true">https://rajandubey.hashnode.dev/how-to-deploy-aws-cloudformation-with-jenkins-pipeline</guid><category><![CDATA[Devops]]></category><category><![CDATA[AWS]]></category><category><![CDATA[cloudformation]]></category><category><![CDATA[automation]]></category><category><![CDATA[Infrastructure as code]]></category><category><![CDATA[IaC (Infrastructure as Code)]]></category><category><![CDATA[Jenkins]]></category><category><![CDATA[GitHub]]></category><category><![CDATA[AWSDevops]]></category><dc:creator><![CDATA[Rajan Dubey]]></dc:creator><pubDate>Fri, 18 Apr 2025 05:28:32 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1744953301387/8f1c47d4-e389-44da-84b5-7e938cd90fb3.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="heading-description"><strong>Description</strong></h3>
<p>This tutorial provides a step-by-step guide on setting up a Jenkins pipeline to deploy AWS infrastructure using CloudFormation.</p>
<h3 id="heading-prerequisites"><strong>Prerequisites</strong></h3>
<ol>
<li><p>AWS Free Tier Account</p>
</li>
<li><p>IAM User with CloudFormation and EC2 Permissions</p>
</li>
<li><p>AWS CLI installed and configured on the Jenkins Server</p>
</li>
<li><p>GitHub repository containing a CloudFormation template</p>
</li>
</ol>
<h3 id="heading-step-1-create-an-iam-user-in-aws"><strong>Step 1: Create an IAM User in AWS</strong></h3>
<ol>
<li><p>Go to <a target="_blank" href="https://signin.aws.amazon.com/signin?client_id=arn%3Aaws%3Asignin%3A%3A%3Aconsole%2Fcanvas&amp;redirect_uri=https%3A%2F%2Fconsole.aws.amazon.com%2Fconsole%2Fhome%3FhashArgs%3D%2523%26isauthcode%3Dtrue%26nc2%3Dh_ct%26oauthStart%3D1738169179194%26src%3Dheader-signin%26state%3DhashArgsFromTB_eu-north-1_34260c98701aa888&amp;page=resolve&amp;code_challenge=L6fCoGIY2Yz8m6IgXyd_wZMemOFQ86NQt6t6G-zRZko&amp;code_challenge_method=SHA-256&amp;backwards_compatible=true">AWS IAM Console</a> → IAM Users</p>
</li>
<li><p>Click Users → Create User</p>
</li>
<li><p>Enter User Name: jenkins-user</p>
</li>
<li><p>Click Next: Permissions -&gt; Attach policies directly</p>
</li>
<li><p>Attach these policies:</p>
<ol>
<li><p><code>AWSCloudFormationFullAccess</code></p>
</li>
<li><p><code>AmazonEC2FullAccess</code></p>
</li>
<li><p><code>IAMFullAccess</code></p>
</li>
</ol>
</li>
<li><p>Click <strong>Next: Tags</strong> → <strong>Next: Review</strong> → <strong>Create User</strong></p>
</li>
<li><p>Create <strong>Access Key ID</strong> and <strong>Secret Access Key</strong> under Security Credentials -&gt; <strong>Access keys (</strong>save them securely)</p>
</li>
</ol>
<h3 id="heading-step-2-configure-aws-cli-on-jenkins-server"><strong>Step 2: Configure AWS CLI on Jenkins Server</strong></h3>
<ol>
<li><p>Open Command Prompt (cmd) on Jenkins Server and run below.</p>
<p> <code>aws configure</code></p>
</li>
<li><p>Enter credentials:</p>
<p> <code>Access Key ID: (Paste from AWS)</code></p>
<p> <code>Secret Access Key: (Paste from AWS)</code></p>
<p> <code>Default region: eu-west-2</code></p>
<p> <code>Output format: json</code></p>
</li>
<li><p>To Verify credentials run.</p>
<p> <code>aws sts get-caller-identity</code></p>
</li>
<li><p>This should return your IAM user details.</p>
</li>
</ol>
<h3 id="heading-step-3-store-aws-credentials-in-jenkins"><strong>Step 3: Store AWS Credentials in Jenkins</strong></h3>
<ol>
<li><p>Go to Jenkins Dashboard → Manage Jenkins → Manage Credentials</p>
</li>
<li><p>Click <strong>Global Credentials</strong> → <strong>Add Credentials</strong></p>
</li>
<li><p>Select <strong>AWS Credentials</strong></p>
</li>
<li><p>Enter below</p>
<p> <code>Access Key ID</code></p>
<p> <code>Secret Access Key</code></p>
</li>
<li><p>Save with <strong>ID</strong>: aws-credentials</p>
</li>
</ol>
<h3 id="heading-step-4-set-up-a-github-repository"><strong>Step 4: Set Up a GitHub Repository</strong></h3>
<ol>
<li><p>Create a <a target="_blank" href="https://github.com/">GitHub</a> Repository</p>
</li>
<li><p>Upload your CloudFormation template (e.g., stack-template.json)</p>
</li>
</ol>
<h3 id="heading-step-5-create-a-jenkins-pipeline-job"><strong>Step 5: Create a Jenkins Pipeline Job</strong></h3>
<ol>
<li><p>Go to Jenkins <strong>Dashboard</strong> → <strong>New Item</strong></p>
</li>
<li><p>Enter Job Name → Select <strong>Pipeline</strong> → Click OK</p>
</li>
<li><p>Scroll down to Pipeline Section → Select <strong>Pipeline Script</strong></p>
</li>
</ol>
<h3 id="heading-step-6-add-the-pipeline-script"><strong>Step 6: Add the Pipeline Script</strong></h3>
<ol>
<li>Paste this pipeline script into Jenkins:</li>
</ol>
<pre><code class="lang-json">pipeline {
    agent any
    environment {
      AWS_REGION = 'eu-west-2'
      STACK_NAME = 'jenkins-cloudformation-stack'
    }
    stages {
      stage('Checkout') {
        steps {
          git(
            url: <span class="hljs-string">"https://github.com/rajandubey/DevOps_With_AWS.git"</span>,
            branch: <span class="hljs-string">"main"</span>,
          )
        }
      }
      stage('Deploy CloudFormation Stack') {
        steps {
          withCredentials([aws(credentialsId: 'AWS_Jenkins_User')]) {
            script {
              bat ''
              '
              aws cloudformation deploy--stack - name % STACK_NAME % --template - file AWS_EC2_Creation.json--capabilities CAPABILITY_IAM--region % AWS_REGION %
                ''
              '
            }
          }
        }
      }
    }
  }
</code></pre>
<h3 id="heading-step-7-run-the-jenkins-job"><strong>Step 7: Run the Jenkins Job</strong></h3>
<ol>
<li><p>Click Save</p>
</li>
<li><p>Click Build Now</p>
</li>
<li><p>Monitor the logs to check for errors</p>
</li>
</ol>
<h3 id="heading-step-8-verify-the-stack-in-aws"><strong>Step 8: Verify the Stack in AWS</strong></h3>
<ol>
<li><p>Go to AWS Console → CloudFormation</p>
</li>
<li><p>Check if the stack jenkins-cloudformation-stack is created successfully</p>
</li>
<li><p>Verify resources (EC2, S3, IAM, etc.)</p>
</li>
</ol>
]]></content:encoded></item></channel></rss>