Terraform Infrastructure #10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Terraform Infrastructure | |
| on: | |
| workflow_dispatch: | |
| workflow_call: | |
| inputs: | |
| terraform-action: | |
| description: 'Terraform action to perform (plan/apply/destroy)' | |
| required: false | |
| default: 'apply' | |
| type: string | |
| outputs: | |
| terraform-result: | |
| description: "Terraform execution result" | |
| value: ${{ jobs.terraform.outputs.result }} | |
| jobs: | |
| terraform: | |
| name: Terraform Deployment | |
| runs-on: ubuntu-latest | |
| environment: production | |
| outputs: | |
| result: ${{ steps.terraform-apply.outcome }} | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v5 | |
| - name: Login to AWS | |
| uses: aws-actions/[email protected] | |
| 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: Setup Terraform | |
| uses: hashicorp/[email protected] | |
| with: | |
| terraform_version: 1.5.7 | |
| - name: Terraform Init | |
| run: terraform init | |
| working-directory: ./Terraform | |
| - name: Terraform Plan | |
| run: terraform plan | |
| working-directory: ./Terraform | |
| - name: Terraform Apply | |
| id: terraform-apply | |
| if: ${{ inputs.terraform-action == 'apply' || inputs.terraform-action == '' }} | |
| run: terraform apply -auto-approve | |
| working-directory: ./Terraform | |
| - name: Update kubeconfig | |
| if: ${{ inputs.terraform-action == 'apply' || inputs.terraform-action == '' }} | |
| run: | | |
| aws eks update-kubeconfig --name otel-cluster --region us-east-1 | |
| - name: Wait for ArgoCD LoadBalancer | |
| if: ${{ inputs.terraform-action == 'apply' || inputs.terraform-action == '' }} | |
| run: | | |
| echo "Waiting for ArgoCD LoadBalancer to be ready..." | |
| kubectl wait --for=condition=available --timeout=300s deployment/argocd-server -n argocd || true | |
| sleep 30 | |
| - name: Get ArgoCD Access Info | |
| if: ${{ inputs.terraform-action == 'apply' || inputs.terraform-action == '' }} | |
| run: | | |
| echo "==========================================" | |
| echo "🚀 ARGOCD ACCESS INFORMATION" | |
| echo "==========================================" | |
| # Get ArgoCD URL | |
| ARGOCD_URL=$(kubectl get svc argocd-server -n argocd -o jsonpath='{.status.loadBalancer.ingress[0].hostname}' 2>/dev/null || echo "Still loading...") | |
| echo "📋 ArgoCD URL: http://$ARGOCD_URL" | |
| # Get admin password | |
| ARGOCD_PASSWORD=$(kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath='{.data.password}' 2>/dev/null | base64 -d || echo "Secret not ready yet") | |
| echo "🔑 Username: admin" | |
| echo "🔑 Password: $ARGOCD_PASSWORD" | |
| echo "==========================================" | |
| echo "📝 Instructions:" | |
| echo "1. Wait a few minutes for LoadBalancer DNS to propagate" | |
| echo "2. Access: http://$ARGOCD_URL" | |
| echo "3. Login with username 'admin' and password above" | |
| echo "4. Your solar-system app should appear automatically" | |
| echo "==========================================" |