123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- resource "aws_iam_policy" "mdradmin_tfstate_setup" {
- name = "mdradmmin_tfstate_setup"
- path = "/bootstrap/"
- description = "Gives MDRAdmin account rights needed to set up tfstate management"
- policy = data.aws_iam_policy_document.mdradmin_tfstate_setup.json
- }
- data "aws_iam_policy_document" "mdradmin_tfstate_setup" {
- # checkov:skip=CKV_AWS_111: see tfsec aws-iam-no-policy-wildcard ignore comment
- # tfsec:ignore:aws-iam-no-policy-wildcards - baseline this setting first. We use wildcards in policies
- statement {
- sid = "DynamoDBTablesAndLocking"
- actions = [
- "dynamodb:*"
- ]
- resources = [
- "arn:${local.aws_partition}:dynamodb:${local.aws_region}:${local.aws_account}:table/${var.lock_table_name}"
- ]
- condition {
- test = "BoolIfExists"
- variable = "aws:MultiFactorAuthPresent"
- values = [
- true
- ]
- }
- }
- # tfsec:ignore:aws-iam-no-policy-wildcards - baseline this setting first. We use wildcards in policies
- statement {
- sid = "DynamoDBTablesAndLocking2"
- actions = [
- "dynamodb:ListTables"
- ]
- resources = [
- "arn:${local.aws_partition}:dynamodb:${local.aws_region}:${local.aws_account}:table/*"
- ]
- condition {
- test = "BoolIfExists"
- variable = "aws:MultiFactorAuthPresent"
- values = [
- true
- ]
- }
- }
- # tfsec:ignore:aws-iam-no-policy-wildcards - baseline this setting first. We use wildcards in policies
- statement {
- sid = "KMSKeyCreate"
- actions = [
- "kms:CreateAlias",
- "kms:CreateKey",
- "kms:List*",
- "kms:DeleteAlias",
- "kms:DeleteKey"
- ]
- # I wish I could scope this down to just specific keys
- # But I don't think it's possible
- resources = [
- "*"
- ]
- condition {
- test = "BoolIfExists"
- variable = "aws:MultiFactorAuthPresent"
- values = [
- true
- ]
- }
- }
- # tfsec:ignore:aws-iam-no-policy-wildcards - baseline this setting first. We use wildcards in policies
- statement {
- sid = "S3ManageStateBucket"
- actions = [
- "s3:CreateBucket",
- "s3:DeleteBucket",
- "s3:ListBucket",
- "s3:Get*",
- "s3:Put*"
- ]
- resources = [
- "arn:${local.aws_partition}:s3:::${var.bucket_name}"
- ]
- condition {
- test = "BoolIfExists"
- variable = "aws:MultiFactorAuthPresent"
- values = [
- true
- ]
- }
- }
- # tfsec:ignore:aws-iam-no-policy-wildcards - baseline this setting first. We use wildcards in policies
- statement {
- sid = "S3ObjectOperations"
- actions = [
- "s3:PutObject*",
- "s3:GetObject*",
- "s3:DeleteObject*"
- ]
- resources = [
- "arn:${local.aws_partition}:s3:::${var.bucket_name}/*"
- ]
- condition {
- test = "BoolIfExists"
- variable = "aws:MultiFactorAuthPresent"
- values = [
- true
- ]
- }
- }
- }
|