Skip to content

Commit

Permalink
Merge pull request #9121 from ministryofjustice/feature/8345-remove-o…
Browse files Browse the repository at this point in the history
…ld-state-locking-config

Remove dynamodb table and legacy role for state access
  • Loading branch information
dms1981 authored Jan 30, 2025
2 parents 347449c + feadab6 commit 260837c
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 158 deletions.
83 changes: 0 additions & 83 deletions terraform/modernisation-platform-account/dynamodb.tf

This file was deleted.

75 changes: 0 additions & 75 deletions terraform/modernisation-platform-account/iam.tf
Original file line number Diff line number Diff line change
Expand Up @@ -193,81 +193,6 @@ resource "aws_iam_role_policy_attachment" "modernisation_account_limited_read" {
policy_arn = aws_iam_policy.modernisation_account_limited_read.arn
}

# Modernisation Platform Environments Terraform backend role

data "aws_iam_policy_document" "modernisation_account_terraform_state_role" {
version = "2012-10-17"
statement {
sid = "AllowDynamoDBAccess"
effect = "Allow"
actions = [
"dynamodb:DescribeTable",
"dynamodb:GetItem",
"dynamodb:PutItem",
"dynamodb:DeleteItem"
]
resources = ["arn:aws:dynamodb:eu-west-2:${data.aws_caller_identity.current.account_id}:table/modernisation-platform-terraform-state-lock"]
}
statement {
sid = "AllowS3AccessList"
effect = "Allow"
actions = ["s3:ListBucket"]
resources = ["arn:aws:s3:::modernisation-platform-terraform-state"]
}
statement {
sid = "AllowS3AccessActions"
effect = "Allow"
actions = [
"s3:DeleteObject",
"s3:GetObject",
"s3:PutObject",
]
resources = [
"arn:aws:s3:::modernisation-platform-terraform-state/environments/members/*",
"arn:aws:s3:::modernisation-platform-terraform-state/environments/bootstrap/*"
]
}
}

data "aws_iam_policy_document" "modernisation_account_terraform_state_assume_role" {
version = "2012-10-17"

statement {
effect = "Allow"
actions = ["sts:AssumeRole"]

principals {
type = "AWS"
identifiers = ["*"]
}

condition {
test = "ForAnyValue:StringLike"
variable = "aws:PrincipalOrgPaths"
values = ["${data.aws_organizations_organization.root_account.id}/*/${local.modernisation_platform_ou_id}/*"]
}
}
}

resource "aws_iam_role" "modernisation_account_terraform_state" {
name = "modernisation-account-terraform-state-member-access"
max_session_duration = 3600
assume_role_policy = data.aws_iam_policy_document.modernisation_account_terraform_state_assume_role.json

tags = local.tags
}

resource "aws_iam_policy" "modernisation_account_terraform_state" {
name = "ModernisationAccountTerraformState"
description = "Role allowing Modernisation Platform customers access to Terraform state backend resources"
policy = data.aws_iam_policy_document.modernisation_account_terraform_state_role.json
}

resource "aws_iam_role_policy_attachment" "modernisation_account_terraform_state" {
role = aws_iam_role.modernisation_account_terraform_state.id
policy_arn = aws_iam_policy.modernisation_account_terraform_state.arn
}

# OIDC Provider for GitHub Actions Plan

module "github_actions_plan_role" {
Expand Down

0 comments on commit 260837c

Please sign in to comment.