<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Alexandre Rabello Santana</title>
    <description>The latest articles on Forem by Alexandre Rabello Santana (@alexandrerabellosantana).</description>
    <link>https://forem.com/alexandrerabellosantana</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1200608%2F5813930e-950c-4293-bca4-fc870b2618d7.jpeg</url>
      <title>Forem: Alexandre Rabello Santana</title>
      <link>https://forem.com/alexandrerabellosantana</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/alexandrerabellosantana"/>
    <language>en</language>
    <item>
      <title>🚀 Disaster Recovery Solution Using AWS Backups 🌐</title>
      <dc:creator>Alexandre Rabello Santana</dc:creator>
      <pubDate>Thu, 13 Jun 2024 14:36:05 +0000</pubDate>
      <link>https://forem.com/alexandrerabellosantana/disaster-recovery-solution-using-aws-backups-2p28</link>
      <guid>https://forem.com/alexandrerabellosantana/disaster-recovery-solution-using-aws-backups-2p28</guid>
      <description>&lt;p&gt;Recently, I implemented an innovative Disaster Recovery (DR) solution to support our Amazon RDS backups using the powerful tools provided by AWS. Here's a brief overview of the project:&lt;/p&gt;

&lt;p&gt;🔹 Challenge: Ensure that our RDS database backups are securely and efficiently replicated across different AWS accounts and regions. The solution needed to be robust, automated, and capable of supporting our recovery needs in the event of catastrophic failures.&lt;/p&gt;

&lt;p&gt;🔹 Solution: I developed an AWS Lambda function to automate the copying of recovery points from AWS Backup across regions and accounts. This function runs daily, ensuring that all recovery points created on the current day are replicated from the source vault to the destination vault in the region where our DR resources are located.&lt;/p&gt;

&lt;p&gt;🔹 Technologies Used:&lt;/p&gt;

&lt;p&gt;AWS Backup: To create and manage the recovery points.&lt;br&gt;
Amazon RDS: The primary data source we are protecting.&lt;br&gt;
AWS Lambda: To automate the recovery points copy process.&lt;br&gt;
IAM Roles: To manage permissions and security between accounts and regions.&lt;br&gt;
🔹 Benefits:&lt;/p&gt;

&lt;p&gt;Resilience: Ensuring that data is securely stored in multiple regions, ready to be recovered in case of disaster.&lt;br&gt;
Automation: Fully automated backup and recovery processes, reducing manual workload and the risk of human error.&lt;br&gt;
Efficiency: Fast and secure data replication, minimizing recovery time.&lt;br&gt;
This DR solution is a significant step towards protecting our critical data and maintaining business continuity. I am excited to continue exploring and implementing innovative solutions that enhance the resilience and security of our systems!&lt;/p&gt;

&lt;p&gt;If you're interested in discussing more about backup strategies and disaster recovery, feel free to reach out!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GITHUB :&lt;/strong&gt; &lt;code&gt;https://github.com/alerabello/AWS-Backup-Copy&lt;/code&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  AWS #Backup #DisasterRecovery #RDS #CloudComputing #Automation #AWSLambda #CrossRegion #CloudSecurity
&lt;/h1&gt;

</description>
      <category>aws</category>
      <category>cloud</category>
    </item>
    <item>
      <title>Github Actions — Terraform — CI/CD Multiple Accounts AWS</title>
      <dc:creator>Alexandre Rabello Santana</dc:creator>
      <pubDate>Sun, 09 Jun 2024 01:02:48 +0000</pubDate>
      <link>https://forem.com/alexandrerabellosantana/github-actions-terraform-cicd-multiple-accounts-aws-1ek4</link>
      <guid>https://forem.com/alexandrerabellosantana/github-actions-terraform-cicd-multiple-accounts-aws-1ek4</guid>
      <description>&lt;h1&gt;
  
  
  Terraform - Multiple AWS Accounts
&lt;/h1&gt;

&lt;p&gt;This repository contains a GitHub Actions workflow for managing Terraform deployments across multiple AWS accounts. The workflow allows for planning, manual approval, and applying or destroying Terraform configurations.&lt;/p&gt;

&lt;h2&gt;
  
  
  Workflow: Terraform Plan, Approval, and Deploy
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Workflow Dispatch Inputs
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;action&lt;/strong&gt;: Specifies the action to perform (&lt;code&gt;apply&lt;/code&gt; or &lt;code&gt;destroy&lt;/code&gt;). Default is &lt;code&gt;apply&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;aws_account&lt;/strong&gt;: Specifies the AWS account to deploy to (&lt;code&gt;shared&lt;/code&gt;, &lt;code&gt;network&lt;/code&gt;, &lt;code&gt;production&lt;/code&gt;, &lt;code&gt;stage&lt;/code&gt;, &lt;code&gt;develop&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;terraform_version&lt;/strong&gt;: Specifies the version of Terraform to use. Default is &lt;code&gt;1.8.0&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Workflow Jobs
&lt;/h3&gt;

&lt;h4&gt;
  
  
  1. Plan
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Runs on&lt;/strong&gt;: &lt;code&gt;ubuntu-latest&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Permissions&lt;/strong&gt;: 

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;actions: read&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;issues: write&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;id-token: write&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;contents: write&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Timeout&lt;/strong&gt;: 5 minutes&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Steps&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;Checkout the code.&lt;/li&gt;
&lt;li&gt;Configure AWS credentials based on the selected AWS account.&lt;/li&gt;
&lt;li&gt;Install and run &lt;code&gt;tflint&lt;/code&gt; for linting Terraform files.&lt;/li&gt;
&lt;li&gt;Setup Terraform with the specified version.&lt;/li&gt;
&lt;li&gt;Initialize Terraform.&lt;/li&gt;
&lt;li&gt;Plan Terraform changes and save the plan.&lt;/li&gt;
&lt;li&gt;Cache Terraform files.&lt;/li&gt;
&lt;li&gt;Upload the Terraform plan as an artifact.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h4&gt;
  
  
  2. Approval
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Needs&lt;/strong&gt;: &lt;code&gt;plan&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Runs on&lt;/strong&gt;: &lt;code&gt;ubuntu-latest&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Permissions&lt;/strong&gt;: 

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;actions: read&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;issues: write&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;id-token: write&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;contents: write&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Steps&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;Request manual approval from the specified approvers.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h4&gt;
  
  
  3. Deploy
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Needs&lt;/strong&gt;: &lt;code&gt;approval&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Runs on&lt;/strong&gt;: &lt;code&gt;ubuntu-latest&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Permissions&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;id-token: write&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;contents: write&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Timeout&lt;/strong&gt;: 20 minutes&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Steps&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;Checkout the code.&lt;/li&gt;
&lt;li&gt;Configure AWS credentials based on the selected AWS account.&lt;/li&gt;
&lt;li&gt;Setup Terraform with the specified version.&lt;/li&gt;
&lt;li&gt;Download the Terraform plan artifact.&lt;/li&gt;
&lt;li&gt;Move the Terraform plan.&lt;/li&gt;
&lt;li&gt;Initialize Terraform.&lt;/li&gt;
&lt;li&gt;Apply or destroy the Terraform plan based on the specified action.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  Usage
&lt;/h2&gt;

&lt;p&gt;To trigger the workflow, go to the Actions tab in your GitHub repository, select the &lt;code&gt;Terraform - Multiple AWS Accounts&lt;/code&gt; workflow, and click on &lt;code&gt;Run workflow&lt;/code&gt;. Fill in the required inputs and run the workflow.&lt;/p&gt;

&lt;h2&gt;
  
  
  Secrets
&lt;/h2&gt;

&lt;p&gt;The following secrets need to be configured in your GitHub repository:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;AWS_ACCESS_KEY_ID&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;AWS_SECRET_ACCESS_KEY&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;AWS_ROLE_ARN_NETWORK&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;AWS_ROLE_ARN_PROD&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;AWS_ROLE_ARN_DEVELOP&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;AWS_ROLE_ARN_STAGE&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;GITHUB_TOKEN&lt;/code&gt; (automatically provided by GitHub)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Notes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Ensure the roles specified in the AWS credentials have the necessary permissions to perform the Terraform actions.&lt;/li&gt;
&lt;li&gt;Modify the role ARNs and other configurations as per your AWS setup.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For more information on GitHub Actions and Terraform, refer to the &lt;a href="https://docs.github.com/en/actions" rel="noopener noreferrer"&gt;GitHub Actions documentation&lt;/a&gt; and &lt;a href="https://www.terraform.io/docs" rel="noopener noreferrer"&gt;Terraform documentation&lt;/a&gt;.&lt;/p&gt;




&lt;p&gt;Code :  &lt;code&gt;deploy-to-terraform.yml&lt;/code&gt;&lt;/p&gt;






&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;name: Terraform - Multiple AWS Accounts

on:
  workflow_dispatch:
    inputs:
      action:
        description: 'Action to perform (apply or destroy)'
        required: true
        default: 'apply'
      aws_account:
        description: 'AWS Account to deploy to (shared, network, production, stage, develop)'
        required: true
      terraform_version:
        description: 'Version of Terraform to use'
        required: true
        default: '1.8.0'

jobs:
  plan:
    runs-on: ubuntu-latest
    permissions:
      actions: read
      issues: write
      id-token: write # This is required for requesting the JWT
      contents: write  # This is required for actions/checkout
    timeout-minutes: 5
    steps:
      - name: Checkout Code
        uses: actions/checkout@v2

      - name: Configure AWS Credentials
        if: ${{ github.event.inputs.aws_account == 'network' }}
        uses: aws-actions/configure-aws-credentials@v4
        with:
          role-to-assume: ${{ secrets.AWS_ROLE_ARN_NETWORK }}
          aws-region: us-east-1

      - name: Configure AWS Credentials
        if: ${{ github.event.inputs.aws_account == 'prod' }}
        uses: aws-actions/configure-aws-credentials@v4
        with:
          role-to-assume: ${{ secrets.AWS_ROLE_ARN_PROD }}
          aws-region: us-east-1

      - name: Configure AWS Credentials
        if: ${{ github.event.inputs.aws_account == 'stage' }}
        uses: aws-actions/configure-aws-credentials@v4
        with:
          role-to-assume: ${{ secrets.AWS_ROLE_ARN_STAGE }}
          aws-region: us-east-1

      - name: Configure AWS Credentials
        if: ${{ github.event.inputs.aws_account == 'develop' }}
        uses: aws-actions/configure-aws-credentials@v4
        with:
          role-to-assume: ${{ secrets.AWS_ROLE_ARN_DEVELOP }}
          aws-region: us-east-1

      - name: Install TFLint
        run: |
          curl -L https://github.com/terraform-linters/tflint/releases/latest/download/tflint_linux_amd64.zip -o tflint.zip
          unzip tflint.zip
          sudo mv tflint /usr/local/bin/
          rm tflint.zip

      - name: Lint Terraform files
        run: tflint

      - name: Setup Terraform
        uses: hashicorp/setup-terraform@v3
        with:
          terraform_version: ${{ github.event.inputs.terraform_version }}
        env:
          AWS_DEFAULT_REGION: us-east-1

      - name: Initialize Terraform
        run: terraform init -reconfigure

      - name: Plan Terraform changes
        run: terraform plan -out=tfplan

      - name: Cache Terraform files
        uses: actions/cache@v2
        with:
          path: |
            .terraform
            .terraform.lock.hcl
          key: ${{ runner.os }}-terraform-${{ hashFiles('**/*.tf') }}

      - name: Upload Terraform plan
        uses: actions/upload-artifact@v2
        with:
            name: tfplan
            path: tfplan

  approval:
    needs: plan
    runs-on: ubuntu-latest
    permissions:
      actions: read
      issues: write
      id-token: write # This is required for requesting the JWT
      contents: write  # This is required for actions/checkout
    steps:
      - name: Request Manual Approval
        uses: trstringer/manual-approval@v1
        with:
          secret: ${{ secrets.GITHUB_TOKEN }}
          approvers: alerabello
          minimum-approvals: 1
          additional-approved-words: 'Approve, Approved, approve, approved'
        timeout-minutes: 10

  deploy:
    needs: approval
    runs-on: ubuntu-latest
    permissions:
      id-token: write # This is required for requesting the JWT
      contents: write  # This is required for actions/checkout
    timeout-minutes: 20
    steps:
      - name: Checkout Code
        uses: actions/checkout@v2

      - name: Configure AWS Credentials
        if: ${{ github.event.inputs.aws_account == 'network' }}
        uses: aws-actions/configure-aws-credentials@v4
        with:
          role-to-assume: ${{ secrets.AWS_ROLE_ARN_NETWORK }}
          aws-region: us-east-1

      - name: Configure AWS Credentials
        if: ${{ github.event.inputs.aws_account == 'prod' }}
        uses: aws-actions/configure-aws-credentials@v4
        with:
          role-to-assume: ${{ secrets.AWS_ROLE_ARN_PROD }}
          aws-region: us-east-1

      - name: Configure AWS Credentials
        if: ${{ github.event.inputs.aws_account == 'stage' }}
        uses: aws-actions/configure-aws-credentials@v4
        with:
          role-to-assume: ${{ secrets.AWS_ROLE_ARN_STAGE }}
          aws-region: us-east-1

      - name: Configure AWS Credentials
        if: ${{ github.event.inputs.aws_account == 'develop' }}
        uses: aws-actions/configure-aws-credentials@v4
        with:
          role-to-assume: ${{ secrets.AWS_ROLE_ARN_DEVELOP }}
          aws-region: us-east-1

      - name: Setup Terraform
        uses: hashicorp/setup-terraform@v3
        with:
          terraform_version: ${{ github.event.inputs.terraform_version }}

      - name: Download repository artifact
        uses: actions/download-artifact@v2
        with:
          name: tfplan
          path: ./tfplan

      - name: Move Terraform plan
        run: mv ./tfplan/tfplan ./tfplan.tfplan

      - name: Initialize Terraform
        run: terraform init -reconfigure

      - name: Apply or Destroy Terraform
        run: |
          if [ "${{ github.event.inputs.action }}" == "apply" ]; then
            terraform apply -auto-approve ./tfplan.tfplan
          elif [ "${{ github.event.inputs.action }}" == "destroy" ]; then
            terraform destroy -auto-approve
          else
            echo "Invalid action specified: ${{ github.event.inputs.action }}"
            exit 1
          fi
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>devops</category>
      <category>aws</category>
      <category>githubactions</category>
    </item>
  </channel>
</rss>
