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

Enable non-executable local files to be generated #3

Closed
brett-richardson opened this issue Aug 17, 2017 · 4 comments · Fixed by #30
Closed

Enable non-executable local files to be generated #3

brett-richardson opened this issue Aug 17, 2017 · 4 comments · Fixed by #30

Comments

@brett-richardson
Copy link

Currently this provider only generates files with the permissions 0777.

Is there a way to parameterise this perhaps? It seems a little odd to make the files executable by default.

https://github.com/terraform-providers/terraform-provider-local/blob/8a97bc491e1e8a28197e40d40226d6748eb07ac6/local/resource_local_file.go#L71

@apparentlymart
Copy link
Member

Hi @brett-richardson!

Right now the options for this resource are pretty limited to keep it simple. Being able to set permissions seems reasonable, and I expect we didn't do it just because that introduces some platform-specific considerations -- Terraform runs on Windows, and permissions don't work the same way there.

Perhaps we could side-step this by not over-generalizing and just addressing directly your concern here, with a new attribute executable that can be set to false. That flag would likely do absolutely nothing on Windows, since Windows doesn't conventionally make such a distinction (or rather, does it via filename conventions), but on POSIX-like systems could set just read/write permissions, rather than read/write/execute. (It should still respect the active umask of the process, so in practice the file on disk will usually not be world-writable even though the mode here would suggest so.)

@brett-richardson
Copy link
Author

That makes a lot of sense. I'll see if I can put together a PR when I have time.

abn added a commit to abn/terraform-provider-local that referenced this issue Apr 8, 2018
Permissions for any created file or directories can now be explicitly
specified if required.

This change preserves the current behavior by defaulting to previously
used `0777` values for both file and directory permissions.

Resolves: hashicorp#3
@abn
Copy link
Contributor

abn commented Apr 8, 2018

@brett-richardson @apparentlymart submitted a possible resolution for this with #12. I have allowed for the configuration of the file permissions instead of an executable boolean. Left the current behaviour intact.

@rodrigocmn
Copy link

This is similar to #19, so I will give the same suggestion.

While we don't have a multi-platform feature in place, I've been using the following workaround...

resource "local_file" "foo" {
  content = "contents"
  filename = "foo.txt"
  provisioner "local-exec" {
    command = "chmod 644 foo.txt"
}

Hope it helps!

petems pushed a commit to petems/terraform-provider-local that referenced this issue Jul 26, 2019
Permissions for any created file or directories 
can now be explicitly specified if required.

This change preserves the current behaviour by 
defaulting to previously used `0777` values for 
both file and directory permissions.

Resolves: hashicorp#3
petems pushed a commit to petems/terraform-provider-local that referenced this issue Jul 26, 2019
Permissions for any created file or directories 
can now be explicitly specified if required.

This change preserves the current behaviour by 
defaulting to previously used `0777` values for 
both file and directory permissions.

Resolves: hashicorp#3
petems pushed a commit to petems/terraform-provider-local that referenced this issue Jul 26, 2019
Permissions for any created file or directories 
can now be explicitly specified if required.

This change preserves the current behaviour by 
defaulting to previously used `0777` values for 
both file and directory permissions.

Resolves: hashicorp#3
petems pushed a commit to petems/terraform-provider-local that referenced this issue Jul 26, 2019
Permissions for any created file or directories 
can now be explicitly specified if required.

This change preserves the current behaviour by 
defaulting to previously used `0777` values for 
both file and directory permissions.

Resolves: hashicorp#3
petems pushed a commit to petems/terraform-provider-local that referenced this issue Jul 26, 2019
Permissions for any created file or directories 
can now be explicitly specified if required.

This change preserves the current behaviour by 
defaulting to previously used `0777` values for 
both file and directory permissions.

Resolves: hashicorp#3
petems pushed a commit to petems/terraform-provider-local that referenced this issue Jul 26, 2019
Permissions for any created file or directories 
can now be explicitly specified if required.

This change preserves the current behaviour by 
defaulting to previously used `0777` values for 
both file and directory permissions.

Resolves: hashicorp#3
petems pushed a commit to petems/terraform-provider-local that referenced this issue Jul 26, 2019
Permissions for any created file or directories 
can now be explicitly specified if required.

This change preserves the current behaviour by 
defaulting to previously used `0777` values for 
both file and directory permissions.

Resolves: hashicorp#3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants