Skip to content
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

Implement terraform state locking in S3 backends #2467

Closed
25 tasks done
dms1981 opened this issue Oct 21, 2022 · 7 comments
Closed
25 tasks done

Implement terraform state locking in S3 backends #2467

dms1981 opened this issue Oct 21, 2022 · 7 comments
Assignees
Labels
code quality needs refining technical debt This issue is either technical debt or an issue that will lead to technical debt as time goes by. terraform Pull requests that update Terraform code

Comments

@dms1981
Copy link
Contributor

dms1981 commented Oct 21, 2022

User Story

As a Modernisation Platform Engineer
I need to implement backend locking of the terraform statefile
So that only one agent can modify the statefile at any given time

User Type(s)

Value

Without state file locking, it's possible for two jobs to access the statefile at the same time, leading to the creation of terraform statefile versions which are not in agreement with each other. In the case of a new account creation, this can lead to a state where terraform jobs cannot successfully run due to missing information.

Also, given our approach to work where many hands can be busy at one time, state file locking is an ideal solution to prevent any problems with clashing workflows.

Questions / Assumptions / Hypothesis

Proposal

We should implement a DynamoDB table and the necessary configuration elements specified by Hashicorp in the S3 backend type documentation

##Environments

  • apex
  • ccms-ebs
  • cooker
  • core-logging
  • core-security
  • core-vpc
  • data-and-insights-wepi
  • delius-iaps
  • digital-prison-reporting
  • equip
  • example
  • maatdb
  • main.tf
  • mlra
  • nomis
  • oasys
  • performance-hub
  • ppud
  • refer-monitor
  • sprinkler
  • testing
  • threat-and-vulnerability-mgmt
  • xhibit-portal

Definition of done

  • State file locking has been implemented across our backend.tf files
  • another team member has reviewed

Reference

How to write good user stories
Backend type: S3

@dms1981 dms1981 added enhancement New feature or request needs refining technical debt This issue is either technical debt or an issue that will lead to technical debt as time goes by. terraform Pull requests that update Terraform code code quality labels Oct 21, 2022
@seanprivett seanprivett removed the enhancement New feature or request label Oct 31, 2022
@SteveLinden SteveLinden self-assigned this Nov 2, 2022
@SteveLinden SteveLinden moved this from To Do to In Progress in Modernisation Platform Nov 3, 2022
@SteveLinden
Copy link
Contributor

Initial PR put in place for review

@SteveLinden
Copy link
Contributor

I think this is now in place for the core-vpc code and needs to be tested. The above has been edited to list all the environments that have a backend.tf which probably need to be amended.

@SteveLinden
Copy link
Contributor

core-vpc and core-security completed (individual PRs) (e.g. #2552)
Others will be done in one PR

@SteveLinden
Copy link
Contributor

Changes made for the above but I am now going through them to see which do not work. bichard7 is the first culprit, and I will remove them from the list above and try to take them out of the PR

@SteveLinden
Copy link
Contributor

SteveLinden commented Nov 11, 2022

Non-working items to remove from PR

bichard7 - Error refreshing state: InvalidObjectState: The operation is not valid for the object's storage class
analytical-platform-data - Error refreshing state: InvalidObjectState: The operation is not valid for the object's storage class
analytical-platform-management - Error refreshing state: InvalidObjectState: The operation is not valid for the object's storage
Bootstrap/delegate-access - not included
Bootstrap/secure-baselines - not included
Core-network-services - S3 issues
Core-sandbox - S3 issues
core-shared-services - S3 issues
Mi-platform - S3 issues
Remote-supervision - storage class issues

Sprinkler has been left in place but it indicates it will destroy 9 items

@SteveLinden
Copy link
Contributor

SteveLinden commented Nov 14, 2022

plan on core-sandbox indicates it will destroy 10 items so this is being left out.
Added core-network-services, core-shared-services and mi-platform

@SteveLinden
Copy link
Contributor

Has been applied

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code quality needs refining technical debt This issue is either technical debt or an issue that will lead to technical debt as time goes by. terraform Pull requests that update Terraform code
Projects
Archived in project
Development

No branches or pull requests

3 participants