Skip to content

Commit c62b899

Browse files
committed
feat: add access analyzer
1 parent dd64232 commit c62b899

File tree

10 files changed

+90
-2
lines changed

10 files changed

+90
-2
lines changed

.github/.templatesyncignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@ README.md
22
.github/workflows/*
33
.terraform-docs.yml
44
docs/20-badges.md
5+
docs/assets/logo.svg
56
*.tf
7+
test/*
8+
go.mod
9+
go.sum

.pre-commit-config.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
repos:
22
- repo: https://github.com/antonbabenko/pre-commit-terraform
3-
rev: v1.76.0
3+
rev: v1.80.0
44
hooks:
55
- id: terraform_docs
66
- id: terraform_fmt
77
- id: terraform_validate
8+
args:
9+
- --hook-config=--retry-once-with-cleanup=true
810
exclude: '^[^/]+$'
911
- id: terraform_tflint
1012
exclude: ^examples/
1113

1214
- repo: https://github.com/pre-commit/pre-commit-hooks
13-
rev: v4.3.0
15+
rev: v4.4.0
1416
hooks:
1517
- id: trailing-whitespace
1618
- id: end-of-file-fixer

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ each module for more information. All modules are enabled by default.
4343
| Name | Description | Type | Default | Required |
4444
|------|-------------|------|---------|:--------:|
4545
| <a name="input_enable_cloudwatch_defaults"></a> [enable\_cloudwatch\_defaults](#input\_enable\_cloudwatch\_defaults) | Enable the Cloudwatch submodule. | `bool` | `true` | no |
46+
| <a name="input_enable_iam_access_analyzer"></a> [enable\_iam\_access\_analyzer](#input\_enable\_iam\_access\_analyzer) | Enable the IAM Access Analyzer submodule. | `bool` | `true` | no |
4647
| <a name="input_enable_iam_account_password_policy"></a> [enable\_iam\_account\_password\_policy](#input\_enable\_iam\_account\_password\_policy) | Enable the IAM Account Password Policy submodule. | `bool` | `true` | no |
4748
| <a name="input_enable_s3_defaults"></a> [enable\_s3\_defaults](#input\_enable\_s3\_defaults) | Enable the S3 submodule. | `bool` | `true` | no |
4849

main.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,8 @@ module "iam_account_password_policy" {
1818
count = var.enable_iam_account_password_policy ? 1 : 0
1919
source = "./modules/iam_password_policy"
2020
}
21+
22+
module "iam_access_analyzer" {
23+
count = var.enable_iam_access_analyzer ? 1 : 0
24+
source = "./modules/iam_access_analyzer"
25+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
content: |-
2+
{{ .Header }}
3+
4+
{{ .Inputs }}
5+
6+
{{ .Outputs }}
7+
8+
{{ .Providers }}
9+
10+
## Resources
11+
{{ range .Module.Resources }}
12+
- {{ .GetMode }}.{{ .Spec }} ({{ .Position.Filename }}#{{ .Position.Line }})
13+
{{- end }}

modules/iam_access_analyzer/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<!-- BEGIN_TF_DOCS -->
2+
# Terraform AWS Account Defaults Access Analyzer
3+
4+
Creates an AWS Access Analyzer for the account or organization.
5+
6+
## Inputs
7+
8+
| Name | Description | Type | Default | Required |
9+
|------|-------------|------|---------|:--------:|
10+
| <a name="input_access_analyzer_name"></a> [access\_analyzer\_name](#input\_access\_analyzer\_name) | The name of the analyzer. | `string` | `"account-default"` | no |
11+
| <a name="input_access_analyzer_type"></a> [access\_analyzer\_type](#input\_access\_analyzer\_type) | The type of analyzer, ACCOUNT or ORGANIZATION. | `string` | `"ACCOUNT"` | no |
12+
13+
## Outputs
14+
15+
No outputs.
16+
17+
## Providers
18+
19+
| Name | Version |
20+
|------|---------|
21+
| <a name="provider_aws"></a> [aws](#provider\_aws) | ~> 4.0 |
22+
23+
## Resources
24+
25+
- resource.aws_accessanalyzer_analyzer.main (modules/iam_access_analyzer/main.tf#6)
26+
<!-- END_TF_DOCS -->

modules/iam_access_analyzer/main.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* # Terraform AWS Account Defaults Access Analyzer
3+
*
4+
* Creates an AWS Access Analyzer for the account or organization.
5+
*/
6+
resource "aws_accessanalyzer_analyzer" "main" {
7+
analyzer_name = var.access_analyzer_name
8+
type = var.access_analyzer_type
9+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
variable "access_analyzer_name" {
2+
description = "The name of the analyzer."
3+
default = "account-default"
4+
type = string
5+
}
6+
7+
variable "access_analyzer_type" {
8+
description = "The type of analyzer, ACCOUNT or ORGANIZATION."
9+
default = "ACCOUNT"
10+
type = string
11+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
terraform {
2+
required_version = ">= 1.3"
3+
4+
required_providers {
5+
aws = {
6+
source = "hashicorp/aws"
7+
version = "~> 4.0"
8+
}
9+
}
10+
}

variables.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,10 @@ variable "enable_iam_account_password_policy" {
1818
default = true
1919
type = bool
2020
}
21+
22+
## IAM ACCESS ANALYZER
23+
variable "enable_iam_access_analyzer" {
24+
description = "Enable the IAM Access Analyzer submodule."
25+
default = true
26+
type = bool
27+
}

0 commit comments

Comments
 (0)