Skip to content

AWS_S3_FORCE_PATH_STYLE environment variable is not correctly recognized #127

Description

@Tobotobo

Note: This issue was translated and drafted with the assistance of AI.

Description

Even when the environment variable AWS_S3_FORCE_PATH_STYLE is set to 1 or true, PathStyle remains disabled.

Version

3.0.4

Root Cause

In bin/cdklocal, the shouldForcePathStyle function passes the value of the environment variable to isEnvTrue instead of the variable name.
Since isEnvTrue in src/index.js performs a lookup using the provided argument as a key for process.env, it fails to find the correct value.

bin/cdklocal

const shouldForcePathStyle = () => {
  // It currently passes the value (e.g., "1" or "true") instead of the key name
  if (isEnvTrue(process.env.AWS_S3_FORCE_PATH_STYLE)) {
    return true;
  }
  const endpointUrl = process.env.AWS_ENDPOINT_URL || "";
  try {
    return new URL(endpointUrl).hostname.includes(".sandbox.");
  } catch {
    return false;
  }
};

src/index.js

const isEnvTrue = (envName) => ["1", "true"].includes(process.env[envName]);

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