Skip to content
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

[cloudwatch-logs-aggregator] replace deprecated inline_policy block of aws_iam_role resource #29

Merged
merged 1 commit into from
Oct 7, 2024

Conversation

Arthur1
Copy link
Member

@Arthur1 Arthur1 commented Oct 4, 2024

Issue

Description

I replaced inline_policy block of aws_iam_role resource, which is deprecated from terraform-provider-aws v5.68.0, to aws_iam_role_policy resource.

Another candidate for replacement was aws_iam_role_policies_exclusive, but I did not choose it. This resource is not provided in terraform-provider-aws prior to v5.68.0. I think that exclusively inline-policy management is not particularly necessary in our case. If using aws_iam_role_policies_exclusive, you have to bump up their terraform-provider-aws to latest.

Test

 module "cw_logs_aggregator_lambda" {
-  source = "github.com/mackerelio-labs/mackerel-monitoring-modules//cloudwatch-logs-aggregator/lambda?ref=v0.3.0"
+  source = "github.com/mackerelio-labs/mackerel-monitoring-modules//cloudwatch-logs-aggregator/lambda?ref=7ef608"

   ...
 }
$ terraform plan
...
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following
symbols:
  + create

Terraform will perform the following actions:

  # module.sendgrid_webhook_logs_aggregator.module.cw_logs_aggregator_lambda.aws_iam_role_policy.this will be created
  + resource "aws_iam_role_policy" "this" {
      + id          = (known after apply)
      + name        = "cloudwatch-logs-aggregator-lambda"
      + name_prefix = (known after apply)
      + policy      = jsonencode(
            {
              + Statement = [
                  + {
                      + Action   = "ssm:GetParameter"
                      + Effect   = "Allow"
                      + Resource = "*"
                    },
                  + {
                      + Action   = [
                          + "logs:StopQuery",
                          + "logs:StartQuery",
                          + "logs:GetQueryResults",
                        ]
                      + Effect   = "Allow"
                      + Resource = "*"
                    },
                ]
              + Version   = "2012-10-17"
            }
        )
      + role        = "sendgrid-webhook-logs-aggregator-lambda"
    }

Plan: 1 to add, 0 to change, 0 to destroy.
...
スクリーンショット 2024-10-04 17 06 23

@Arthur1 Arthur1 changed the title replace deprecated inline_policy block of aws_iam_role resource [cloudwatch-logs-aggregator] replace deprecated inline_policy block of aws_iam_role resource Oct 4, 2024
Copy link

@yohfee yohfee left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@Arthur1 Arthur1 merged commit bfb508e into main Oct 7, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants