File tree Expand file tree Collapse file tree 3 files changed +87
-1
lines changed Expand file tree Collapse file tree 3 files changed +87
-1
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,9 @@ locals {
1111 # using an aws_iam_policy resource and then map it to the name you want to use in the
1212 # YAML configuration by adding an entry in `custom_policy_map`.
1313 supplied_custom_policy_map = {
14- eks_viewer = try (aws_iam_policy. eks_viewer [0 ]. arn , null )
14+ eks_viewer = try (aws_iam_policy. eks_viewer [0 ]. arn , null )
15+ vpn_planner = try (aws_iam_policy. vpn_planner [0 ]. arn , null )
16+ kms_planner = try (aws_iam_policy. kms_planner [0 ]. arn , null )
1517 }
1618 custom_policy_map = merge (local. supplied_custom_policy_map , local. overridable_additional_custom_policy_map )
1719
Original file line number Diff line number Diff line change 1+ locals {
2+ kms_planner_enabled = contains (local. configured_policies , " kms_planner" )
3+ }
4+
5+ data "aws_iam_policy_document" "kms_planner_access" {
6+ count = local. kms_planner_enabled ? 1 : 0
7+
8+ statement {
9+ sid = " AllowKMSDecrypt"
10+ effect = " Allow"
11+
12+ actions = [
13+ " kms:Decrypt" ,
14+ ]
15+
16+ # Only allow decryption of SSM parameters.
17+ # To further restrict to specific parameters, add conditions on the value of
18+ # kms:EncryptionContext:PARAMETER_ARN
19+ # See https://docs.aws.amazon.com/kms/latest/developerguide/services-parameter-store.html#parameter-store-encryption-context
20+ condition {
21+ test = " Null"
22+ variable = " kms:EncryptionContext:PARAMETER_ARN"
23+ values = [" false" ]
24+ }
25+
26+ resources = [
27+ " *"
28+ ]
29+ }
30+
31+ }
32+
33+ data "aws_iam_policy_document" "kms_planner_access_aggregated" {
34+ count = local. kms_planner_enabled ? 1 : 0
35+
36+ source_policy_documents = [
37+ data . aws_iam_policy_document . kms_planner_access [0 ]. json ,
38+ ]
39+ }
40+
41+ resource "aws_iam_policy" "kms_planner" {
42+ count = local. kms_planner_enabled ? 1 : 0
43+
44+ name = format (" %s-kms_planner" , module. this . id )
45+ policy = data. aws_iam_policy_document . kms_planner_access_aggregated [0 ]. json
46+
47+ tags = module. this . tags
48+ }
Original file line number Diff line number Diff line change 1+ locals {
2+ vpn_planner_enabled = contains (local. configured_policies , " vpn_planner" )
3+ }
4+
5+ data "aws_iam_policy_document" "vpn_planner_access" {
6+ count = local. vpn_planner_enabled ? 1 : 0
7+
8+ statement {
9+ sid = " AllowVPNReader"
10+ effect = " Allow"
11+ actions = [
12+ " ec2:ExportClientVpnClientConfiguration" ,
13+ ]
14+ resources = [
15+ " *"
16+ ]
17+ }
18+
19+ }
20+
21+ data "aws_iam_policy_document" "vpn_planner_access_aggregated" {
22+ count = local. vpn_planner_enabled ? 1 : 0
23+
24+ source_policy_documents = [
25+ data . aws_iam_policy_document . vpn_planner_access [0 ]. json ,
26+ ]
27+ }
28+
29+ resource "aws_iam_policy" "vpn_planner" {
30+ count = local. vpn_planner_enabled ? 1 : 0
31+
32+ name = format (" %s-vpn_planner" , module. this . id )
33+ policy = data. aws_iam_policy_document . vpn_planner_access_aggregated [0 ]. json
34+
35+ tags = module. this . tags
36+ }
You can’t perform that action at this time.
0 commit comments