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

Allow ability to create ad-hoc backups on developer role #8617

Closed
4 tasks done
richgreen-moj opened this issue Nov 28, 2024 · 14 comments
Closed
4 tasks done

Allow ability to create ad-hoc backups on developer role #8617

richgreen-moj opened this issue Nov 28, 2024 · 14 comments
Assignees
Labels
member request Feature requested by a member to enhance the platform experience

Comments

@richgreen-moj
Copy link
Contributor

richgreen-moj commented Nov 28, 2024

User Story

As a MP developer
I want the ability to perform ad-hoc backups via the console
So that I can do this for myself without the intervention of the Mod Platform team

Value / Purpose

The purpose of this ticket is to consider granting the MP Developer role the ability to perform ad-hoc backups in the console.

Currently members need to request it via the #ask-modernisation-platform slack channel. This adds an unnecessary middle-man and delay to performing the task.

MP should consider the impact of making this available and the right level of permissions to grant.

Context / Background

Requested here: https://mojdt.slack.com/archives/C01A7QK5VM1/p1732801669766849

Also likely to have been requested by others in the past.

Useful Contacts

No response

Additional Information

No response

Definition of Done

  • Consider permissions required
  • Update Developer policy/role as required
  • Test using role to create an ad-hoc backup
  • Deploy to the role and notify members
@richgreen-moj richgreen-moj added iam member request Feature requested by a member to enhance the platform experience needs refining labels Nov 28, 2024
@mikereiddigital mikereiddigital self-assigned this Jan 15, 2025
@mikereiddigital mikereiddigital moved this from To Do to In Progress in Modernisation Platform Jan 15, 2025
@mikereiddigital
Copy link
Contributor

The significant issue is whether to add delete privs and if so, how they are restricted so that the main backups cannot be accessed.

@mikereiddigital mikereiddigital moved this from In Progress to To Do in Modernisation Platform Jan 15, 2025
@mikereiddigital
Copy link
Contributor

mikereiddigital commented Jan 15, 2025

Checked with @VinceChiuMOJ in the LAA Ops team & can confirm that using the standard developer role in a non-sandbox account, that role already has the necessary permissions to create EBS and RDS snapshots. It does not have permissions to delete those snapshots.

Suggest that no further action is required on this issue.

@mikereiddigital mikereiddigital moved this from To Do to For Review in Modernisation Platform Jan 15, 2025
@richgreen-moj
Copy link
Contributor Author

Hi @mikereiddigital could you check in with the originator of the request just to make sure they are aware/content? https://mojdt.slack.com/archives/C01A7QK5VM1/p1732801669766849

I think it's fine if it's already available in the developer role.

@mikereiddigital
Copy link
Contributor

Put out a message on the "Update" channel & have contacted Dominic Robinson to check whether it is a different role he needs.

@mikereiddigital
Copy link
Contributor

Spoke with Dominic. The requirement he has is to be able to create ad-hoc AWS Backups, ideally using the AWSBackup role. Currently this is prevented. He stated that it's far more convenient to use the ad-hoc AWS Backup as the wrapper for the backups rather than take them individually. Also he has the need to generate EFS backups using this method.

I will pick this up again tomorrow morning.

@mikereiddigital mikereiddigital moved this from For Review to In Progress in Modernisation Platform Jan 16, 2025
@mikereiddigital
Copy link
Contributor

mikereiddigital commented Jan 17, 2025

Having done some testing in sprinkler & had a call with AWS, the issue is that the developer SSO permission set being used requires the "IAM:PassRole" permission for the role AWSBackUp as defined here.

For reference - https://docs.aws.amazon.com/aws-managed-policy/latest/reference/AWSBackupServiceRolePolicyForBackup.html

That role has attached it the AWS Managed role AWSBackupServiceRolePolicyForBackup that a number of permissions that we have not yet granted the developer role, including:

  • rds:DeleteDBInstanceAutomatedBackup
  • rds:DeleteDBClusterAutomatedBackup
  • rds:DeleteDBSnapshot
  • ec2:DeleteSnapshot
  • ec2:DeregisterImage

etc.

An best approach to limit this would be to restrict its use through the "iam:PassedToService" condition. For example:

  # Additional statement that allows for the creation of on-demand AWS Backups.
  statement {
    sid    = "AllowPassRoleForBackup"
    effect = "Allow"
    actions = ["iam:PassRole"]
    resources = ["arn:aws:iam::${data.aws_caller_identity.current.account_id}:role/AWSBackup"]
    condition {
      test     = "StringEquals"
      variable = "iam:PassedToService"
      values   = ["backup.amazonaws.com"]
    }
  }

Will discuss with colleagues before progressing.

@mikereiddigital
Copy link
Contributor

mikereiddigital commented Jan 17, 2025

Spoke with David & confirmed the approach to use iam:PassRole as shown in the above. Tested in sprinkler with that additional statement and the following:

"backup:StartBackupJob"

and I have been able to create ad-hoc backups for efs, ec2 and rds.

I will create a new PR for Monday morning.

@mikereiddigital mikereiddigital mentioned this issue Jan 20, 2025
4 tasks
@mikereiddigital
Copy link
Contributor

Deployed via PR - #9006.

Will contact Dominic and ask him to test it.

@mikereiddigital
Copy link
Contributor

An issue occured with the approach taken to identify the current account id (using aws_caller_identity) whereby it when applied via the production bootstrap workflow it would pick up the mod platform account id. As a result an alternative was sought. Reusing the local environment_management would result in a low-level terraform exception that is unhandled by the existing plan workflow

Error: -20T15:41:56.544Z [ERROR] AttachSchemaTransformer: No provider config schema available for provider["terraform.io/builtin/terraform"]

https://github.com/ministryofjustice/modernisation-platform/actions/runs/12871455952/job/35884786849?pr=9008#step:7:155

Though when run locally the plan would work and the local correctly referencing the correct accound id.

The solution I've found is the create a new local calling the same secret data resource. This works without error. See https://github.com/ministryofjustice/modernisation-platform/actions/runs/12883276724/job/35917195021?pr=9016#step:7:89

@mikereiddigital
Copy link
Contributor

PR with the new approach. #9027

The error was resolved by removing the existing statement first. Not clear what the underlying issue was though.

@mikereiddigital
Copy link
Contributor

Successfully tested in both cooker & example.

@mikereiddigital mikereiddigital moved this from In Progress to For Review in Modernisation Platform Jan 21, 2025
@mikereiddigital
Copy link
Contributor

Posted message on the Update channel. https://mojdt.slack.com/archives/D057KCLN11U/p1737461331343439

@mikereiddigital
Copy link
Contributor

Dominic Robinson has tested and confirmed working.

@SimonPPledger SimonPPledger removed the iam label Jan 22, 2025
@SimonPPledger
Copy link
Contributor

As this is a member request and Dominic has confirmed it works then moving to done

@SimonPPledger SimonPPledger moved this from For Review to Done in Modernisation Platform Jan 22, 2025
@SimonPPledger SimonPPledger closed this as completed by moving to Done in Modernisation Platform Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
member request Feature requested by a member to enhance the platform experience
Projects
Status: Done
Development

No branches or pull requests

3 participants