Skip to content

Commit

Permalink
Merge pull request #167 from tablexi/role_attachments
Browse files Browse the repository at this point in the history
Allow roles to be attached to SES policy
  • Loading branch information
jhanggi authored Aug 26, 2020
2 parents 15ec8a6 + 80fe6e3 commit 46d2a1f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 28 deletions.
41 changes: 17 additions & 24 deletions aws/iam/ses_send/main.tf
Original file line number Diff line number Diff line change
@@ -1,31 +1,24 @@
resource "aws_iam_group" "mod" {
name = "ses_senders"
data "aws_iam_policy_document" "mod" {
version = "2012-10-17"
statement {
effect = "Allow"
actions = [
"ses:SendRawEmail",
"ses:SendEmail",
]
resources = ["*"]
}
}

resource "aws_iam_group_policy" "mod" {
resource "aws_iam_policy" "mod" {
name = "AmazonSesSendingAccess"
group = aws_iam_group.mod.id

policy = jsonencode(
{
Statement = [
{
Action = [
"ses:SendRawEmail",
"ses:SendEmail",
]
Effect = "Allow"
Resource = "*"
},
]
Version = "2012-10-17"
}
)
policy = data.aws_iam_policy_document.mod.json
}

resource "aws_iam_group_membership" "mod" {
name = "app-server-group-membership"
users = var.users
group = aws_iam_group.mod.name
resource "aws_iam_policy_attachment" "mod" {
name = "ses-sending-policy-attachment"
users = var.users
roles = var.roles
policy_arn = aws_iam_policy.mod.arn
}

4 changes: 0 additions & 4 deletions aws/iam/ses_send/outputs.tf

This file was deleted.

5 changes: 5 additions & 0 deletions aws/iam/ses_send/variables.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
variable "users" {
type = list(string)
default = []
}

variable "roles" {
type = list(string)
default = []
}

0 comments on commit 46d2a1f

Please sign in to comment.