diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4cc8829 --- /dev/null +++ b/.gitignore @@ -0,0 +1,30 @@ +# Local .terraform directories +**/.terraform/* + +# .tfstate files +*.tfstate +*.tfstate.* + +# Crash log files +crash.log +# Terraform Lock HCL +.terraform.lock.hcl +# Ignore any .tfvars files that are generated automatically for each Terraform run. Most +# .tfvars files are managed as part of configuration and so should be included in +# version control. +# +# example.tfvars + +# Ignore override files as they are usually used to override resources locally and so +# are not checked in +override.tf +override.tf.json +*_override.tf +*_override.tf.json +.terraform-docs.yml +# Include override files you do wish to add to version control using negated pattern +# +# !example_override.tf + +# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan +# example: *tfplan* diff --git a/README.md b/README.md new file mode 100644 index 0000000..66b2861 --- /dev/null +++ b/README.md @@ -0,0 +1,71 @@ +# Introduction +- This Terraform Stack create **IAM users** and optionally **IAM groups** dynamically in AWS cloud. +## Permissions +- Crate a policy with content below and attach in EC2 IAM Role or IAM User. These permissions are required to works correctly! + +```json +{ + "Version": "2012-10-17", + "Statement": [ + { + "Sid": "", + "Effect": "Allow", + "Action": [ + "iam:CreateGroup", + "iam:AddUserToGroup", + "iam:RemoveUserFromGroup", + "iam:DeleteGroup", + "iam:ListGroupsForUser", + "iam:UpdateGroup", + "iam:DeleteUser", + "iam:GetUser", + "iam:CreateUser", + "iam:GetGroup" + ], + "Resource": "*" + } + ] +} +``` + + +## Requirements + +No requirements. + +## Providers + +| Name | Version | +|------|---------| +| [aws](#provider\_aws) | n/a | + +## Resources + +| Name | Type | +|------|------| +| [aws_iam_group.groups](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_group) | resource | +| [aws_iam_user.users](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user) | resource | +| [aws_iam_user_group_membership.user_to_groups](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_group_membership) | resource | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [access\_key](#input\_access\_key) | AWS Access Key | `string` | n/a | yes | +| [region](#input\_region) | Region where the resources will be created. | `string` | n/a | yes | +| [secret\_key](#input\_secret\_key) | AWS Secret Access Key | `string` | n/a | yes | +| [create\_groups](#input\_create\_groups) | Define if Terraform will create new\_groups based on variable groups. | `bool` | `true` | no | +| [groups](#input\_groups) | List of group names for Terraform create, case create\_groups variable be true | `list(string)` | `[]` | no | +| [users](#input\_users) | Map for Terraform create users. | `map(any)` |
{| no | + + +### This Terraform documentation was generated by [terraform-docs](https://github.com/terraform-docs/terraform-docs). + +## Getting started +```sh +terraform init + +terraform plan + +terraform apply +``` diff --git a/examples/with_new_groups.tf b/examples/with_new_groups.tf new file mode 100644 index 0000000..9c78609 --- /dev/null +++ b/examples/with_new_groups.tf @@ -0,0 +1,17 @@ +module "with_new_groups" { + + source = "../../.." + region = "us-east-1" + access_key = "
"user1": {
"groups": [
"ADM",
"developers"
],
"name": "test",
"path": "/"
}
}