{"record":{"id":"c50518cca992b58d","repo":"apache/flink","slug":"aws-region-could-not-be-determined-set-s3-region","errorCode":null,"errorMessage":"AWS region could not be determined. Set 's3.region' in Flink configuration, AWS_REGION environment variable, or configure ~/.aws/config","messagePattern":"AWS region could not be determined\\. Set 's3\\.region' in Flink configuration, AWS_REGION environment variable, or configure ~/\\.aws/config","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink-filesystems/flink-s3-fs-native/src/main/java/org/apache/flink/fs/s3native/S3ClientProvider.java","lineNumber":986,"sourceCode":"                    .refreshRequest(requestBuilder.build())\n                    .build();\n        }\n\n        private Region resolveRegion(@Nullable String explicitRegion) {\n            if (!StringUtils.isNullOrWhitespaceOnly(explicitRegion)) {\n                LOG.info(\"Using configured AWS region: {}\", explicitRegion);\n                return Region.of(explicitRegion);\n            }\n\n            try {\n                Region region = DefaultAwsRegionProviderChain.builder().build().getRegion();\n                LOG.info(\"Auto-detected AWS region: {}\", region.id());\n                return region;\n            } catch (Exception e) {\n                // Fall through to error\n            }\n\n            throw new IllegalArgumentException(\n                    \"AWS region could not be determined. Set 's3.region' in Flink configuration, \"\n                            + \"AWS_REGION environment variable, or configure ~/.aws/config\");\n        }\n    }\n}\n","sourceCodeStart":968,"sourceCodeEnd":992,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-filesystems/flink-s3-fs-native/src/main/java/org/apache/flink/fs/s3native/S3ClientProvider.java#L968-L992","documentation":"resolveRegion() first honors an explicit s3.region / fs.s3.endpoint-region config, then falls back to the AWS SDK DefaultAwsRegionProviderChain (AWS_REGION/AWS_DEFAULT_REGION env vars, ~/.aws/config profile region, EC2/ECS metadata). If both the explicit config is unset and the provider chain throws, this IllegalArgumentException is raised listing the three remedies. The AWS SDK v2 client built here is region-mandatory, so no region means no client.","triggerScenarios":"No s3.region in flink-conf.yaml AND no AWS_REGION env on JobManager/TaskManager AND no ~/.aws/config on those hosts AND not running on EC2/ECS with IMDS reachable — then any S3 filesystem init (first S3 path touch) fails. Common in on-prem/minio deployments targeting a custom endpoint without setting the region option.","commonSituations":"Self-hosted MinIO/Ceph/ObjectStorage with fs.s3.endpoint configured but region forgotten (v2 SDK requires a region even for custom endpoints); bare-metal clusters without ~/.aws/config; containers that drop env vars; IMDS blocked by firewall so the provider chain throws instead of returning a region.","solutions":["Set the region explicitly in Flink config: s3.region: us-east-1 (or whatever your S3-compatible service expects; for MinIO any valid region string works, often us-east-1).","Alternatively export AWS_REGION=... for the JobManager and TaskManager processes (flink-conf.yaml via env.java.opts.all or the systemd/container env).","Or provide ~/.aws/config with [default] region=... on every cluster node — but prefer the Flink option for reproducibility.","For S3-compatible stores, also verify fs.s3.endpoint is set; region + endpoint together fully pin the client."],"exampleFix":"# before (flink-conf.yaml, MinIO deployment)\nfs.s3.endpoint: http://minio:9000\nfs.s3.path.style.access: true\n\n# after\nfs.s3.endpoint: http://minio:9000\nfs.s3.path.style.access: true\ns3.region: us-east-1","handlingStrategy":"validation","validationCode":"// Fail fast with a precise message before S3 init\nstatic void requireRegion(Configuration c) {\n    String region = c.getString(\"s3.region\", null);\n    if (region == null && System.getenv(\"AWS_REGION\") == null && System.getenv(\"AWS_DEFAULT_REGION\") == null\n            && !Files.isReadable(Path.of(System.getProperty(\"user.home\"), \".aws/config\"))) {\n        throw new IllegalArgumentException(\"No AWS region source — set s3.region in flink-conf.yaml\");\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always set s3.region explicitly in flink-conf.yaml for reproducible behavior, especially with custom endpoints (MinIO/Ceph).","Custom endpoint + path-style + region is the correct trio for S3-compatible stores.","Set AWS_REGION in container images as a belt-and-braces default."],"tags":["configuration","region","s3","minio","aws-sdk-v2","flink"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}