Skip to content

Commit

Permalink
Refactoring IAM Modules
Browse files Browse the repository at this point in the history
  • Loading branch information
Weyder Ferreira committed Jan 5, 2023
1 parent cf70be2 commit 898e5b0
Show file tree
Hide file tree
Showing 41 changed files with 466 additions and 154 deletions.
10 changes: 0 additions & 10 deletions iam/group/vars.tf

This file was deleted.

37 changes: 37 additions & 0 deletions iam/groups/group/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!-- BEGIN_TF_DOCS -->
## Requirements

No requirements.

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | n/a |

## Modules

No modules.

## Resources

| Name | Type |
|------|------|
| [aws_iam_group.group](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_group) | resource |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_name"></a> [name](#input\_name) | (Required) The group's name. The name must consist of upper and lowercase alphanumeric characters with no spaces. You can also include any of the following characters: =,.@-\_.. Group names are not distinguished by case. For example, you cannot create groups named both ADMINS and admins. | `string` | `null` | no |
| <a name="input_path"></a> [path](#input\_path) | (Optional, default /) Path in which to create the group. | `string` | `"/"` | no |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_arn"></a> [arn](#output\_arn) | n/a |
| <a name="output_id"></a> [id](#output\_id) | n/a |
| <a name="output_name"></a> [name](#output\_name) | n/a |
| <a name="output_path"></a> [path](#output\_path) | n/a |
<!-- END_TF_DOCS -->
4 changes: 2 additions & 2 deletions iam/group/main.tf → iam/groups/group/main.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
resource "aws_iam_group" "group" {

name = var.name
path = var.path

}
File renamed without changes.
10 changes: 10 additions & 0 deletions iam/groups/group/vars.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
variable "name" {
type = string
default = null
description = " (Required) The group's name. The name must consist of upper and lowercase alphanumeric characters with no spaces. You can also include any of the following characters: =,.@-_.. Group names are not distinguished by case. For example, you cannot create groups named both ADMINS and admins."
}
variable "path" {
type = string
default = "/"
description = "(Optional, default /) Path in which to create the group."
}
33 changes: 33 additions & 0 deletions iam/policies/policy-document/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!-- BEGIN_TF_DOCS -->
## Requirements

No requirements.

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | n/a |

## Modules

No modules.

## Resources

| Name | Type |
|------|------|
| [aws_iam_policy_document.policy_document](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy_document) | resource |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_statement"></a> [statement](#input\_statement) | (Required) - Statement definitions. | `list(object({ actions = list(string), effect = list(string), resources = list(string), sid = string }))` | n/a | yes |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_json"></a> [json](#output\_json) | The Policy Name |
<!-- END_TF_DOCS -->
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
resource "aws_iam_policy_document" "policy_document" {
dynamic "statement" {
for_each = var.statement
for_each = var.statement
content {
actions = statement.value.actions
effect = statement.value.effect
Expand Down
4 changes: 4 additions & 0 deletions iam/policies/policy-document/outuputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
output "json" {
description = "The Policy Name"
value = aws_iam_policy_document.policy_document.json
}
File renamed without changes.
40 changes: 40 additions & 0 deletions iam/policies/policy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!-- BEGIN_TF_DOCS -->
## Requirements

No requirements.

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | n/a |

## Modules

No modules.

## Resources

| Name | Type |
|------|------|
| [aws_iam_policy.policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_description"></a> [description](#input\_description) | (Optional, Forces new resource) Description of the IAM policy. | `string` | `null` | no |
| <a name="input_name"></a> [name](#input\_name) | (Optional, Forces new resource) The name of the policy. If omitted, Terraform will assign a random, unique name. | `string` | `null` | no |
| <a name="input_path"></a> [path](#input\_path) | (Optional, default /) Path in which to create the policy. See IAM Identifiers for more information. | `string` | `"/"` | no |
| <a name="input_policy"></a> [policy](#input\_policy) | (Required) The policy document. This is a JSON formatted string. | `any` | n/a | yes |
| <a name="input_tags"></a> [tags](#input\_tags) | The TAG list | `map(string)` | `{}` | no |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_arn"></a> [arn](#output\_arn) | The ARN assigned by AWS to this policy |
| <a name="output_description"></a> [description](#output\_description) | The porpouse of these policy |
| <a name="output_name"></a> [name](#output\_name) | The Policy Name |
| <a name="output_path"></a> [path](#output\_path) | The path of the policy in IAM |
<!-- END_TF_DOCS -->
File renamed without changes.
8 changes: 4 additions & 4 deletions iam/policy/outuputs.tf → iam/policies/policy/outuputs.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
output "name" {
description = "The Policy Name"
value = aws_iam_policy.policy.name
description = "The Policy Name"
value = aws_iam_policy.policy.name
}

output "description" {
description = "The porpouse of these policy"
value = aws_iam_policy.policy.description
description = "The porpouse of these policy"
value = aws_iam_policy.policy.description
}

output "arn" {
Expand Down
23 changes: 23 additions & 0 deletions iam/policies/policy/vars.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
variable "name" {
type = string
default = null
description = "(Optional, Forces new resource) The name of the policy. If omitted, Terraform will assign a random, unique name."
}
variable "path" {
type = string
default = "/"
description = "(Optional, default /) Path in which to create the policy. See IAM Identifiers for more information."
}
variable "description" {
type = string
default = null
description = "(Optional, Forces new resource) Description of the IAM policy."
}
variable "policy" {
description = "(Required) The policy document. This is a JSON formatted string. "
}
variable "tags" {
type = map(string)
default = {}
description = "The TAG list"
}
23 changes: 0 additions & 23 deletions iam/policy/vars.tf

This file was deleted.

4 changes: 0 additions & 4 deletions iam/policy_document/outuputs.tf

This file was deleted.

15 changes: 0 additions & 15 deletions iam/role/main.tf

This file was deleted.

11 changes: 0 additions & 11 deletions iam/role/outputs.tf

This file was deleted.

49 changes: 0 additions & 49 deletions iam/role/vars.tf

This file was deleted.

6 changes: 6 additions & 0 deletions iam/roles/instance-profile/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
resource "aws_iam_instance_profile" "instance_profile" {
name = var.name
path = var.path
role = var.role
tags = var.tags
}
16 changes: 16 additions & 0 deletions iam/roles/instance-profile/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
output "arn" {
value = aws_iam_instance_profile.instance_profile.arn
}
output "create_date" {
value = aws_iam_instance_profile.instance_profile.create_date
}
output "id" {
value = aws_iam_instance_profile.instance_profile.id
}

output "unique_id" {
value = aws_iam_instance_profile.instance_profile.unique_id
}



23 changes: 23 additions & 0 deletions iam/roles/instance-profile/vars.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
variable "name" {
type = string
default = null
description = "(Optional, Forces new resource) Name of the instance profile. If omitted, Terraform will assign a random, unique name. Can be a string of characters consisting of upper and lowercase alphanumeric characters and these special characters: _, +, =, ,, ., @, -. Spaces are not allowed."
}

variable "path" {
type = string
default = "/"
description = "(Optional, default \"/\") Path to the instance profile. For more information about paths, see IAM Identifiers in the IAM User Guide. Can be a string of characters consisting of either a forward slash (/) by itself or a string that must begin and end with forward slashes. Can include any ASCII character from the ! (\u0021) through the DEL character (\u007F), including most punctuation characters, digits, and upper and lowercase letters."
}

variable "role" {
type = string
default = null
description = "(Optional) Name of the role to add to the profile."
}

variable "tags" {
type = map(string)
default = {}
description = "The list of Tags"
}
6 changes: 6 additions & 0 deletions iam/roles/instance_profile/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
resource "aws_iam_instance_profile" "instance_profile" {
name = var.name
path = var.path
role = var.role
tags = var.tags
}
16 changes: 16 additions & 0 deletions iam/roles/instance_profile/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
output "arn" {
value = aws_iam_instance_profile.instance_profile.arn
}
output "create_date" {
value = aws_iam_instance_profile.instance_profile.create_date
}
output "id" {
value = aws_iam_instance_profile.instance_profile.id
}

output "unique_id" {
value = aws_iam_instance_profile.instance_profile.unique_id
}



Loading

0 comments on commit 898e5b0

Please sign in to comment.