JetBrains / teamcity-aws-codedeploy-plugin

Build runner for deploying application to AWS EC2 and on-premise instances using AWS CodeDeploy
https://confluence.jetbrains.com/display/TW/AWS+CodeDeploy+Runner
Apache License 2.0
11 stars 7 forks source link

Allow empty url in custom AWS Environment #18

Closed pennyclip closed 6 years ago

pennyclip commented 6 years ago

Hello Crew,

Back again, I would like the custom AWS Environment variable 'Endpoint URL' to allow me to leave it blank. The code seems to have some redundancy around this.

This exists, and would seemingly work fine if it were left empty https://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/client/builder/AwsClientBuilder.html#withRegion-java.lang.String- :

   if (StringUtil.isNotEmpty(myServiceEndpoint)) {
      builder.setEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(myServiceEndpoint, myRegion));
    } else {
      builder.withRegion(myRegion);
    }

But then we also don't allow it to be empty in the first place.

    if (ENVIRONMENT_TYPE_CUSTOM.equals(params.get(ENVIRONMENT_NAME_PARAM))) {
      final String serviceEndpoint = params.get(SERVICE_ENDPOINT_PARAM);
      if (StringUtil.isEmptyOrSpaces(serviceEndpoint)) {
        invalids.put(SERVICE_ENDPOINT_PARAM, SERVICE_ENDPOINT_LABEL + " must not be empty");
      } else {
        try {
          new URL(serviceEndpoint);
        } catch (MalformedURLException e) {
          invalids.put(SERVICE_ENDPOINT_PARAM, "Invalid URL format for " + SERVICE_ENDPOINT_LABEL);
        }
      }
    }

We could just remove the empty check and people won't be forced to manually enter the endpoint. There could be some additional clarity as to what the service endpoint is referring to as well. Should still validate for good URL formatting, and if it's left blank should use just the region, which should work.

Thanks for the consideration, welcome any constructive talks. I think this would help reduce forced manual effort on standard regions.

Jon