-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
feat: enhance project with CI/CD pipeline, automated formatting, and improved outputs #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| name: "Terraform CI" | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| paths: | ||
| - "DevOps-Project-11/**" | ||
| pull_request: | ||
| branches: [main] | ||
| paths: | ||
| - "DevOps-Project-11/**" | ||
|
|
||
| env: | ||
| TF_VERSION: "1.7.0" | ||
| WORKING_DIR: "DevOps-Project-11" | ||
|
|
||
| jobs: | ||
| format: | ||
| name: Terraform Format Check | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Terraform | ||
| uses: hashicorp/setup-terraform@v3 | ||
| with: | ||
| terraform_version: ${{ env.TF_VERSION }} | ||
|
|
||
| - name: Terraform Format Check | ||
| working-directory: ${{ env.WORKING_DIR }} | ||
| run: terraform fmt -check -recursive -diff | ||
|
|
||
| validate: | ||
| name: Terraform Validate | ||
| runs-on: ubuntu-latest | ||
| needs: format | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Terraform | ||
| uses: hashicorp/setup-terraform@v3 | ||
| with: | ||
| terraform_version: ${{ env.TF_VERSION }} | ||
|
|
||
| - name: Terraform Init | ||
| working-directory: ${{ env.WORKING_DIR }} | ||
| run: terraform init -backend=false | ||
|
|
||
| - name: Terraform Validate | ||
| working-directory: ${{ env.WORKING_DIR }} | ||
| run: terraform validate | ||
|
|
||
| plan: | ||
| name: Terraform Plan | ||
| runs-on: ubuntu-latest | ||
| needs: validate | ||
| if: github.event_name == 'pull_request' | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Terraform | ||
| uses: hashicorp/setup-terraform@v3 | ||
| with: | ||
| terraform_version: ${{ env.TF_VERSION }} | ||
|
|
||
| - name: Configure AWS Credentials | ||
| uses: aws-actions/configure-aws-credentials@v4 | ||
| with: | ||
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
| aws-region: us-east-1 | ||
|
|
||
| - name: Terraform Init | ||
| working-directory: ${{ env.WORKING_DIR }} | ||
| run: terraform init | ||
|
|
||
| - name: Terraform Plan | ||
| working-directory: ${{ env.WORKING_DIR }} | ||
| run: terraform plan -var-file=variables.tfvars -no-color -input=false | ||
|
Comment on lines
+55
to
+82
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Plan job is well-configured but will fail due to module output errors. The plan job structure is correct—it runs only on PRs, configures AWS credentials, and uses the correct var-file. However, it will fail during 🤖 Prompt for AI Agents |
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,14 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| output "alb_dns_name" { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description = "The DNS name of the Application Load Balancer" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| value = aws_lb.alb.dns_name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| output "alb_arn" { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description = "The ARN of the Application Load Balancer" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| value = aws_lb.alb.arn | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| output "target_group_arn" { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description = "The ARN of the ALB target group" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| value = aws_lb_target_group.tg.arn | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+1
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resource label mismatches will cause terraform to fail. All outputs reference incorrect resource labels. According to
These mismatches will cause 🐛 Proposed fix to correct resource references output "alb_dns_name" {
description = "The DNS name of the Application Load Balancer"
- value = aws_lb.alb.dns_name
+ value = aws_lb.web-elb.dns_name
}
output "alb_arn" {
description = "The ARN of the Application Load Balancer"
- value = aws_lb.alb.arn
+ value = aws_lb.web-elb.arn
}
output "target_group_arn" {
description = "The ARN of the ALB target group"
- value = aws_lb_target_group.tg.arn
+ value = aws_lb_target_group.web-tg.arn
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,14 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| output "rds_cluster_endpoint" { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description = "The writer endpoint of the Aurora RDS cluster" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| value = aws_rds_cluster.rds-cluster.endpoint | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| output "rds_reader_endpoint" { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description = "The reader endpoint of the Aurora RDS cluster" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| value = aws_rds_cluster.rds-cluster.reader_endpoint | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| output "rds_cluster_port" { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description = "The port of the Aurora RDS cluster" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| value = aws_rds_cluster.rds-cluster.port | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+1
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resource label mismatch will cause terraform to fail. All outputs reference This mismatch will cause 🐛 Proposed fix to correct resource references output "rds_cluster_endpoint" {
description = "The writer endpoint of the Aurora RDS cluster"
- value = aws_rds_cluster.rds-cluster.endpoint
+ value = aws_rds_cluster.aurora_cluster.endpoint
}
output "rds_reader_endpoint" {
description = "The reader endpoint of the Aurora RDS cluster"
- value = aws_rds_cluster.rds-cluster.reader_endpoint
+ value = aws_rds_cluster.aurora_cluster.reader_endpoint
}
output "rds_cluster_port" {
description = "The port of the Aurora RDS cluster"
- value = aws_rds_cluster.rds-cluster.port
+ value = aws_rds_cluster.aurora_cluster.port
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| output "cloudfront_domain_name" { | ||
| description = "The domain name of the CloudFront distribution" | ||
| value = aws_cloudfront_distribution.cf.domain_name | ||
| } | ||
|
|
||
| output "cloudfront_distribution_id" { | ||
| description = "The ID of the CloudFront distribution" | ||
| value = aws_cloudfront_distribution.cf.id | ||
| } | ||
|
|
||
| output "acm_certificate_arn" { | ||
| description = "The ARN of the ACM certificate" | ||
| value = aws_acm_certificate.acm.arn | ||
| } | ||
|
Comment on lines
+1
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Description: Verify CloudFront and ACM resource labels in the module's main.tf
echo "=== Searching for CloudFront distribution resource label ==="
rg -n 'resource\s+"aws_cloudfront_distribution"' DevOps-Project-11/modules/aws-waf-cdn-acm-route53/
echo ""
echo "=== Searching for ACM certificate resource label ==="
rg -n 'resource\s+"aws_acm_certificate"' DevOps-Project-11/modules/aws-waf-cdn-acm-route53/Repository: NotHarshhaa/DevOps-Projects Length of output: 411 Fix resource label references in outputs — both CloudFront and ACM certificate references are incorrect. The outputs reference non-existent resource labels:
Update lines 3 and 8 to use 🤖 Prompt for AI Agents |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| # ----------------------------------------------------------------------------- | ||
| # Root Outputs — Two-Tier AWS Architecture | ||
| # These values are printed to the console after a successful `terraform apply`. | ||
| # ----------------------------------------------------------------------------- | ||
|
|
||
| output "alb_dns_name" { | ||
| description = "DNS name of the Application Load Balancer (HTTP entry point)" | ||
| value = module.alb.alb_dns_name | ||
| } | ||
|
|
||
| output "cloudfront_domain_name" { | ||
| description = "Domain name of the CloudFront distribution (HTTPS entry point)" | ||
| value = module.route53.cloudfront_domain_name | ||
| } | ||
|
|
||
| output "rds_endpoint" { | ||
| description = "Writer endpoint of the Aurora MySQL cluster" | ||
| value = module.rds.rds_cluster_endpoint | ||
| } | ||
|
|
||
| output "rds_reader_endpoint" { | ||
| description = "Reader endpoint of the Aurora MySQL cluster (read replicas)" | ||
| value = module.rds.rds_reader_endpoint | ||
| } | ||
|
|
||
| output "cloudfront_distribution_id" { | ||
| description = "CloudFront distribution ID (useful for cache invalidation)" | ||
| value = module.route53.cloudfront_distribution_id | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Branch mismatch: workflow triggers on
mainbut PR targetsmaster.The workflow is configured to trigger on
pushandpull_requestevents to themainbranch, but according to the PR objectives, this PR targets themasterbranch. This means the workflow will not run for this PR or future changes targetingmaster.Either update the workflow to trigger on
master, or ensure the repository's default branch ismain.🐛 Proposed fix if targeting master branch
📝 Committable suggestion
🤖 Prompt for AI Agents