Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

S3 backend override tf code generated incorrectly #65

Closed
Jac0xb opened this issue Jan 10, 2025 · 3 comments · Fixed by #66
Closed

S3 backend override tf code generated incorrectly #65

Jac0xb opened this issue Jan 10, 2025 · 3 comments · Fixed by #66

Comments

@Jac0xb
Copy link

Jac0xb commented Jan 10, 2025

PR

The shared_config_files field is being rendered as a string instead of as a set of strings.

terraform {
  backend "s3" {
    access_key = "test"
    bucket = "...tf-state"
    dynamodb_table = "terraform-state-locks"
    encrypt = true
    endpoints = {
      s3 = "http://s3.localhost.localstack.cloud:4566"
      iam = "http://localhost:4566"
      sso = "http://localhost:4566"
      sts = "http://localhost:4566"
      dynamodb = "http://localhost:4566"
    }
    key = ".../terraform.tfstate"
    profile = "...-terraform"
    region = "us-east-1"
    secret_key = "test"
    shared_config_files = "['~/.aws/config']" <-- Renders it as a string.
    skip_credentials_validation = true
    skip_metadata_api_check = true
  }
}
image
@Jac0xb Jac0xb changed the title S3 backend tf code generated incorrectly S3 backend override tf code generated incorrectly Jan 10, 2025
@wisefool769
Copy link
Contributor

This part in tflocal is wrong for lists:

if isinstance(value, bool):
    value = str(value).lower()
elif isinstance(value, dict):
    # Special handling for dictionaries
    ...
else:
    value = f'"{str(value)}"'

should have an elif for list like:

elif isinstance(value, list):
    value = json.dumps(value)

@alexrashed
Copy link
Member

@wisefool769 thanks for digging into it! Would you be up to filing a PR to fix this? :)

@wisefool769
Copy link
Contributor

@alexrashed this worked better in my tests: #66

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants