generated from hackforla/.github-hackforla-base-repo-template
-
-
Notifications
You must be signed in to change notification settings - Fork 12
adding mvp terraform config for aws iam resources #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
8ae9bdc
adding example terraform config for aws iam resources
chelseybeck aeb03b3
adding directory structure
chelseybeck 2da8fa8
updating structure and documentation
chelseybeck ccf2b1a
removing instructions
chelseybeck 9094081
documentation updates
chelseybeck f067626
cleaning up files
chelseybeck 39d27f4
removing pgp key comments
chelseybeck 836b72d
adding terraform-docs to auto generate documentation
chelseybeck 6897401
updating documentation template
chelseybeck 9389e3e
updating docs templates
chelseybeck 3784b59
updating formatting and adding lifecycle parameter
chelseybeck File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module "aws_iam_policies" { | ||
source = "./modules/policies" | ||
policies = { | ||
"ManageAccessKeys" = { | ||
description = "Policy for creating, listing, and updating Access Keys" | ||
filename = "manage-access-keys-policy.json" | ||
}, | ||
"FullAccessPolicy" = { | ||
description = "Full access to specific resources" | ||
filename = "full-access-policy.json" | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
terraform/aws-custom-policies/existing-policies/manage-access-keys-policy.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Sid": "ListUsersForConsole", | ||
"Effect": "Allow", | ||
"Action": "iam:ListUsers", | ||
"Resource": "arn:aws:iam::*:*" | ||
}, | ||
{ | ||
"Sid": "ViewAndUpdateAccessKeys", | ||
"Effect": "Allow", | ||
"Action": [ | ||
"iam:UpdateAccessKey", | ||
"iam:CreateAccessKey", | ||
"iam:ListAccessKeys" | ||
], | ||
"Resource": "arn:aws:iam::*:user/*" | ||
} | ||
] | ||
} |
46 changes: 46 additions & 0 deletions
46
terraform/aws-custom-policies/existing-policies/self-manage-credentials-policy.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{ | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Sid": "AllowViewAccountInfo", | ||
"Effect": "Allow", | ||
"Action": [ | ||
"iam:GetAccountPasswordPolicy", | ||
"iam:GetAccountSummary" | ||
], | ||
"Resource": "*" | ||
}, | ||
{ | ||
"Sid": "AllowManageOwnPasswords", | ||
"Effect": "Allow", | ||
"Action": [ | ||
"iam:ChangePassword", | ||
"iam:GetUser" | ||
], | ||
"Resource": "arn:aws:iam::*:user/${aws:username}" | ||
}, | ||
{ | ||
"Sid": "AllowManageOwnAccessKeys", | ||
"Effect": "Allow", | ||
"Action": [ | ||
"iam:CreateAccessKey", | ||
"iam:DeleteAccessKey", | ||
"iam:ListAccessKeys", | ||
"iam:UpdateAccessKey" | ||
], | ||
"Resource": "arn:aws:iam::*:user/${aws:username}" | ||
}, | ||
{ | ||
"Sid": "AllowManageOwnSSHPublicKeys", | ||
"Effect": "Allow", | ||
"Action": [ | ||
"iam:DeleteSSHPublicKey", | ||
"iam:GetSSHPublicKey", | ||
"iam:ListSSHPublicKeys", | ||
"iam:UpdateSSHPublicKey", | ||
"iam:UploadSSHPublicKey" | ||
], | ||
"Resource": "arn:aws:iam::*:user/${aws:username}" | ||
} | ||
] | ||
} |
27 changes: 27 additions & 0 deletions
27
terraform/aws-custom-policies/existing-policies/terraform-policy.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Sid": "VisualEditor0", | ||
"Effect": "Allow", | ||
"Action": [ | ||
"elasticloadbalancing:DescribeTargetGroupAttributes", | ||
"elasticloadbalancing:DescribeTags", | ||
"s3:ListAllMyBuckets", | ||
"ecr:GetRegistryScanningConfiguration" | ||
], | ||
"Resource": "*" | ||
}, | ||
{ | ||
"Sid": "RDS", | ||
"Effect": "Allow", | ||
"Action": [ | ||
"rds:DescribeDBInstances", | ||
"rds:DescribeDBClusters", | ||
"rds:DescribeGlobalClusters", | ||
"rds:DescribeDBInstances" | ||
], | ||
"Resource": "*" | ||
} | ||
] | ||
} |
46 changes: 46 additions & 0 deletions
46
terraform/aws-custom-policies/existing-policies/terragrunt-s3-permissions-policy.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{ | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Sid": "AllowViewAccountInfo", | ||
"Effect": "Allow", | ||
"Action": [ | ||
"iam:GetAccountPasswordPolicy", | ||
"iam:GetAccountSummary" | ||
], | ||
"Resource": "*" | ||
}, | ||
{ | ||
"Sid": "AllowManageOwnPasswords", | ||
"Effect": "Allow", | ||
"Action": [ | ||
"iam:ChangePassword", | ||
"iam:GetUser" | ||
], | ||
"Resource": "arn:aws:iam::*:user/${aws:username}" | ||
}, | ||
{ | ||
"Sid": "AllowManageOwnAccessKeys", | ||
"Effect": "Allow", | ||
"Action": [ | ||
"iam:CreateAccessKey", | ||
"iam:DeleteAccessKey", | ||
"iam:ListAccessKeys", | ||
"iam:UpdateAccessKey" | ||
], | ||
"Resource": "arn:aws:iam::*:user/${aws:username}" | ||
}, | ||
{ | ||
"Sid": "AllowManageOwnSSHPublicKeys", | ||
"Effect": "Allow", | ||
"Action": [ | ||
"iam:DeleteSSHPublicKey", | ||
"iam:GetSSHPublicKey", | ||
"iam:ListSSHPublicKeys", | ||
"iam:UpdateSSHPublicKey", | ||
"iam:UploadSSHPublicKey" | ||
], | ||
"Resource": "arn:aws:iam::*:user/${aws:username}" | ||
} | ||
] | ||
} |
27 changes: 27 additions & 0 deletions
27
terraform/aws-custom-policies/level-2-project-admin-policy.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Sid": "", | ||
"Effect": "", | ||
"Action": [ | ||
"", | ||
"", | ||
"", | ||
"" | ||
], | ||
"Resource": "" | ||
}, | ||
{ | ||
"Sid": "", | ||
"Effect": "", | ||
"Action": [ | ||
"", | ||
"", | ||
"", | ||
"" | ||
], | ||
"Resource": "" | ||
} | ||
] | ||
} |
27 changes: 27 additions & 0 deletions
27
terraform/aws-custom-policies/level-3-ops-mentor-policy.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Sid": "", | ||
"Effect": "", | ||
"Action": [ | ||
"", | ||
"", | ||
"", | ||
"" | ||
], | ||
"Resource": "" | ||
}, | ||
{ | ||
"Sid": "", | ||
"Effect": "", | ||
"Action": [ | ||
"", | ||
"", | ||
"", | ||
"" | ||
], | ||
"Resource": "" | ||
} | ||
] | ||
} |
27 changes: 27 additions & 0 deletions
27
terraform/aws-custom-policies/level-4-iam-services-admin-policy.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Sid": "", | ||
"Effect": "", | ||
"Action": [ | ||
"", | ||
"", | ||
"", | ||
"" | ||
], | ||
"Resource": "" | ||
}, | ||
{ | ||
"Sid": "", | ||
"Effect": "", | ||
"Action": [ | ||
"", | ||
"", | ||
"", | ||
"" | ||
], | ||
"Resource": "" | ||
} | ||
] | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Create groups and attach policies | ||
module "iam_read_only_group" { | ||
source = "./modules/groups" | ||
|
||
group_name = "read-only-group" | ||
policy_arn = "arn:aws:iam::aws:policy/ReadOnlyAccess" | ||
} | ||
|
||
module "iam_project_admin_group" { | ||
source = "./modules/groups" | ||
|
||
group_name = "project-admin-group" | ||
policy_arn = [ # here we can pass a list of policies that are aws managed or customer managed | ||
"arn:aws:iam::aws:policy/SomeAWSPolicy", | ||
module.iam_policies.policy_arns["ManageAccessKeys"] | ||
] | ||
} | ||
|
||
module "iam_ops_mentor_group" { | ||
source = "./modules/groups" | ||
|
||
group_name = "project-admin-group" | ||
policy_arn = [ # here we can pass a list of policies that are aws managed or customer managed | ||
"arn:aws:iam::aws:policy/SomeAWSPolicy", | ||
"arn:aws:iam::aws:policy/SomeAWSPolicy", | ||
"arn:aws:iam::aws:policy/SomeAWSPolicy", | ||
"arn:aws:iam::aws:policy/SomeAWSPolicy", | ||
] | ||
} | ||
|
||
// Assign users to groups | ||
resource "aws_iam_group_membership" "project_admin_group_membership" { | ||
name = "project_admin_group_membership" # A unique name for the group membership | ||
|
||
users = [ | ||
module.iam_user_gwenstacy.user_name, | ||
module.iam_user_miles_morales.user_name, | ||
"chelseybeck" | ||
] | ||
|
||
group = module.iam_project_admin_group.group_name | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module "iam_user_gwenstacy" { | ||
source = "./modules/users" | ||
|
||
user_name = "gwenstacy" | ||
user_tags = { | ||
"Environment" = "Development" | ||
"Project" = "spiderverse" | ||
} | ||
pgp_key = "user_provided_public_key_here" | ||
chelseybeck marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
module "iam_user_milesmorales" { | ||
source = "./modules/users" | ||
|
||
user_name = "miles_morales" | ||
user_tags = { | ||
"Environment" = "Production" | ||
"Project" = "spiderverse" | ||
} | ||
pgp_key = "user_provided_public_key_here" | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
terraform { | ||
backend "s3" { | ||
bucket = "my-terraform-state-bucket" # Replace with S3 bucket name | ||
key = "path/to/terraform.tfstate" # Path to the state file within the bucket | ||
region = "us-west-2" # AWS region of the S3 bucket | ||
dynamodb_table = "my-terraform-state-lock" # DynamoDB table name for state locking | ||
encrypt = true | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# groups/main.tf | ||
|
||
resource "aws_iam_group" "group" { | ||
name = var.group_name | ||
path = var.group_path | ||
} | ||
|
||
# Attaching policies to the group | ||
resource "aws_iam_group_policy_attachment" "group_policy_attachment" { | ||
for_each = toset(var.policy_arns) | ||
group = aws_iam_group.group.name | ||
policy_arn = each.value | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# groups/outputs.tf | ||
|
||
output "group_name" { | ||
value = aws_iam_group.group.name | ||
description = "The name of the IAM group" | ||
} | ||
|
||
output "group_arn" { | ||
value = aws_iam_group.group.arn | ||
description = "The ARN of the IAM group" | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# groups/variables.tf | ||
|
||
variable "group_name" { | ||
description = "The name of the IAM group" | ||
type = string | ||
} | ||
|
||
variable "group_path" { | ||
description = "Path in which to create the group" | ||
type = string | ||
default = "/" | ||
} | ||
|
||
variable "policy_arn" { | ||
description = "The ARN of the policy to attach to the group" | ||
type = string | ||
} | ||
|
||
variable "policy_arns" { | ||
description = "List of policy ARNs to attach to the group" | ||
type = list(string) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# policies/main.tf | ||
|
||
resource "aws_iam_policy" "custom_policy" { | ||
for_each = var.policies | ||
|
||
name = each.key | ||
description = each.value["description"] | ||
policy = file("${path.module}/policies-json/${each.value["filename"]}") | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.