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

minio_canned_policy order of array shifts on second (further) plan/apply #6

Open
rbojan opened this issue Jan 21, 2022 · 2 comments
Open

Comments

@rbojan
Copy link

rbojan commented Jan 21, 2022

The resource minio_canned_policy order of Action array shifts on second and further terraform plan forcing replacement of the resource.

Steps to reproduce:

  1. Create main.tf
resource "minio_canned_policy" "backups" {
  name = "backups"

  policy = <<EOT
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "s3:ListBucket"
            ],
            "Resource": [
                "arn:aws:s3:::backups"
            ]
        },
        {
            "Effect": "Allow",
            "Action": [
                "s3:GetObject",
                "s3:PutObject",
                "s3:DeleteObject"
            ],
            "Resource": [
                "arn:aws:s3:::backups/*"
            ]
        }
    ]
}
EOT
}
  1. Run terraform plan
  # minio_canned_policy.backups will be created
  + resource "minio_canned_policy" "backups" {
      + id     = (known after apply)
      + name   = "backups"
      + policy = jsonencode(
            {
              + Statement = [
                  + {
                      + Action   = [
                          + "s3:ListBucket",
                        ]
                      + Effect   = "Allow"
                      + Resource = [
                          + "arn:aws:s3:::backups",
                        ]
                    },
                  + {
                      + Action   = [
                          + "s3:GetObject",
                          + "s3:PutObject",
                          + "s3:DeleteObject",
                        ]
                      + Effect   = "Allow"
                      + Resource = [
                          + "arn:aws:s3:::backups/*",
                        ]
                    },
                ]
              + Version   = "2012-10-17"
            }
        )
    }
  1. Run terraform apply
minio_canned_policy.backups: Creation complete after 1s [id=backups]
  1. Run terraform plan again (without changing the resource)
  # minio_canned_policy.backups must be replaced
-/+ resource "minio_canned_policy" "backups" {
      ~ id     = "backups" -> (known after apply)
        name   = "backups"
      ~ policy = jsonencode(
          ~ {
              ~ Statement = [
                    {
                        Action   = [
                            "s3:ListBucket",
                        ]
                        Effect   = "Allow"
                        Resource = [
                            "arn:aws:s3:::backups",
                        ]
                    },
                  ~ {
                      ~ Action   = [
                          - "s3:DeleteObject",
                            "s3:GetObject",
                            "s3:PutObject",
                          + "s3:DeleteObject",
                        ]
                        # (2 unchanged elements hidden)
                    },
                ]
                # (1 unchanged element hidden)
            } # forces replacement
        )
    }

I suppose that this also applies to the Resource array but is not applicable here because it has only one element.

@rbojan rbojan changed the title minio_canned_policy shifts on second (further) plan/apply minio_canned_policy order shifts on second (further) plan/apply Jan 21, 2022
@rbojan rbojan changed the title minio_canned_policy order shifts on second (further) plan/apply minio_canned_policy order of array shifts on second (further) plan/apply Jan 21, 2022
@jostmart
Copy link

Stumbled upon this today. No fix?

@rbojan
Copy link
Author

rbojan commented Jun 13, 2023

@jostmart We ended up using another Terraform Provider for MinIO: https://github.com/aminueza/terraform-provider-minio which works like a charm.

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

No branches or pull requests

2 participants