Skip to content

Dev - #21

Open
Mraakhil wants to merge 24 commits into
iam-veeramalla:mainfrom
Mraakhil:dev
Open

Dev#21
Mraakhil wants to merge 24 commits into
iam-veeramalla:mainfrom
Mraakhil:dev

Conversation

@Mraakhil

@Mraakhil Mraakhil commented Jul 23, 2026

Copy link
Copy Markdown

dev

Summary by CodeRabbit

  • New Features

    • Added a guided Jenkins pipeline to provision or tear down the EKS environment, with an apply/destroy action, Terraform plan output, and a manual approval step.
  • Changes

    • Updated default AWS region to Asia Pacific (Mumbai) and aligned availability zones.
    • Updated default node group instance type and reduced initial desired capacity to one.
    • Adjusted Terraform S3 backend state handling (locking/encryption settings).
  • Maintenance

    • Automatically cleans the Jenkins workspace after each run.

@Mraakhil Mraakhil closed this Jul 23, 2026
@Mraakhil Mraakhil reopened this Jul 23, 2026
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a parameterized Jenkins pipeline for applying or destroying the EKS Terraform module, updates S3 backend locking, changes Terraform deployment defaults to ap-south-1, and changes the general node group instance type and desired capacity.

Changes

EKS Terraform deployment

Layer / File(s) Summary
Terraform region and node defaults
eks-install/main.tf, eks-install/variables.tf
Enables S3 backend lock files, changes the region and availability zones to ap-south-1, and configures the general node group with c7i-flex.large and a desired size of 1.
Jenkins Terraform workflow
Jenkinsfile
Adds apply/destroy selection, Terraform initialization and planning, manual approval, conditional execution, and workspace cleanup.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Jenkins
  participant Terraform
  participant AWS_S3_Backend
  participant EKS
  Jenkins->>Terraform: terraform init
  Terraform->>AWS_S3_Backend: access Terraform state
  Jenkins->>Terraform: plan apply or destroy
  Jenkins->>Jenkins: request manual approval
  Jenkins->>Terraform: execute approved action
  Terraform->>EKS: provision or destroy EKS resources
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title is too vague to describe the actual changes in the pull request. Use a concise, specific title that names the main change, such as adding Jenkins Terraform pipeline support for EKS.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@eks-install/main.tf`:
- Line 12: The Terraform S3 backend region in the backend configuration must
match the region where the state bucket and lock table are provisioned. Update
the backend region setting near the root Terraform configuration to use the AWS
provider’s default us-west-2, or explicitly migrate the backend resources and
state if retaining ap-south-1.

In `@Jenkinsfile`:
- Line 10: Replace the placeholder value assigned to AWS_CREDENTIALS_ID with the
actual ID of the scoped AWS credential configured in Jenkins, ensuring all
AmazonWebServicesCredentialsBinding usages reference the valid credential.
- Around line 54-55: Update the destroy branch for params.ACTION == 'destroy' to
apply the existing tfplan directly instead of invoking terraform apply with
-destroy -auto-approve. Preserve the previously generated, reviewed destroy plan
by using the saved plan artifact in the shell command.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: c17b8ad4-89b7-4603-9a22-351de96696b5

📥 Commits

Reviewing files that changed from the base of the PR and between c7a045c and b4cec78.

📒 Files selected for processing (3)
  • Jenkinsfile
  • eks-install/main.tf
  • eks-install/variables.tf

Comment thread eks-install/main.tf
Comment thread Jenkinsfile Outdated
Comment thread Jenkinsfile Outdated
Comment on lines +54 to +55
} else if (params.ACTION == 'destroy') {
sh 'terraform apply -destroy -auto-approve'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

sed -n '31,57p' Jenkinsfile

Repository: iam-veeramalla/ultimate-devops-project-aws

Length of output: 1558


🌐 Web query:

Terraform apply -destroy option plan file saved with -destroy applies that plan documentation

💡 Result:

To apply a saved Terraform plan file, you provide the path to the plan file as an argument to the terraform apply command [1][2]. Usage: terraform apply [plan file] Key details of this workflow: - Creation: You first generate the plan file using the -out option with the terraform plan command (e.g., terraform plan -out=tfplan) [3][4]. - Execution: When you pass a saved plan file to terraform apply, Terraform executes the exact operations recorded in that file [1][4]. - No Confirmation Required: Terraform interprets the use of a saved plan file as explicit approval; therefore, it does not prompt for confirmation or require the -auto-approve flag [1][2][4]. - Restriction on Options: When using a saved plan file, you cannot specify additional planning options or modes (such as -var, -replace, -destroy, or -refresh-only) [1][4]. The plan file already contains the finalized set of actions, and these options only apply when Terraform is generating a new plan [1]. - Automation: This two-step workflow (plan then apply) is recommended for automation and CI/CD pipelines to ensure that the infrastructure changes applied are exactly those that were previously reviewed [3][2][5]. It is recommended to use the terraform show command to inspect the contents of a saved plan file before applying it [1][6]. Additionally, be aware that saved plan files may contain sensitive information in cleartext if your configuration or variables include sensitive data [3][5].

Citations:


🌐 Web query:

Terraform documentation apply saved plan file -destroy option cannot specify additional options destroy mode preserved

💡 Result:

When you pass a saved plan file to the terraform apply command, Terraform does not allow you to specify additional planning modes or options [1][2]. The plan file already contains the final results of all planning decisions, including the intended operations, and cannot be modified at the execution stage [1]. Specifically, this means you cannot use options like -destroy, -refresh-only, or -replace when applying a saved plan [1][2]. If you wish to apply a destroy plan, you must specify the -destroy option when creating the plan with terraform plan, save that plan to a file using the -out option, and then pass that saved file to terraform apply [3][2]. In summary, the design of the saved plan workflow is that the plan file encapsulates the entire execution strategy [1]. Any customization of that strategy, including changing the mode of operation (such as destroy mode) or applying resource replacements, must occur during the planning phase, not the application phase [1][4]. Providing additional planning-related flags alongside a saved plan file will cause Terraform to reject the command [1].

Citations:


🌐 Web query:

Terraform apply command plan file without -auto-approve skips confirmation

💡 Result:

When you use a saved plan file with the terraform apply command, Terraform automatically skips the interactive confirmation prompt [1][2][3]. Terraform interprets the act of providing a saved plan file as your approval of the planned operations, so it proceeds to execute the changes immediately [1]. Because this behavior is automatic for saved plans, you do not need—and cannot use—the -auto-approve flag in this context [1]. Terraform will ignore the -auto-approve flag if it is provided alongside a plan file [1]. This workflow is specifically designed for automation, ensuring that the exact changes you reviewed during the plan phase are the ones performed during the apply phase [1][2][3]. To use this workflow: 1. Create a saved plan file: terraform plan -out=tfplan 2. Apply that specific plan file: terraform apply "tfplan" [3]

Citations:


Apply the approved destroy plan instead of generating a new one.

tfplan is already created with terraform plan -destroy -out=tfplan, but the destroy branch runs terraform apply -destroy -auto-approve, which regenerates the plan after approval. The saved plan file already preserves destroy mode, so apply it directly to avoid destroying anything outside the reviewed plan.

Proposed fix
-                            } else if (params.ACTION == 'destroy') {
-                                sh 'terraform apply -destroy -auto-approve'
+                            } else if (params.ACTION == 'destroy') {
+                                sh 'terraform apply tfplan'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
} else if (params.ACTION == 'destroy') {
sh 'terraform apply -destroy -auto-approve'
} else if (params.ACTION == 'destroy') {
sh 'terraform apply tfplan'
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Jenkinsfile` around lines 54 - 55, Update the destroy branch for
params.ACTION == 'destroy' to apply the existing tfplan directly instead of
invoking terraform apply with -destroy -auto-approve. Preserve the previously
generated, reviewed destroy plan by using the saved plan artifact in the shell
command.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@eks-install/main.tf`:
- Around line 12-14: Update the Terraform backend configuration in
eks-install/backend/main.tf to reference the existing terraform_locks DynamoDB
table via dynamodb_table = "terraform-eks-state-locks", restoring state locking
for concurrent runs; alternatively, remove the unused
aws_dynamodb_table.terraform_locks resource only if an explicit migration to
another locking mechanism is completed.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 277dbc93-4e5e-4f6b-8024-856bf73018a4

📥 Commits

Reviewing files that changed from the base of the PR and between d0c419f and e3fb6f8.

📒 Files selected for processing (1)
  • eks-install/main.tf

Comment thread eks-install/main.tf Outdated
Comment on lines 12 to 14
region = "us-west-2"
dynamodb_table = "terraform-eks-state-locks"
encrypt = true
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Restore Terraform state locking or remove the unused lock table.

eks-install/backend/main.tf still provisions aws_dynamodb_table.terraform_locks, but this backend no longer references it. Unless another locking mechanism is configured, concurrent Jenkins runs can update the same state without coordination, risking state corruption. Re-add dynamodb_table = "terraform-eks-state-locks" or complete an explicit migration to the intended locking mechanism.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@eks-install/main.tf` around lines 12 - 14, Update the Terraform backend
configuration in eks-install/backend/main.tf to reference the existing
terraform_locks DynamoDB table via dynamodb_table = "terraform-eks-state-locks",
restoring state locking for concurrent runs; alternatively, remove the unused
aws_dynamodb_table.terraform_locks resource only if an explicit migration to
another locking mechanism is completed.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@eks-install/main.tf`:
- Line 13: Add a compatible Terraform required_version constraint in the module
containing use_lockfile, and pin the Jenkins Terraform CLI to a version
satisfying that constraint before running terraform init. Update or validate the
Jenkins AWS credentials policy to grant s3:GetObject, s3:PutObject, and
s3:DeleteObject for terraform.tfstate.tflock, preserving the existing state
permissions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 44b755bb-785a-431d-9fd4-8eda5ea50dcb

📥 Commits

Reviewing files that changed from the base of the PR and between e3fb6f8 and 014e4ac.

📒 Files selected for processing (1)
  • eks-install/main.tf

Comment thread eks-install/main.tf
region = "us-west-2"
dynamodb_table = "terraform-eks-state-locks"
encrypt = true
use_lockfile = true

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

rg -n 'required_version|terraform init|use_lockfile|s3:(GetObject|PutObject|DeleteObject)' \
  eks-install Jenkinsfile

Repository: iam-veeramalla/ultimate-devops-project-aws

Length of output: 285


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

printf '--- repository files around relevant paths ---\n'
git ls-files | rg '(^|/)Jenkinsfile$|(^|/)eks-install/main\.tf$|terraform|tflock|s3|bucket' || true

printf '\n--- eks-install/main.tf ---\n'
cat -n eks-install/main.tf

printf '\n--- Jenkinsfile relevant lines ---\n'
sed -n '1,120p' Jenkinsfile | cat -n

printf '\n--- Terraform backend occurrences ---\n'
rg -n 'terraform[^;]*(backend|state|lockfile|bucket|key|region|dynamodb|sse|access_key|secret_key|profile)|backend\(' -S .

Repository: iam-veeramalla/ultimate-devops-project-aws

Length of output: 271


🌐 Web query:

Terraform S3 backend use_lockfile flag documentation GetObject PutObject DeleteObject permissions .tflock

💡 Result:

When you enable native S3 state locking in the Terraform S3 backend by setting the use_lockfile argument to true, Terraform utilizes a lock file with a.tflock suffix (e.g., path/to/key.tflock) to manage concurrency [1][2][3]. Because Terraform must create, access, and subsequently delete this lock file to manage the locking lifecycle, you must grant specific IAM permissions for the.tflock object [2][3][4]. Required Permissions If use_lockfile is set to true, the following permissions are required specifically for the lock file resource [1][5][6]: s3:GetObject s3:PutObject s3:DeleteObject These permissions must be applied to the ARN corresponding to the lock file, such as arn:aws:s3:::mybucket/path/to/my/key.tflock [1][6]. Key Distinction It is important to note that the state file itself (the.tfstate file) does not require the s3:DeleteObject permission, as Terraform does not delete the state file during standard operations [2][6][4]. The s3:DeleteObject permission is strictly required for the.tflock file because Terraform actively deletes it to release the lock once an operation completes [2][3][4]. Failure to include s3:DeleteObject for the lock file will result in errors when Terraform attempts to release the lock [2][4][7].

Citations:


Pin and validate the Terraform locking contract.

use_lockfile requires a Terraform CLI that supports the S3 use_lockfile argument, but Jenkinsfile invokes an unpinned terraform init and this module has no Terraform version constraint. Also ensure the Jenkins credentials can access terraform.tfstate.tflock with s3:GetObject, s3:PutObject, and s3:DeleteObject; S3 locking depends on those lockfile operations.

Add a compatible required_version constraint and validate the Jenkins agent/iam policy before relying on this lock.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@eks-install/main.tf` at line 13, Add a compatible Terraform required_version
constraint in the module containing use_lockfile, and pin the Jenkins Terraform
CLI to a version satisfying that constraint before running terraform init.
Update or validate the Jenkins AWS credentials policy to grant s3:GetObject,
s3:PutObject, and s3:DeleteObject for terraform.tfstate.tflock, preserving the
existing state permissions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant