Skip to content

Restrict use of the GitHub connection - #2331

Merged
whi-tw merged 2 commits into
mainfrom
whi-tw/deployment-triggering
Oct 22, 2026
Merged

whi-tw merged 2 commits into
mainfrom
whi-tw/deployment-triggering

Conversation

@whi-tw

@whi-tw whi-tw commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

What problem does this pull request solve?

Trello card: https://trello.com/c/j4GU3D6F/858-review-our-how-trigger-deployments

This limits which roles can use and pass the GitHub connection, and what they can use it for.

The support role (manage-deployments) loses codepipeline:UpdatePipeline, iam:PassRole, iam:GetRole, PassConnection and UseConnection. The pause, unpause and deploy rake tasks and trigger_terraform_pipeline only start executions and toggle stage transitions, so they are unaffected. CloudTrail shows no UpdatePipeline calls through the support role in the last 90 days in dev, staging, production or deploy. The codestar_connection_arn variable is removed from the engineer-access module because nothing uses it now.

The deployer role (deployer-access) can now use the connection only for govuk-forms/forms-deploy and govuk-forms/forms-e2e-tests, and pass it only to CodePipeline. Our connection ARNs use the codeconnections prefix but the policy only had codestar-connections actions, so it now grants both prefixes on both ARN forms, each with its own condition key. A codecommit:GitPull statement is removed, because the connection ARN is not a CodeCommit resource and it never granted anything.

Applied to dev: the plan showed only the two policy updates and apply-forms-terraform-dev succeeded. As the support role, get-pipeline-state, the pause and unpause rake tasks and trigger_terraform_pipeline still work, and UpdatePipeline is denied.

Things to consider when reviewing

  • The repository list in the deployer policy is hardcoded, so a pipeline that fetches another repo needs it updated.
  • The codestar-connections: statements are kept until the codeconnections: ones are shown to be enough on their own.
  • Staging and production have not been applied yet.

Reminders

If you've made changes to the deployer role (files in modules/deployer-access):

  • Remember to run make <environment> forms/account apply on the relevant environments (dev, staging and/or prod)
  • Check the #govuk-forms-deployment-notifications Slack channel to ensure the apply-forms-terraform-<environment> pipelines have run successfully

Copilot AI balanced review requested due to automatic review settings October 20, 2026 09:52

This comment was marked as outdated.

The manage-deployments policy let the support role update any pipeline
in the account, pass any IAM role and pass the GitHub connection to
CodePipeline. Together those allow a pipeline to be repointed at any
repository the connection can reach and run under a role of the
caller's choosing.

Nothing needs them. The pause, unpause and deploy rake tasks and the
trigger_terraform_pipeline make target only start executions and toggle
stage transitions. CloudTrail shows the UpdatePipeline calls in dev
came from admin roles and the deployer role, not the support role.
The deployer role could use and pass the connection with no limit on
which repository it fetched. Limit UseConnection to the two repositories
its pipelines fetch, and PassConnection to CodePipeline.

The connection ARNs use the codeconnections prefix but the policy only
granted codestar-connections actions. Each prefix has its own condition
keys, so grant both, on both forms of the ARN.

Remove the codecommit:GitPull statement. CodeCommit has no resource
type that matches a connection ARN, so it granted nothing.
@whi-tw
whi-tw force-pushed the whi-tw/deployment-triggering branch from 0c48483 to 60ffe61 Compare October 20, 2026 11:05
Copilot AI balanced review requested due to automatic review settings October 20, 2026 11:05
@whi-tw whi-tw changed the title Scope PassConnection to the connection ARN Restrict use of the GitHub connection Oct 20, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The permission removals and new authorization conditions need reconciliation with the stated scope before rollout.

2 open issues

Review effort: Balanced

Comment thread infra/modules/deployer-access/policy.tf
Comment thread infra/modules/engineer-access/policies.tf

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Deployment-critical IAM changes need human rollout review because staging and production remain unvalidated.

No open issues 🎉

2 resolved since last review

Review effort: Balanced

@whi-tw
whi-tw requested a review from theseanything October 20, 2026 11:23
@whi-tw
whi-tw added this pull request to the merge queue Oct 22, 2026
Merged via the queue into main with commit 66750ed Oct 22, 2026
24 checks passed
@whi-tw
whi-tw deleted the whi-tw/deployment-triggering branch October 22, 2026 09:01
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.

3 participants