Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions infra/deployments/deploy/engineer-access/roles.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module "engineer_access" {
codestar_connection_arn = var.codestar_connection_arn
allow_ecs_task_usage = false
allow_rds_data_api_access = false
state_file_bucket_name = "gds-forms-deploy-tfstate"

# Pentesters may not have GDS domains so our pattern using the 'users' module
# doesn't necessarily work.
Expand Down
20 changes: 20 additions & 0 deletions infra/deployments/forms/account/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions infra/deployments/forms/account/engineer-access.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ module "engineer_access" {
codestar_connection_arn = var.codestar_connection_arn
allow_rds_data_api_access = true
allow_ecs_task_usage = true
state_file_bucket_name = var.bucket
}
27 changes: 27 additions & 0 deletions infra/deployments/integration/account/engineer-access.tf
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,31 @@ resource "aws_iam_policy" "deny_parameter_store" {
})
}

resource "aws_iam_policy" "lock_state_files" {
name = "release-lock-on-state-files"
path = "/"

description = "Allow locking state files"

policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Action = [
"s3:GetObject",
"s3:PutObject",
"s3:DeleteObject"
]
Effect = "Allow"
Resource = [
"arn:aws:s3:::${var.bucket}/*.tflock"
]
}
]
})
}



module "admin_role" {
for_each = toset(local.admin_users)
Expand All @@ -51,6 +76,7 @@ module "support_role" {
email = "${each.value}@digital.cabinet-office.gov.uk"
role_suffix = "support"
iam_policy_arns = [
aws_iam_policy.lock_state_files.arn
]
ip_restrictions = local.ip_restrictions
}
Expand All @@ -63,6 +89,7 @@ module "readonly_role" {
role_suffix = "readonly"
iam_policy_arns = [
"arn:aws:iam::aws:policy/ReadOnlyAccess",
aws_iam_policy.lock_state_files.arn
]
ip_restrictions = local.ip_restrictions
}
Expand Down
10 changes: 6 additions & 4 deletions infra/modules/engineer-access/policies.tf
Original file line number Diff line number Diff line change
Expand Up @@ -289,24 +289,26 @@ resource "aws_iam_policy" "deny_parameter_store" {
})
}

resource "aws_iam_policy" "release_lock_on_state_files" {
resource "aws_iam_policy" "lock_state_files" {
name = "release-lock-on-state-files"
path = "/"

description = "Allow releasing the lock on state files"
description = "Allow locking state files"

policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Action = [
"s3:GetObject",
"s3:PutObject",
"s3:DeleteObject"
]
Effect = "Allow"
Resource = [
"arn:aws:s3:::gds-forms-${var.environment_type}-tfstate/*.tflock"
"arn:aws:s3:::${var.state_file_bucket_name}/*.tflock"
]
}
]
})
}
}
3 changes: 2 additions & 1 deletion infra/modules/engineer-access/roles.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module "support_role" {
aws_iam_policy.manage_dashboards.arn,
aws_iam_policy.manage_deployments.arn,
aws_iam_policy.manage_maintenance_page.arn,
aws_iam_policy.release_lock_on_state_files.arn,
aws_iam_policy.lock_state_files.arn,
var.allow_rds_data_api_access ? [aws_iam_policy.query_rds_with_data_api[0].arn] : [],
var.allow_ecs_task_usage ? [aws_iam_policy.run_task[0].arn, aws_iam_policy.stop_task[0].arn] : []
])
Expand All @@ -43,6 +43,7 @@ module "readonly_role" {
role_suffix = "readonly"
iam_policy_arns = [
"arn:aws:iam::aws:policy/ReadOnlyAccess",
aws_iam_policy.lock_state_files.arn,
]
ip_restrictions = local.vpn_ip_restrictions
}
Expand Down
7 changes: 6 additions & 1 deletion infra/modules/engineer-access/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,9 @@ variable "allow_rds_data_api_access" {
variable "allow_ecs_task_usage" {
type = bool
description = "Whether appropriate engineer roles should be able to run tasks in AWS ECS"
}
}

variable "state_file_bucket_name" {
type = string
description = "The name of the S3 bucket in which Terraform state files are stored"
}
Loading