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

Invalid character '%!'(MISSING) on policy in composition #1792

Closed
zapr-16 opened this issue Jun 25, 2023 · 2 comments
Closed

Invalid character '%!'(MISSING) on policy in composition #1792

zapr-16 opened this issue Jun 25, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@zapr-16
Copy link

zapr-16 commented Jun 25, 2023

What happened?

After upgrading provider-aws from 0.39.0 to 0.41.0, policies defined in my composite resources started failing with the error below. The error goes away after rolling back to 0.39.0

2023-06-23T15:45:13.359Z DEBUG events	
cannot check if policy is up to date: invalid character '%!'(MISSING) looking for beginning of value	
{
  "type": "Warning", 
  "object": 
     {
       "kind":"Policy",
       "name":"policies-aws-secrets-manager",
       "uid":"8e5e38c4-506e-412a-b05e-733cb9137eac",
       "apiVersion":"iam.aws.crossplane.io/v1beta1",
       "resourceVersion":"3054451"
      }, 
       "reason": "CannotObserveExternalResource"
 }

This is a sample failing resource:

- name: Secretsmanager-Policy
      base:
        apiVersion: iam.aws.crossplane.io/v1beta1
        kind: Policy
        metadata:
          labels:
            role: aws-secrets-manager
        spec:
          deletionPolicy: Orphan
          forProvider:
            name: AllowSealedSecretsMasterKeyRead
            document: ""
      patches:
        - fromFieldPath: spec.id
          toFieldPath: metadata.name
          transforms:
            - type: string
              string:
                fmt: "%s-aws-secrets-manager"
        - fromFieldPath: spec.provider
          toFieldPath: spec.providerConfigRef.name
        - fromFieldPath: spec.account
          toFieldPath: metadata.annotations[crossplane.io/external-name]
          transforms:
            - type: string
              string:
                fmt: "arn:aws:iam::%s:policy/AllowSealedSecretsMasterKeyRead"
        - type: CombineFromComposite
          combine:
            variables:
              - fromFieldPath: spec.account
            strategy: string
            string:
              fmt: |
                {
                  "Version": "2012-10-17",
                  "Statement": [
                      {
                          "Effect": "Allow",
                          "Action": [
                              "secretsmanager:GetResourcePolicy",
                              "secretsmanager:GetSecretValue",
                              "secretsmanager:DescribeSecret",
                              "secretsmanager:ListSecretVersionIds"
                          ],
                          "Resource": [
                              "arn:aws:secretsmanager:eu-central-1:%s:secret:sealed-secrets-master*"
                          ]
                      }
                  ]
                }
          toFieldPath: spec.forProvider.document

How can we reproduce it?

Install provider-aws v0.41.0
Try to have a composite resource containing a similar policy to the one above

What environment did it happen in?

Crossplane version: 12.2.2
Provider-aws version: 0.41.0
K8s version. 1.27.3
K8s distro: EKS

@zapr-16 zapr-16 added the bug Something isn't working label Jun 25, 2023
@MisterMX
Copy link
Collaborator

MisterMX commented Jun 26, 2023

Should be fixed in #1790. Please checkout v0.41.1.

@MisterMX
Copy link
Collaborator

MisterMX commented Aug 4, 2023

Closing, as decoding errors are fixed in v0.41.1 and v0.42.0.

@MisterMX MisterMX closed this as completed Aug 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants