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: Handle case when IAM Policy was deleted externally #569

Merged

Conversation

s-vitaliy
Copy link
Collaborator

Handle case when an IAM policy was Removed externally

Currently the provider has very annoying bug: if an IAM policy was removed externally, plan fails and the project that contains minio policies becomes unplannable.

This PR implements the following changes:

The new behavior:

$ terraform plan 
minio_iam_policy.test_policy: Refreshing state... [id=state-terraform-s3]

Note: Objects have changed outside of Terraform

Terraform detected the following changes made outside of Terraform since the last "terraform apply":

  # minio_iam_policy.test_policy has been deleted
  - resource "minio_iam_policy" "test_policy" {
      - id     = "state-terraform-s3" -> null
      - name   = "state-terraform-s3" -> null
      - policy = jsonencode(
            {
              - Statement = [
                  - {
                      - Action   = [
                          - "s3:GetBucketLocation",
                          - "s3:ListAllMyBuckets",
                        ]
                      - Effect   = "Allow"
                      - Resource = [
                          - "arn:aws:s3:::*",
                        ]
                      - Sid      = "1"
                    },
                  - {
                      - Action    = [
                          - "s3:*",
                        ]
                      - Condition = {
                          - StringLike = {
                              - s3:prefix = [
                                  - "",
                                  - "home/",
                                ]
                            }
                        }
                      - Effect    = "Allow"
                      - Resource  = [
                          - "arn:aws:s3:::state-terraform-s3",
                        ]
                    },
                  - {
                      - Action   = [
                          - "s3:DeleteObject",
                          - "s3:PutObject",
                        ]
                      - Effect   = "Allow"
                      - Resource = [
                          - "arn:aws:s3:::state-terraform-s3",
                          - "arn:aws:s3:::state-terraform-s3/*",
                        ]
                    },
                ]
              - Version   = "2012-10-17"
            }
        ) -> null
    }


Unless you have made equivalent changes to your configuration, or ignored the relevant attributes using ignore_changes, the following plan may include actions to undo or respond to these changes.

─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

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:

  # minio_iam_policy.test_policy will be created
  + resource "minio_iam_policy" "test_policy" {
      + id     = (known after apply)
      + name   = "state-terraform-s3"
      + policy = jsonencode(
            {
              + Statement = [
                  + {
                      + Action   = [
                          + "s3:ListAllMyBuckets",
                          + "s3:GetBucketLocation",
                        ]
                      + Effect   = "Allow"
                      + Resource = "arn:aws:s3:::*"
                      + Sid      = "1"
                    },
                  + {
                      + Action    = "s3:*"
                      + Condition = {
                          + StringLike = {
                              + s3:prefix = [
                                  + "",
                                  + "home/",
                                ]
                            }
                        }
                      + Effect    = "Allow"
                      + Resource  = "arn:aws:s3:::state-terraform-s3"
                      + Sid       = ""
                    },
                  + {
                      + Action   = [
                          + "s3:PutObject",
                          + "s3:DeleteObject",
                        ]
                      + Effect   = "Allow"
                      + Resource = [
                          + "arn:aws:s3:::state-terraform-s3/*",
                          + "arn:aws:s3:::state-terraform-s3",
                        ]
                      + Sid      = ""
                    },
                ]
              + Version   = "2012-10-17"
            }
        )
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Changes to Outputs:
  ~ minio_id = "state-terraform-s3" -> (known after apply)

Reference

Resolves #550

Closing issues

Copy link
Collaborator

@felladrin felladrin left a comment

Choose a reason for hiding this comment

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

Thanks for the fix and congrats on your first contribution to this repo, @s-vitaliy! 🎉

@felladrin felladrin merged commit bb3414e into aminueza:main Jun 20, 2024
2 checks passed
kireque referenced this pull request in kireque/home-ops Jun 21, 2024
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [minio](https://registry.terraform.io/providers/aminueza/minio)
([source](https://togithub.com/aminueza/terraform-provider-minio)) |
required_provider | patch | `2.3.1` -> `2.3.2` |

---

### Release Notes

<details>
<summary>aminueza/terraform-provider-minio (minio)</summary>

###
[`v2.3.2`](https://togithub.com/aminueza/terraform-provider-minio/releases/tag/v2.3.2)

[Compare
Source](https://togithub.com/aminueza/terraform-provider-minio/compare/v2.3.1...v2.3.2)

#### What's Changed

- Fix: Handle case when IAM Policy was deleted externally by
[@&#8203;s-vitaliy](https://togithub.com/s-vitaliy) in
[https://github.com/aminueza/terraform-provider-minio/pull/569](https://togithub.com/aminueza/terraform-provider-minio/pull/569)

#### New Contributors

- [@&#8203;s-vitaliy](https://togithub.com/s-vitaliy) made their first
contribution in
[https://github.com/aminueza/terraform-provider-minio/pull/569](https://togithub.com/aminueza/terraform-provider-minio/pull/569)

**Full Changelog**:
aminueza/terraform-provider-minio@v2.3.1...v2.3.2

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Renovate
Bot](https://togithub.com/renovatebot/renovate).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40MTMuMyIsInVwZGF0ZWRJblZlciI6IjM3LjQxMy4zIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJyZW5vdmF0ZS90ZXJyYWZvcm0iLCJ0eXBlL3BhdGNoIl19-->

Co-authored-by: kireque-bot[bot] <143391978+kireque-bot[bot]@users.noreply.github.com>
szinn referenced this pull request in szinn/k8s-homelab Jun 22, 2024
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [minio](https://registry.terraform.io/providers/aminueza/minio)
([source](https://togithub.com/aminueza/terraform-provider-minio)) |
required_provider | patch | `2.3.0` -> `2.3.2` |

---

### Release Notes

<details>
<summary>aminueza/terraform-provider-minio (minio)</summary>

###
[`v2.3.2`](https://togithub.com/aminueza/terraform-provider-minio/releases/tag/v2.3.2)

[Compare
Source](https://togithub.com/aminueza/terraform-provider-minio/compare/v2.3.1...v2.3.2)

#### What's Changed

- Fix: Handle case when IAM Policy was deleted externally by
[@&#8203;s-vitaliy](https://togithub.com/s-vitaliy) in
[https://github.com/aminueza/terraform-provider-minio/pull/569](https://togithub.com/aminueza/terraform-provider-minio/pull/569)

#### New Contributors

- [@&#8203;s-vitaliy](https://togithub.com/s-vitaliy) made their first
contribution in
[https://github.com/aminueza/terraform-provider-minio/pull/569](https://togithub.com/aminueza/terraform-provider-minio/pull/569)

**Full Changelog**:
aminueza/terraform-provider-minio@v2.3.1...v2.3.2

###
[`v2.3.1`](https://togithub.com/aminueza/terraform-provider-minio/releases/tag/v2.3.1)

[Compare
Source](https://togithub.com/aminueza/terraform-provider-minio/compare/v2.3.0...v2.3.1)

#### What's Changed

- Fix Azure and GCP remote tier creation and add support for tier
options by [@&#8203;s2thudry](https://togithub.com/s2thudry) in
[https://github.com/aminueza/terraform-provider-minio/pull/566](https://togithub.com/aminueza/terraform-provider-minio/pull/566)
- Bump google.golang.org/protobuf from 1.31.0 to 1.33.0 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[https://github.com/aminueza/terraform-provider-minio/pull/567](https://togithub.com/aminueza/terraform-provider-minio/pull/567)
- Bump golang.org/x/net from 0.17.0 to 0.23.0 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[https://github.com/aminueza/terraform-provider-minio/pull/568](https://togithub.com/aminueza/terraform-provider-minio/pull/568)

**Full Changelog**:
aminueza/terraform-provider-minio@v2.3.0...v2.3.1

</details>

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40MTMuMiIsInVwZGF0ZWRJblZlciI6IjM3LjQxMy4zIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJ0eXBlL3BhdGNoIl19-->

Co-authored-by: repo-jeeves[bot] <106431701+repo-jeeves[bot]@users.noreply.github.com>
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.

[FATAL] unable to read policy: The canned policy does not exist
2 participants