diff --git a/.tflint.hcl b/.tflint.hcl index fcc2fa8..a4029d7 100644 --- a/.tflint.hcl +++ b/.tflint.hcl @@ -1,15 +1,15 @@ config { - module = true - force = false + module = true + force = false disabled_by_default = false -# ignore_module = { -# "terraform-aws-modules/vpc/aws" = true -# "terraform-aws-modules/security-group/aws" = true -# } + # ignore_module = { + # "terraform-aws-modules/vpc/aws" = true + # "terraform-aws-modules/security-group/aws" = true + # } -# varfile = ["example1.tfvars", "example2.tfvars"] -# variables = ["foo=bar", "bar=[\"baz\"]"] + # varfile = ["example1.tfvars", "example2.tfvars"] + # variables = ["foo=bar", "bar=[\"baz\"]"] } rule "aws_instance_invalid_type" { diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e3a7fa..bf80a1b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -93,3 +93,7 @@ * 1.7.1 -- 2026-03-26 - updated policies/sc-developer - add kms:UpdateKeyDescription + +* 1.7.2 -- 2026-04-07 + - created policies + - policies/sc-dbuser diff --git a/policies/sc-dbuser/.terraform.lock.hcl b/policies/sc-dbuser/.terraform.lock.hcl new file mode 100644 index 0000000..32cc8cc --- /dev/null +++ b/policies/sc-dbuser/.terraform.lock.hcl @@ -0,0 +1,25 @@ +# This file is maintained automatically by "terraform init". +# Manual edits may be lost in future updates. + +provider "registry.terraform.io/hashicorp/aws" { + version = "6.37.0" + constraints = ">= 6.0.0" + hashes = [ + "h1:w3z/TApcKD3b/aMZoZZKSxOld4xw+gEtQ1ka6C1UN+4=", + "zh:0427fadb719ed5a32feb09f047539d2348e659056f3b8a8589d34d8f0a95be7a", + "zh:3891c670674aba2125a7ac6d4348cde43646b1b46ce6f829e6f4724091bc0dcd", + "zh:632cb24b7b5790b730b33bcbe9f1a7b75f2644fb52f9d6aaafb0249c9e7601d2", + "zh:6e96ed1f824c2efa9de5b7c22ab3715624ba34c28564a06e9a15e71bc3d3a30b", + "zh:7b8fd86907b659bc45f4a3f42c3c0ccc66925a74e265b01e9e66242c0b2cafef", + "zh:81f9a587deddef4dfcc2101c54ec28a3a554056837f68ebb920c83fe8327b16f", + "zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425", + "zh:a9a38a67cb98d690fec951ec3e133b6836279629db2ed3a0ebf97a5bea58674f", + "zh:b18f60d62e4bd4d466077e09c39259d1a85355f0f00b801fe8aedbc50193d357", + "zh:b7a51bc0faf60d17043b4df1d1b7bb55129eaa4bdeb65ff55f5b00b9b8fee9f7", + "zh:c28c42f91ca3a6b65b3fd3ed6e891fc0fc28d0cb5ab65dea65eda8eec5cea5f3", + "zh:d895ddc04280ed26b6ca64ca05b78caaa7b72c8e167af4093545efbc608d5482", + "zh:f4a56f5157009ef160fbd79105078fe675df479cb73c1b7e1fea2741403a0b67", + "zh:f547d6ca371b96fec97b972fc0c93bcfc23d58e34a9da215b94e9d2aa170fb77", + "zh:f7b0a3cd4adadd3f4b9609a54e651ed5eafa22c196ab229042fc1d0aa0ab8f3a", + ] +} diff --git a/policies/sc-dbuser/README.md b/policies/sc-dbuser/README.md new file mode 100644 index 0000000..33cb3c2 --- /dev/null +++ b/policies/sc-dbuser/README.md @@ -0,0 +1,44 @@ +## Requirements + +| Name | Version | +|------|---------| +| [terraform](#requirement\_terraform) | >= 1.12 | +| [aws](#requirement\_aws) | >= 6.0 | + +## Providers + +| Name | Version | +|------|---------| +| [aws](#provider\_aws) | >= 6.0 | + +## Modules + +No modules. + +## Resources + +| Name | Type | +|------|------| +| [aws_arn.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/arn) | data source | +| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source | +| [aws_iam_policy_document.inline](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source | +| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [account\_alias](#input\_account\_alias) | AWS Account Alias | `string` | `""` | no | +| [account\_id](#input\_account\_id) | AWS Account ID (default will pull from current user) | `string` | `""` | no | +| [override\_prefixes](#input\_override\_prefixes) | Override built-in prefixes by component. This should be used primarily for common infrastructure things | `map(string)` | `{}` | no | +| [tags](#input\_tags) | AWS Tags to apply to appropriate resources | `map(string)` | `{}` | no | + +## Outputs + +| Name | Description | +|------|-------------| +| [customer\_managed\_policy\_names](#output\_customer\_managed\_policy\_names) | Map of policy name to permission boundary of Customer Managed Policy to attach to the permissionset | +| [inline\_policy](#output\_inline\_policy) | AWS Policy document for the single allowed inline policy (use .json to get policy) | +| [managed\_policy\_names](#output\_managed\_policy\_names) | Names of AWS Managed Policy to attach to the permissionset | +| [name](#output\_name) | Permission Set Name for which all settings apply | +| [relay\_state](#output\_relay\_state) | Relay State to pass along to permissionset | diff --git a/policies/sc-dbuser/base_arn.tf b/policies/sc-dbuser/base_arn.tf new file mode 100644 index 0000000..5eba500 --- /dev/null +++ b/policies/sc-dbuser/base_arn.tf @@ -0,0 +1,3 @@ +locals { + all_account_arn_iam = format("arn:%v:%v::%v:%%v", data.aws_arn.current.partition, "iam", "*") +} diff --git a/policies/sc-dbuser/data.tf b/policies/sc-dbuser/data.tf new file mode 120000 index 0000000..37fff16 --- /dev/null +++ b/policies/sc-dbuser/data.tf @@ -0,0 +1 @@ +../../common/data.tf \ No newline at end of file diff --git a/policies/sc-dbuser/defaults.tf b/policies/sc-dbuser/defaults.tf new file mode 120000 index 0000000..1227df3 --- /dev/null +++ b/policies/sc-dbuser/defaults.tf @@ -0,0 +1 @@ +../../common/defaults.tf \ No newline at end of file diff --git a/policies/sc-dbuser/locals.tf b/policies/sc-dbuser/locals.tf new file mode 100644 index 0000000..6aa29cd --- /dev/null +++ b/policies/sc-dbuser/locals.tf @@ -0,0 +1,12 @@ +locals { + account_id = var.account_id != "" ? var.account_id : data.aws_caller_identity.current.account_id + account_environment = data.aws_arn.current.partition == "aws-us-gov" ? "gov" : "ew" + region = data.aws_region.current.region + region_short = join("", [for c in split("-", local.region) : substr(c, 0, 1)]) + + base_tags = { + "boc:tf_module_version" = local._module_version + "boc:tf_module_name" = local._module_name + "boc:created_by" = "terraform" + } +} diff --git a/policies/sc-dbuser/main.tf b/policies/sc-dbuser/main.tf new file mode 100644 index 0000000..3c91f4a --- /dev/null +++ b/policies/sc-dbuser/main.tf @@ -0,0 +1,2 @@ +/* +*/ diff --git a/policies/sc-dbuser/module_name.tf b/policies/sc-dbuser/module_name.tf new file mode 100644 index 0000000..cd0ea8b --- /dev/null +++ b/policies/sc-dbuser/module_name.tf @@ -0,0 +1,3 @@ +locals { + _module_name = "aws-sso/policies/sc-dbuser" +} diff --git a/policies/sc-dbuser/outputs.tf b/policies/sc-dbuser/outputs.tf new file mode 100644 index 0000000..776869b --- /dev/null +++ b/policies/sc-dbuser/outputs.tf @@ -0,0 +1,24 @@ +output "name" { + description = "Permission Set Name for which all settings apply" + value = local.name +} + +output "managed_policy_names" { + description = "Names of AWS Managed Policy to attach to the permissionset" + value = local.managed_policy_names +} + +output "customer_managed_policy_names" { + description = "Map of policy name to permission boundary of Customer Managed Policy to attach to the permissionset" + value = local.customer_managed_policy_names +} + +output "inline_policy" { + description = "AWS Policy document for the single allowed inline policy (use .json to get policy)" + value = local.inline_policy +} + +output "relay_state" { + description = "Relay State to pass along to permissionset" + value = local.relay_state +} diff --git a/policies/sc-dbuser/policy.tf b/policies/sc-dbuser/policy.tf new file mode 100644 index 0000000..1b2c448 --- /dev/null +++ b/policies/sc-dbuser/policy.tf @@ -0,0 +1,18 @@ +data "aws_iam_policy_document" "inline" { + statement { + sid = "AllowRDSDB" + effect = "Allow" + resources = ["*"] + actions = [ + "rds-db:connect", + "rds:DescribeDBInstances", + "rds:DescribeDBClusters", + "rds:DescribeDBInstancesPerformance", + "rds:DescribeDBClustersPerformance", + "pi:DescribeDimensionKeys", + "pi:GetResourceMetrics", + "pi:ListAvailableResourceDimensions", + "pi:ListAvailableResourceMetrics" + ] + } +} diff --git a/policies/sc-dbuser/prefixes.tf b/policies/sc-dbuser/prefixes.tf new file mode 120000 index 0000000..5bc256c --- /dev/null +++ b/policies/sc-dbuser/prefixes.tf @@ -0,0 +1 @@ +../../common/prefixes.tf \ No newline at end of file diff --git a/policies/sc-dbuser/settings.tf b/policies/sc-dbuser/settings.tf new file mode 100644 index 0000000..7e8bede --- /dev/null +++ b/policies/sc-dbuser/settings.tf @@ -0,0 +1,10 @@ +locals { + name = "sc-dbuser" + description = "System Common DB User" + managed_policy_names = [ + "ReadOnlyAccess", + ] + customer_managed_policy_names = {} + relay_state = null + inline_policy = data.aws_iam_policy_document.inline +} diff --git a/policies/sc-dbuser/variables.common.tf b/policies/sc-dbuser/variables.common.tf new file mode 120000 index 0000000..e01226c --- /dev/null +++ b/policies/sc-dbuser/variables.common.tf @@ -0,0 +1 @@ +../../common/variables.common.tf \ No newline at end of file diff --git a/policies/sc-dbuser/variables.tf.unused b/policies/sc-dbuser/variables.tf.unused new file mode 100644 index 0000000..53d6bf1 --- /dev/null +++ b/policies/sc-dbuser/variables.tf.unused @@ -0,0 +1,29 @@ +variable "name" { + description = "Permission Set Name for which all settings apply" + type = string + default = null +} + +variable "managed_policy_names" { + description = "Names of AWS Managed Policy to attach to the permissionset" + type = list(string) + default = [] +} + +variable "customer_managed_policy_names" { + description = "Map of policy name to permission boundary of Customer Managed Policy to attach to the permissionset" + type = map(string) + default = {} +} + +# variable "inline_policy" { +# description = "AWS Policy document for the single allowed inline policy" +# type = string +# default = null +# } + +variable "relay_state" { + description = "Relay State to pass along to permissionset" + type = string + default = null +} diff --git a/policies/sc-dbuser/version.tf b/policies/sc-dbuser/version.tf new file mode 120000 index 0000000..4950c91 --- /dev/null +++ b/policies/sc-dbuser/version.tf @@ -0,0 +1 @@ +../../common/version.tf \ No newline at end of file diff --git a/policies/sc-dbuser/versions.tf b/policies/sc-dbuser/versions.tf new file mode 120000 index 0000000..cbeda73 --- /dev/null +++ b/policies/sc-dbuser/versions.tf @@ -0,0 +1 @@ +../../common/versions.tf \ No newline at end of file