Skip to content

Provisioning fails if helm chart installed with aws.key="" #252

@mkhattab

Description

@mkhattab

Describe the bug

The following assumes the service broker is configured to use a custom S3 bucket. If the aws.key field during helm install is set to an empty string, i.e.

helm install aws-sb aws-sb/aws-servicebroker \
    # other options ...
    --set aws.key=""

Provisioning will fail with the following message (in the logs):

Failed to create the CloudFormation stack: ValidationError: S3 error: Access Denied

I believe I have narrowed to this specific line:

bl := AwsBroker{
        ...
	s3key:   addTrailingSlash(o.S3Key),   // This sets s3key: "/" if o.S3Key = ""
        ...
}

I think the fix in addTrailingSlash should check if the string is empty before adding a trailing slash.

func addTrailingSlash(s string) string {
	if s != "" && strings.HasSuffix(s, "/") == false {  // add check to make sure `s` is not empty
		s = s + "/"
	}
	return s
}

It's probably a good idea to trim whitespace here as well, although not sure if it's necessary (just thinking defensively).

To Reproduce

Install helm chart with --set aws.key=""

Expected behavior

Should provision resources normally.

Screenshots

None

Environment (please complete the following information):

  • Application Platform: [Kubernetes]
  • Application Platform Version: [e.g. k8s 1.21.10]
  • Broker Version [e.g. v1.0.4]

Additional context

Nope

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions