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

[Bug]: IAM Role inlinePolicy conflicting with IAM RolePolicy #1207

Closed
1 task done
caspar-ds opened this issue Mar 12, 2024 · 4 comments · Fixed by #1213
Closed
1 task done

[Bug]: IAM Role inlinePolicy conflicting with IAM RolePolicy #1207

caspar-ds opened this issue Mar 12, 2024 · 4 comments · Fixed by #1213
Assignees
Labels
bug Something isn't working is:triaged Indicates that an issue has been reviewed.

Comments

@caspar-ds
Copy link

caspar-ds commented Mar 12, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Affected Resource(s)

  • iam.aws.upbound.io/v1beta1 - Role
  • iam.aws.upbound.io/v1beta1 - RolePolicy

Resource MRs required to reproduce the bug

apiVersion: iam.aws.upbound.io/v1beta1
kind: Role
metadata:
  name: crossplane-test-role
spec:
  forProvider:
    assumeRolePolicy: |-
      {
        "Version": "2012-10-17",
        "Statement": [
          {
            "Sid": "",
            "Effect": "Allow",
            "Principal": {
              "AWS": "*"
            },
            "Action": "sts:AssumeRole"
          }
        ]
      }
  providerConfigRef:
    name: default
apiVersion: iam.aws.upbound.io/v1beta1
kind: RolePolicy
metadata:
  name: crossplane-test-policy
spec:
  forProvider:
    policy: |
      {
        "Version": "2012-10-17",
        "Statement": [
          {
            "Effect": "Allow",
            "Action": "ec2:DescribeInstances",
            "Resource": [
              "*"
            ]
          }
        ]
      }
    role: crossplane-test-role
  providerConfigRef:
    name: default

Steps to Reproduce

  1. Create the Role and RolePolicy
  2. Wait for the Role to be reconciled. Note the inlinePolicy field is now present on the role:
inlinePolicy:
    - name: crossplane-test-policy
      policy: '{"Version":"2012-10-17","Statement":[{"Action":"ec2:DescribeInstances","Effect":"Allow","Resource":["*"]}]}'
  1. Delete the RolePolicy
  2. Note that the inline role policy has been removed
  3. Wait until next reconciliation of the Role
  4. Note that the inline role policy has been recreated due to the inlinePolicy

What happened?

As no inlinePolicy was defined on the Role it should not be managing inline policies:

If no blocks are configured, Crossplane will not manage any inline policies in this resource.

Setting inlinePolicy: [] or inlinePolicy: ~ has no effect and the field is removed during reconciliation.

Relevant Error Output Snippet

No response

Crossplane Version

1.15.0

Provider Version

0.47.2

Kubernetes Version

1.26

Kubernetes Distribution

EKS 1.26

Additional Info

No response

@caspar-ds caspar-ds added bug Something isn't working needs:triage labels Mar 12, 2024
@mbbush
Copy link
Collaborator

mbbush commented Mar 12, 2024

When you see inlinePolicy set on the Role, is the field in spec.forProvider or status.atProvider?

@haarchri
Copy link
Member

@mbbush remembers me on your comment in #933 (comment)

@mbbush
Copy link
Collaborator

mbbush commented Mar 13, 2024

Yeah, I couldn't remember if we ever made the second fix. Sounds like probably not.

@caspar-ds
Copy link
Author

When you see inlinePolicy set on the Role, is the field in spec.forProvider or status.atProvider?

It's in both

@mbbush mbbush added is:triaged Indicates that an issue has been reviewed. and removed needs:triage labels Mar 16, 2024
@mbbush mbbush self-assigned this Mar 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working is:triaged Indicates that an issue has been reviewed.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants