Skip to content

TECH-378: Remove old IAM resources #8

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 3 commits into from
Mar 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions iam-new.tf

This file was deleted.

31 changes: 14 additions & 17 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,6 @@ data "template_file" "cloud-init" {
}
}

# To be replaced
resource "aws_iam_role" "role" {
name = local.cluster_name
assume_role_policy = data.aws_iam_policy_document.policy_doc.json
tags = var.tags
}

data "aws_iam_policy_document" "policy_permissions_doc" {
statement {
effect = "Allow"
Expand All @@ -99,8 +92,8 @@ data "aws_iam_policy_document" "policy_permissions_doc" {
"logs:PutLogEvents"
]
resources = [
aws_cloudwatch_log_group.log_group.arn,
"${aws_cloudwatch_log_group.log_group.arn}/*"
"${aws_cloudwatch_log_group.log_group.arn}:*",
"${aws_cloudwatch_log_group.log_group.arn}:*:*"
Copy link
Member Author

@magreenbaum magreenbaum Mar 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bumping aws provider to latest revealed a bugfix that was done here which removed the :* from the cloudwatch logs arn: hashicorp/terraform-provider-aws#14214.
Now we'll need to specifically include the :*.

Also noting that the arn format of log group and log stream is:
Log group | arn:aws:logs:region:account-id:log-group:log_group_name
Log stream | arn:aws:logs:region:account-id:log-group:log_group_name:log-stream:log-stream-name
https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/iam-access-control-overview-cwl.html

Planning to bump CMW terraform aws provider to latest v3 which will have the arn bugfix. Required for these changes.

Tested in dev:

            "Resource": [
                "arn:aws:logs:<region>:<account>:log-group:rabbitmq-<app_name>-dev:*:*",
                "arn:aws:logs:<region>:<account>:log-group:rabbitmq-<app_name>-dev:*"

Logs show up in CW.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch!

]
}

Expand All @@ -122,18 +115,22 @@ data "aws_iam_policy_document" "policy_permissions_doc" {
}
}

# To be replaced
resource "aws_iam_role_policy" "policy" {
name = local.cluster_name
role = aws_iam_role.role.id
resource "aws_iam_role_policy" "iam_policy" {
name = "${local.cluster_name}-${data.aws_region.current.name}"
role = aws_iam_role.iam_role.id

policy = data.aws_iam_policy_document.policy_permissions_doc.json
}

# To be replaced
resource "aws_iam_instance_profile" "profile" {
name_prefix = local.cluster_name
role = aws_iam_role.role.name
resource "aws_iam_instance_profile" "iam_profile" {
name_prefix = "${local.cluster_name}-${data.aws_region.current.name}-"
role = aws_iam_role.iam_role.name
}

resource "aws_iam_role" "iam_role" {
name = "${local.cluster_name}-${data.aws_region.current.name}"
assume_role_policy = data.aws_iam_policy_document.policy_doc.json
tags = var.tags
}

resource "aws_security_group" "rabbitmq_elb" {
Expand Down