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

MalformedXML when calling the PutBucketLifecycleConfiguration #5183

Open
theory opened this issue Dec 23, 2019 · 3 comments
Open

MalformedXML when calling the PutBucketLifecycleConfiguration #5183

theory opened this issue Dec 23, 2019 · 3 comments

Comments

@theory
Copy link

theory commented Dec 23, 2019

I wrote a policy to configure a lifecycle, but get this error:

botocore.exceptions.ClientError: An error occurred (MalformedXML) when calling the
PutBucketLifecycleConfiguration operation: The XML you provided was not well-formed or did not
validate against our published schema

The policy:

policies:
  - name: s3-log-targets
    resource: s3
    filters:
      - type: is-log-target
        # XXX Filter for buckets without a lifecycle expiration rule?
    actions:
      - type: configure-lifecycle
        rules:
          - ID: retention-policy
            Status: Enabled
            Expiration:
              Days: 30
    mode:
      type: pull

This does abide by the policy in s3.py, and looks similar to the policy I found in resources.json:

    "Lifecycle": {
      "Rules": [
        {
          "Expiration": {
            "Days": 30
          },
          "ID": "Log Retention",
          "Filter": {
            "Prefix": ""
          },
          "Status": "Enabled"
        }
      ]
    }

Is there a way to get c7n to emit the XML it's sending to the API?

@theory
Copy link
Author

theory commented Dec 23, 2019

Ah, fixed by adding the Filter:

          - ID: retention-policy
            Status: Enabled
            Prefix: ""
            Expiration:
              Days: 30

So maybe the schema needs to require it (or Filter/Prefix)?

@kapilt
Copy link
Collaborator

kapilt commented Dec 24, 2019

per the docs its not clear Prefix or Filter is required for a rule (required: no in the docs). re the xml, its something thats generated much lower down in the sdk stack (by boto3/botocore) not something custodian has access to directly.

https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketLifecycleConfiguration.html
https://docs.aws.amazon.com/AmazonS3/latest/API/API_LifecycleRule.html

@kapilt
Copy link
Collaborator

kapilt commented Dec 27, 2019

custodian is pretty much straight pass through on the user configuration to the api here, there's very little to no customization that we're doing on a given filter/rule. In this case it appears the service sdk api description and the service actual behavior differ.

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