spring-cloud / spring-cloud-config

External configuration (server and client) for Spring Cloud
Apache License 2.0
1.95k stars 1.29k forks source link

Unable to Load Configuration from S3 Folder using Spring Cloud Config: Key Not Found #2531

Open BeardDude opened 2 weeks ago

BeardDude commented 2 weeks ago

Issue Description:

I'm trying to access configuration files located inside a folder in an S3 bucket using Spring Cloud Config. Below is the folder structure in S3:

bucket1/
└── config/
    └── application-dev.yml

Here is the relevant Spring configuration:

spring:
  profiles:
    active: awss3
  cloud:
    config:
      server:
        awss3:
          region: us-east-1
          bucket: bucket1/config

When trying to access the configuration via http://localhost:8888/application/dev, I am encountering an issue. The debug logs indicate that the S3 key was not found. The encoded URL appears as /bucket1%2Fconfig/application-dev.yml, and it seems like the folder structure or path encoding might be the cause.

Debug Log Excerpt:

Key not found: /bucket1%2Fconfig/application-dev.yml

Question:

How can I resolve this issue to correctly access the application-dev.yml file from the config folder in the S3 bucket?

(or)

Support for subfolders in a S3 bucket is not available ?

Package versions:

spring-cloud-config-server - 4.1.3 software.amazon.awssdk (s3) - 2.28.1

Any help or suggestions would be appreciated!

ryanjbaxter commented 1 week ago

According to the S3 docs...

Bucket names can consist only of lowercase letters, numbers, dots (.), and hyphens (-).

BeardDude commented 1 week ago

True. The bucket name is bucket1 and the sub-folder name is config inside which i have the application-dev.yml file.

Is there any way to access the application-dev.yml file ?

ryanjbaxter commented 2 days ago

Yes there is an example in the integration test we have https://github.com/spring-cloud/spring-cloud-config/blob/main/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/AwsS3IntegrationTests.java#L94-L95