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

fix: decouple IAM policy documents from IAM role resource #196

Merged
merged 2 commits into from
Dec 23, 2024

Conversation

cazorla19
Copy link
Contributor

Description

Fixes #193

additionally decouples assume_role_policy from IAM role specifications to the separate data.aws_iam_policy_document resource

How Has This Been Tested?

  1. Run the module instance via terraform apply before the code change to reproduce this warning:
│ Warning: Argument is deprecated
│ 
│   with module.cloudwatch_firehose_logs_coralogix.aws_iam_role.new_firehose_iam[0],
│   on .terraform/modules/cloudwatch_firehose_logs_coralogix/modules/firehose-logs/main.tf line 97, in resource "aws_iam_role" "new_firehose_iam":
│   97: resource "aws_iam_role" "new_firehose_iam" {
│ 
│ The inline_policy argument is deprecated. Use the aws_iam_role_policy resource instead. If Terraform should exclusively manage all inline policy associations (the current behavior of this argument), use the aws_iam_role_policies_exclusive resource as well.
  1. Run terraform plan on firehose-logs module instance after the code change
  2. You will see a new resource Terraform wants to add, run terraform apply to see the warning is gone and the new resource has been added without breaking the resource permission

Although terraform will technically create a new resource, practically the state of IAM role altogether with its policy will stay the same as it was before the change: same inline policy format, same name, same permissions. (during tf apply it won't return you the error that this policy already exists)

Checklist:

  • I have updated the relevant example in the examples directory for the module.
  • I have updated the relevant test file for the module.
  • This change does not affect module (e.g. it's readme file change)

@cazorla19 cazorla19 requested a review from a team as a code owner December 23, 2024 14:27
Copy link
Contributor

@daidokoro daidokoro left a comment

Choose a reason for hiding this comment

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

LGTM

@cazorla19 cazorla19 merged commit b57f5bf into master Dec 23, 2024
7 checks passed
Copy link

🎉 This PR is included in version 2.3.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

firehose-logs: Migrate IAM Policy from inline to the separate data resource (aws_iam_role_policy)
2 participants