Commit Graph

10 Commits

Author SHA1 Message Date
The Magician
23db6b0c12 Fix golangci-lint errors (#3059)
Signed-off-by: Modular Magician <magic-modules@google.com>
2019-02-14 16:00:35 -08:00
The Magician
c605b0bc4b [Terraform]: Apply gofmt -s to all files managed by MM (#2676)
<!-- This change is generated by MagicModules. -->
/cc @rileykarson
2018-12-20 17:22:22 -08:00
Dana Hoffman
b8cf81e527
use customizediff to allow all role-entity pairs to be unordered (#1787) 2018-07-24 15:36:30 -07:00
Paddy Carver
87be5d2345 Explain this silliness.
Add a comment explaining why I'm setting something to nil in state.
2018-06-25 13:12:28 -07:00
Paddy Carver
d7078ab309 Fix failing test for storage ACLs.
When using predefined storage ACLs, you'd get a permadiff, because the
role_entities list was computed, but was never set in state. So it would
be read as empty in the config, and not present in state, so Terraform
would want to pull it down and sync it. This is probably, technically
speaking, a bug in Terraform, but we can work around it by just setting
role_entities to an empty value on every read.
2018-06-25 13:02:05 -07:00
Paddy Carver
1c8d56eca2 Fix the perma-diff in storage bucket ACLs.
Add a CustomDiff function to storage bucket ACLs that will ignore a diff
if the config and state have the same role_entities, even if they're in
a different order.

Fixes #1525.
2018-06-21 23:42:25 -07:00
Paddy
5060f07926 Pull ProjectNumber off bucket, not getProject.
Use the project reported by the bucket, not the one Terraform is
configured to use.
2017-09-25 06:02:36 -07:00
Paddy
72114636da Deal with undeleatable bucket ACLs in storage.
When GCS buckets are created, they're created with a set of default
ACLs:

* `OWNER:project-owners-{project_number}`
* `OWNER:project-editors-{project_number}`
* `READER:project-viewers-{project_number}`

Normally, this would be fine, or a minor inconvenience. Terraform could
either delete them itself, or the first apply of a user would overwrite
them.

However, trying to remove the `OWNER:project-owners-{project_number}`
ACL yields an API error that the bucket owner must maintain OWNER access
to the bucket. This breaks things like `terraform destroy`, but also
means any config without that line in it will fail to apply, not just
overwrite the value.

To make matters worse, trying to *add* the
`OWNER:project-owners-{project_number}` ACL to any bucket that already
has it _also_ yields the same error about not being able to remove it.

To get around this, the storage_bucket_acl resource has been updated to
largely ignore _just this_ ACL. It will not try to add it if it already
exists, will not try to remove it at all. This does mean that Terraform
is incapable of removing this ACL from a bucket, but I'm not sure it's
possible to do that with the API, anyways.

Tests were also updated to keep the default ACLs as part of the config,
and to change the email addresses to addresses we actually own. I tried
changing to non-existant hashicorp.com email addresses, but was
rejected; only email addresses that are backed by actual Google accounts
can be used, sadly.
2017-09-15 12:03:03 -07:00
Paddy
5b6df5ee93 storage: make bucket ACLs control the entire resource.
Storage bucket ACLs inherited the behaviour of only updating the fields
that were set in the config file. Terraform should track all the fields
in the resource, whether the user has specified a value for them or not,
and correct any drift that may occur.

This has manifested in an issue and unexpected behaviour in #50, and
this PR restores the expected behaviour.
2017-08-24 16:18:34 -07:00
Jake Champlin
66029ac431
Transfer google provider 2017-06-06 11:58:51 -04:00