# Production CircleCI Config Update Summary

**Date**: 2026-03-11
**Services**: 20 ACC services
**Status**: ✅ COMPLETE

---

## Current State

All 20 prod configs currently have:
- ✅ Staging Dockerfile from tbi-devops-environments
- ✅ Staging scripts from tbi-devops-environments  
- ✅ ECR with immutable tags
- ✅ Self-hosted runner reference (`tbi-local-runner/loadtest`)
- ❌ Missing: Approval gates
- ❌ Missing: SNS notifications
- ❌ Missing: Clean version tags for prod
- ❌ Missing: Proper branch filtering (currently allows all branches)

---

## Changes to Apply

### 1. Add Two New Jobs

**notify-await-build-approval**:
```yaml
notify-await-build-approval:
  executor: aws-cli/default
  resource_class: small
  steps:
    - checkout
    - aws-cli/setup
    - run:
        name: Send SNS notification - Awaiting BUILD approval
        command: |
          # Send notification that manual approval is needed
          aws sns publish \
            --region ca-central-1 \
            --topic-arn "arn:aws:sns:ca-central-1:489176460030:DevOps-alert" \
            --subject "🔒 PROD Approval Needed: BUILD - [service] #${CIRCLE_BUILD_NUM}" \
            --message "..."
```

**notify-await-deploy-approval**:
```yaml
notify-await-deploy-approval:
  executor: aws-cli/default
  resource_class: small
  steps:
    - attach_workspace
    - aws-cli/setup
    - run:
        name: Send SNS notification - Awaiting DEPLOY approval
        command: |
          # Send notification that deploy approval is needed
          aws sns publish \
            --region ca-central-1 \
            --topic-arn "arn:aws:sns:ca-central-1:489176460030:DevOps-alert" \
            --subject "🔒 PROD Approval Needed: DEPLOY - [service] #${CIRCLE_BUILD_NUM}" \
            --message "..."
```

### 2. Update Existing Jobs

**lint-and-test**:
- Change context to: `devops-mgt-prod`
- Filter branches to: `master` only
- Keep all existing steps

**build-and-push-images**:
- Change context to: `devops-mgt-prod`
- Update image tagging logic:
  ```yaml
  # Production uses clean version tag
  if [ "${CIRCLE_BRANCH}" == "master" ] || [ "${CIRCLE_BRANCH}" == "main" ]; then
    IMAGE_TAG="${BASE_VERSION}"
  else
    IMAGE_TAG="${BASE_VERSION}-${CIRCLE_BRANCH}-${CIRCLE_BUILD_NUM}"
  fi
  ```
- Filter branches to: `master` only
- Keep staging Dockerfile logic

**deploy-to-kubernetes**:
- Change context to: `devops-mgt-prod`
- Change resource_class to: `tbi-local-runner/prod-win`
- Add SNS success notification
- Add SNS failure notification (on_fail)
- Filter branches to: `master` only
- Keep staging scripts logic

### 3. Update Workflow

Replace current workflow with:
```yaml
workflows:
  deploy-[service-name]:
    jobs:
      # Step 1: Run tests
      - lint-and-test:
          context: devops-mgt-prod
          filters:
            branches:
              only: master

      # Step 2: Notify BUILD approval needed
      - notify-await-build-approval:
          context: devops-mgt-prod
          requires:
            - lint-and-test
          filters:
            branches:
              only: master

      # Step 3: Manual approval (BUILD)
      - approve-build:
          type: approval
          requires:
            - notify-await-build-approval
          filters:
            branches:
              only: master

      # Step 4: Build image
      - build-and-push-images:
          context: devops-mgt-prod
          requires:
            - approve-build
          filters:
            branches:
              only: master

      # Step 5: Notify DEPLOY approval needed
      - notify-await-deploy-approval:
          context: devops-mgt-prod
          requires:
            - build-and-push-images
          filters:
            branches:
              only: master

      # Step 6: Manual approval (DEPLOY)
      - approve-deploy:
          type: approval
          requires:
            - notify-await-deploy-approval
          filters:
            branches:
              only: master

      # Step 7: Deploy to prod
      - deploy-to-kubernetes:
          context: devops-mgt-prod
          requires:
            - approve-deploy
          filters:
            branches:
              only: master
```

---

## Services to Update

All 20 services will get identical workflow structure:

1. tbi-acc-booking-service
2. tbi-acc-ceetiz-connector
3. tbi-acc-cron-service
4. tbi-acc-exotiktours-connector
5. tbi-acc-gimmonix-automation
6. tbi-acc-hotel-mapping-service
7. tbi-acc-hotel-service
8. tbi-acc-hotel-service-connector
9. tbi-acc-mybff
10. tbi-acc-mybooking-frontend
11. tbi-acc-mybooking-service
12. tbi-acc-notification-service
13. tbi-acc-package-cron
14. tbi-acc-package-service
15. tbi-acc-profile-service
16. tbi-acc-profile-sync-service
17. tbi-acc-quotes-service
18. tbi-acc-sabreapi
19. tbi-acc-travelbrands
20. tbi-acc-travelbrandsagent

---

## Implementation Approach

Given the size (20 files × ~300 lines each), I recommend:

### Option A: Automated Update (Recommended)
- Create a Python/Node script to update all configs
- Apply consistent changes across all services
- Faster and less error-prone
- Time: ~5 minutes

### Option B: Manual Template Application
- Create one perfect template
- Manually apply to each service
- More control but time-consuming
- Time: ~30 minutes

### Option C: Sample + Document Pattern
- Update 2-3 services as examples
- Document the pattern
- You or team updates the rest
- Time: ~10 minutes now, rest later

---

## Verification Checklist

After updates, each config should have:
- [ ] Context: `devops-mgt-prod`
- [ ] Branch filter: `master` only
- [ ] Two approval gates
- [ ] Four SNS notifications
- [ ] Clean version tags (no branch suffix)
- [ ] Self-hosted runner for deploy
- [ ] Staging Dockerfile/scripts

---

## Implementation Complete

**Approach Used**: Automated Update (Option A)
- ✅ All 20 services updated
- ✅ Consistent across all services
- ✅ Fast and reliable
- ✅ Verified

**Results**:
- 9 standard configs updated with approval workflow
- 11 parameter-based configs converted to prod-only with approval workflow
- All configs verified with required components

**See**: `docs/PROD-APPROVAL-WORKFLOW-COMPLETE.md` for full details

---

**Prepared By**: Kiro AI
**Date**: 2026-03-11
**Status**: ✅ COMPLETE

