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

s3: Empty routing rules refused by AWS #1156

Merged

Conversation

chlunde
Copy link
Collaborator

@chlunde chlunde commented Feb 18, 2022

Description of your changes

When no routing rules are defined for a website configuration, we must
avoid sending an empty XML attribute as AWS refuses this as part of the
schema validation:

<WebsiteConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><ErrorDocument><Key>techdocs-docs/index.html</Key></ErrorDocument><IndexDocument><Suffix>index.html</Suffix></IndexDocument><RoutingRules></RoutingRules></WebsiteConfiguration>

cannot create or update: api error MalformedXML: The XML you provided was not well-formed or did not validate against our published schema

for the input:

websiteConfiguration:
  errorDocument:
    key: 'techdocs-docs/index.html'
  indexDocument:
    suffix: 'index.html'

Fixes bug reported on slack. #1155

I have:

  • Read and followed Crossplane's contribution process.
  • Run make reviewable test to ensure this PR is ready for review.

How has this code been tested

Created bucket, verified in the console that the config was created as requested.

apiVersion: s3.aws.crossplane.io/v1beta1
kind: Bucket
metadata:
  name: test-bucket
  annotations:
    # This will be the actual bucket name. It must be globally unique, so you
    # probably want to change it before trying to apply this example.
    crossplane.io/external-name: crossplane-example-bucket123
spec:
  forProvider:
    acl: private
    locationConstraint: us-east-1
    publicAccessBlockConfiguration:
      blockPublicPolicy: true
    websiteConfiguration:
      errorDocument: 
        key: 'techdocs-docs/index.html'
      indexDocument: 
        suffix: 'index.html'

When no routing rules are defined for a website configuration, we must
avoid sending an empty XML attribute as AWS refuses this as part of the
schema validation:

    <WebsiteConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><ErrorDocument><Key>techdocs-docs/index.html</Key></ErrorDocument><IndexDocument><Suffix>index.html</Suffix></IndexDocument><RoutingRules></RoutingRules></WebsiteConfiguration>

    cannot create or update: api error MalformedXML: The XML you provided was not well-formed or did not validate against our published schema

for the input:

    websiteConfiguration:
      errorDocument:
        key: 'techdocs-docs/index.html'
      indexDocument:
        suffix: 'index.html'

Signed-off-by: Carl Henrik Lunde <chlunde@ifi.uio.no>
Copy link
Member

@haarchri haarchri left a comment

Choose a reason for hiding this comment

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

LGTM - we have the same running internally ;) missed to upstream

@haarchri haarchri merged commit e8096bf into crossplane-contrib:master Feb 20, 2022
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.

None yet

2 participants