Skip to content

Commit 80faa4c

Browse files
authored
feat: add additionals policies parameters (#64)
* feat: add additionals policies parameters * chore: improve variables type
1 parent 42389ef commit 80faa4c

File tree

4 files changed

+25
-5
lines changed

4 files changed

+25
-5
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ Available targets:
145145
|------|-------------|------|---------|:--------:|
146146
| <a name="input_additional_security_group_rules"></a> [additional\_security\_group\_rules](#input\_additional\_security\_group\_rules) | A list of Security Group rule objects to add to the created security group, in addition to the ones<br/>this module normally creates. (To suppress the module's rules, set `create_security_group` to false<br/>and supply your own security group(s) via `associated_security_group_ids`.)<br/>The keys and values of the objects are fully compatible with the `aws_security_group_rule` resource, except<br/>for `security_group_id` which will be ignored, and the optional "key" which, if provided, must be unique and known at "plan" time.<br/>For more info see https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule<br/>and https://github.com/cloudposse/terraform-aws-security-group. | `list(any)` | `[]` | no |
147147
| <a name="input_additional_tag_map"></a> [additional\_tag\_map](#input\_additional\_tag\_map) | Additional key-value pairs to add to each map in `tags_as_list_of_maps`. Not added to `tags` or `id`.<br/>This is for some rare cases where resources want additional configuration of tags<br/>and therefore take a list of maps with tag key, value, and additional configuration. | `map(string)` | `{}` | no |
148+
| <a name="input_additionals_managed_policy_arns"></a> [additionals\_managed\_policy\_arns](#input\_additionals\_managed\_policy\_arns) | List of managed policies to attach to the MWAA IAM role | `list(any)` | `[]` | no |
149+
| <a name="input_additionals_policy_documents"></a> [additionals\_policy\_documents](#input\_additionals\_policy\_documents) | List of JSON IAM policy documents to attach to the MWAA IAM role | `list(any)` | `[]` | no |
148150
| <a name="input_airflow_configuration_options"></a> [airflow\_configuration\_options](#input\_airflow\_configuration\_options) | The Airflow override options | `any` | `null` | no |
149151
| <a name="input_airflow_version"></a> [airflow\_version](#input\_airflow\_version) | Airflow version of the MWAA environment, will be set by default to the latest version that MWAA supports. | `string` | `""` | no |
150152
| <a name="input_allow_all_egress"></a> [allow\_all\_egress](#input\_allow\_all\_egress) | If `true`, the created security group will allow egress on all ports and protocols to all IP addresses.<br/>If this is false and no egress rules are otherwise specified, then no egress will be allowed. | `bool` | `true` | no |

docs/terraform.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
| Name | Source | Version |
1818
|------|--------|---------|
1919
| <a name="module_iam_label"></a> [iam\_label](#module\_iam\_label) | cloudposse/label/null | 0.25.0 |
20-
| <a name="module_mwaa_iam_role"></a> [mwaa\_iam\_role](#module\_mwaa\_iam\_role) | cloudposse/iam-role/aws | 0.16.2 |
20+
| <a name="module_mwaa_iam_role"></a> [mwaa\_iam\_role](#module\_mwaa\_iam\_role) | cloudposse/iam-role/aws | 0.20.0 |
2121
| <a name="module_mwaa_s3_bucket"></a> [mwaa\_s3\_bucket](#module\_mwaa\_s3\_bucket) | cloudposse/s3-bucket/aws | 4.0.0 |
2222
| <a name="module_mwaa_security_group"></a> [mwaa\_security\_group](#module\_mwaa\_security\_group) | cloudposse/security-group/aws | 1.0.1 |
2323
| <a name="module_s3_label"></a> [s3\_label](#module\_s3\_label) | cloudposse/label/null | 0.25.0 |
@@ -39,6 +39,8 @@
3939
|------|-------------|------|---------|:--------:|
4040
| <a name="input_additional_security_group_rules"></a> [additional\_security\_group\_rules](#input\_additional\_security\_group\_rules) | A list of Security Group rule objects to add to the created security group, in addition to the ones<br/>this module normally creates. (To suppress the module's rules, set `create_security_group` to false<br/>and supply your own security group(s) via `associated_security_group_ids`.)<br/>The keys and values of the objects are fully compatible with the `aws_security_group_rule` resource, except<br/>for `security_group_id` which will be ignored, and the optional "key" which, if provided, must be unique and known at "plan" time.<br/>For more info see https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule<br/>and https://github.com/cloudposse/terraform-aws-security-group. | `list(any)` | `[]` | no |
4141
| <a name="input_additional_tag_map"></a> [additional\_tag\_map](#input\_additional\_tag\_map) | Additional key-value pairs to add to each map in `tags_as_list_of_maps`. Not added to `tags` or `id`.<br/>This is for some rare cases where resources want additional configuration of tags<br/>and therefore take a list of maps with tag key, value, and additional configuration. | `map(string)` | `{}` | no |
42+
| <a name="input_additionals_managed_policy_arns"></a> [additionals\_managed\_policy\_arns](#input\_additionals\_managed\_policy\_arns) | List of managed policies to attach to the MWAA IAM role | `list(any)` | `[]` | no |
43+
| <a name="input_additionals_policy_documents"></a> [additionals\_policy\_documents](#input\_additionals\_policy\_documents) | List of JSON IAM policy documents to attach to the MWAA IAM role | `list(any)` | `[]` | no |
4244
| <a name="input_airflow_configuration_options"></a> [airflow\_configuration\_options](#input\_airflow\_configuration\_options) | The Airflow override options | `any` | `null` | no |
4345
| <a name="input_airflow_version"></a> [airflow\_version](#input\_airflow\_version) | Airflow version of the MWAA environment, will be set by default to the latest version that MWAA supports. | `string` | `""` | no |
4446
| <a name="input_allow_all_egress"></a> [allow\_all\_egress](#input\_allow\_all\_egress) | If `true`, the created security group will allow egress on all ports and protocols to all IP addresses.<br/>If this is false and no egress rules are otherwise specified, then no egress will be allowed. | `bool` | `true` | no |

main.tf

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ locals {
1212
security_group_ids = var.create_security_group ? concat(var.associated_security_group_ids, [module.mwaa_security_group.id]) : var.associated_security_group_ids
1313
s3_bucket_arn = var.create_s3_bucket ? module.mwaa_s3_bucket.bucket_arn : var.source_bucket_arn
1414
execution_role_arn = var.create_iam_role ? module.mwaa_iam_role.arn : var.execution_role_arn
15+
iam_policy_documents = concat(
16+
var.additionals_policy_documents,
17+
[data.aws_iam_policy_document.this.json]
18+
)
1519
}
1620

1721
module "s3_label" {
@@ -197,14 +201,14 @@ module "mwaa_iam_role" {
197201

198202
use_fullname = true
199203

200-
policy_documents = [
201-
data.aws_iam_policy_document.this.json,
202-
]
204+
policy_documents = local.iam_policy_documents
203205

204-
policy_document_count = 1
206+
policy_document_count = length(local.iam_policy_documents)
205207
policy_description = "AWS MWAA IAM policy"
206208
role_description = "AWS MWAA IAM role"
207209

210+
managed_policy_arns = var.additionals_managed_policy_arns
211+
208212
context = module.iam_label.context
209213
}
210214

variables.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@ variable "create_iam_role" {
1515
default = true
1616
}
1717

18+
variable "additionals_managed_policy_arns" {
19+
type = list(any)
20+
description = "List of managed policies to attach to the MWAA IAM role"
21+
default = []
22+
}
23+
24+
variable "additionals_policy_documents" {
25+
type = list(any)
26+
description = "List of JSON IAM policy documents to attach to the MWAA IAM role"
27+
default = []
28+
}
29+
1830
variable "source_bucket_arn" {
1931
type = string
2032
description = "If `create_s3_bucket` is `false` then set this to the Amazon Resource Name (ARN) of your Amazon S3 storage bucket."

0 commit comments

Comments
 (0)