-
Notifications
You must be signed in to change notification settings - Fork 8
/
main.tf
138 lines (129 loc) · 3.83 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# Variables
###################################
variable "external_id" {
type = string
description = "ProwlerPro IAM Role External ID - Please input your External ID here below"
}
##### PLEASE, DO NOT EDIT BELOW THIS LINE #####
# Terraform Provider Configuration
###################################
terraform {
required_version = ">= 1.5.0"
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.10"
}
}
}
provider "aws" {
region = "us-east-1"
}
data "aws_partition" "current" {}
# IAM Role
###################################
data "aws_iam_policy_document" "prowler_pro_saas_assume_role_policy" {
statement {
actions = ["sts:AssumeRole"]
principals {
type = "AWS"
identifiers = ["arn:aws:iam::232136659152:root"]
}
condition {
test = "StringEquals"
variable = "sts:ExternalId"
values = [
var.external_id,
]
}
condition {
test = "StringLike"
variable = "aws:PrincipalArn"
values = [
"arn:aws:iam::232136659152:role/prowler-pro-saas*"
]
}
}
}
data "aws_iam_policy_document" "prowler_pro_saas_role_policy" {
statement {
effect = "Allow"
actions = [
"account:Get*",
"appstream:Describe*",
"appstream:List*",
"backup:List*",
"backup:Get*",
"bedrock:List*",
"bedrock:Get*",
"cloudtrail:GetInsightSelectors",
"codeartifact:List*",
"codebuild:BatchGet*",
"codebuild:ListReportGroups",
"cognito-idp:GetUserPoolMfaConfig",
"dlm:Get*",
"drs:Describe*",
"ds:Get*",
"ds:Describe*",
"ds:List*",
"dynamodb:GetResourcePolicy",
"ec2:GetEbsEncryptionByDefault",
"ec2:GetSnapshotBlockPublicAccessState",
"ec2:GetInstanceMetadataDefaults",
"ecr:Describe*",
"ecr:GetRegistryScanningConfiguration",
"elasticfilesystem:DescribeBackupPolicy",
"glue:GetConnections",
"glue:GetSecurityConfiguration*",
"glue:SearchTables",
"glue:GetMLTransforms",
"lambda:GetFunction*",
"logs:FilterLogEvents",
"lightsail:GetRelationalDatabases",
"macie2:GetMacieSession",
"macie2:GetAutomatedDiscoveryConfiguration",
"s3:GetAccountPublicAccessBlock",
"servicecatalog:Describe*",
"servicecatalog:List*",
"shield:DescribeProtection",
"shield:GetSubscriptionState",
"securityhub:BatchImportFindings",
"securityhub:GetFindings",
"ssm:GetDocument",
"ssm-incidents:List*",
"support:Describe*",
"tag:GetTagKeys",
"wellarchitected:List*"
]
resources = ["*"]
}
}
data "aws_iam_policy_document" "prowler_pro_saas_role_apigw_policy" {
statement {
effect = "Allow"
actions = [
"apigateway:GET"
]
resources = ["arn:${data.aws_partition.current.partition}:apigateway:*::/restapis/*", "arn:${data.aws_partition.current.partition}:apigateway:*::/apis/*"]
}
}
resource "aws_iam_role" "prowler_pro_saas_role" {
name = "ProwlerProSaaSScanRole"
assume_role_policy = data.aws_iam_policy_document.prowler_pro_saas_assume_role_policy.json
managed_policy_arns = ["arn:${data.aws_partition.current.partition}:iam::aws:policy/SecurityAudit", "arn:${data.aws_partition.current.partition}:iam::aws:policy/job-function/ViewOnlyAccess"]
inline_policy {
name = "prowler-pro-saas-role-additional-view-privileges"
policy = data.aws_iam_policy_document.prowler_pro_saas_role_policy.json
}
inline_policy {
name = "prowler-pro-saas-role-apigateway-view-privileges"
policy = data.aws_iam_policy_document.prowler_pro_saas_role_apigw_policy.json
}
tags = tomap({
"Name" = "ProwlerProSaaSScanRole",
"Terraform" = "true",
"Service" = "https://prowler.pro",
"Support" = "[email protected]"
"Version" = "1.0.1"
})
}