Skip to content

[EPAC-2101]: re-add terraform apply for staging workspace to backend staging deploy#627

Merged
riddim-developer-bot[bot] merged 1 commit into
mainfrom
symphony/epac-2101-re-add-terraform-apply-for-staging-workspace-to
May 26, 2026
Merged

[EPAC-2101]: re-add terraform apply for staging workspace to backend staging deploy#627
riddim-developer-bot[bot] merged 1 commit into
mainfrom
symphony/epac-2101-re-add-terraform-apply-for-staging-workspace-to

Conversation

@riddim-developer-bot

Copy link
Copy Markdown
Contributor

Why

The terraform apply step for the staging workspace was removed in EPAC-2072 (PR #602) because the CI IAM role lacked S3 access to the Terraform state bucket. That IAM gap has since been fixed. Without terraform apply, newly registered Lambda services (e.g. epac-hansard-search-index-staging from EPAC-2062) never get provisioned — the deploy job skips them and downstream workflows like hansard-search-reindex.yml fail with ResourceNotFoundException.

What changed

  • Added infra-apply job to backend-staging.yml that runs terraform init and terraform apply -auto-approve in infra/terraform/staging/ using the existing AWS_BACKEND_STAGING_ROLE_ARN credentials.
  • Added hashicorp/setup-terraform@v3 step so the Terraform CLI is available on the runner.
  • Updated deploy job dependency from needs: prepare to needs: [prepare, infra-apply] so deploys only run after infrastructure is provisioned.
  • Added infra/terraform/staging/** to the paths trigger so infra-only changes also trigger the workflow.

Trade-offs not taken

  • Did not add -target flags to scope the apply — full workspace apply is required so all manifest-registered services are provisioned.
  • Did not add terraform plan as a separate preview step — the existing concurrency group prevents concurrent runs and the staging workspace is a non-production environment where plan review overhead is not warranted.

Verification

  • actionlint passes clean on the modified workflow file.
  • Terraform staging directory (infra/terraform/staging/) confirmed to exist with main.tf, variables.tf, outputs.tf, versions.tf.
  • Cannot run full workflow locally (requires AWS credentials and GitHub Actions runner context).

Risks

  • First CI-driven terraform apply on this workspace — the plan output should be reviewed in the workflow run summary after the first execution. Any unexpected destroy actions on existing resources warrant investigation.
  • terraform apply holds the DynamoDB state lock for its duration; the workflow's concurrency: group: backend-staging-deploy prevents concurrent runs.

Resolves EPAC-2101

Reviewer-Boundary: review-only

@riddim-developer-bot riddim-developer-bot Bot added the autonomous Enrolled in prconverged daemon for automated review and merge label May 26, 2026
@riddim-developer-bot
riddim-developer-bot Bot enabled auto-merge (squash) May 26, 2026 01:46
@riddim-developer-bot
riddim-developer-bot Bot merged commit a509f55 into main May 26, 2026
5 checks passed
@riddim-developer-bot
riddim-developer-bot Bot deleted the symphony/epac-2101-re-add-terraform-apply-for-staging-workspace-to branch May 26, 2026 01:48
riddim-developer-bot Bot added a commit that referenced this pull request May 26, 2026
…le management (#628)

## Summary

- Add `lambda:ListVersionsByFunction`, `lambda:CreateFunction`,
`lambda:DeleteFunction`, `lambda:GetPolicy`, `lambda:ListTags`,
`lambda:TagResource`, and `lambda:UntagResource` to both the staging and
production CI IAM role policies
- These permissions are required by the Terraform AWS provider to
refresh Lambda function state, create new functions from the deployment
manifest, manage tags, and handle full lifecycle operations

## Root cause

PR #627 (EPAC-2101) re-added `terraform apply` for the staging workspace
to the backend staging deploy workflow. The Terraform provider calls
`lambda:ListVersionsByFunction` during the state refresh phase, but the
`ManageStagingLambda` IAM policy only included the subset of Lambda
actions needed for direct CLI deploys (update-function-code,
get-function, etc.) — not the broader set Terraform needs.

Failed run:
https://github.com/RiddimSoftware/epac/actions/runs/26427674950

Error: `User:
arn:aws:sts::227530433709:assumed-role/GitHubActions-epac-backend-staging/GitHubActions
is not authorized to perform: lambda:ListVersionsByFunction on resource:
arn:aws:lambda:us-east-1:227530433709:function:epac-health-staging`

## Post-merge action required

The IAM policy is managed by the **core** Terraform workspace
(`infra/terraform/core/`), which is applied separately from the staging
workspace. After this PR merges, the core workspace must be applied
before the next staging deploy will succeed:

```bash
cd infra/terraform/core
terraform init
terraform apply
```

## Verification

- `terraform validate` passes for the core workspace
- Production policy updated with the same permissions for consistency

Reviewer-Boundary: review-only

Resolves EPAC-2102

_Issue estimate was not set in Linear._

Co-authored-by: riddim-developer-bot <developer-bot@riddimsoftware.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autonomous Enrolled in prconverged daemon for automated review and merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants