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

provider/aws: Validate effect in aws_iam_policy_document data source #10021

Merged

Conversation

dougneal
Copy link
Contributor

AWS allows only the case-sensitive strings Allow and Deny to appear in the Effect fields of IAM policy documents. Catch deviations from this, including mis-casing, before hitting the API and generating an error (the error is a generic 400 and doesn't indicate what part of the policy doc is invalid).

@dougneal dougneal changed the title Validate effect in aws_iam_policy_document data source provider/aws: Validate effect in aws_iam_policy_document data source Nov 10, 2016
@apparentlymart
Copy link
Contributor

Thanks for this, @dougneal. Seems like a very sensible addition!

Do you think it would be clearer to write this as a switch statement instead of a set of if branches?

switch v.(string) {
case "Allow", "Deny":
    // ...
default:
    // ...
}

My eye likes the compactness of this, but that's pretty subjective. What do you think?

@dougneal
Copy link
Contributor Author

Thanks @apparentlymart, I agree, that's neater. Will change.

AWS allows only the case-sensitive strings `Allow` and `Deny` to appear
in the `Effect` fields of IAM policy documents. Catch deviations from
this, including mis-casing, before hitting the API and generating an
error (the error is a generic 400 and doesn't indicate what part of the
policy doc is invalid).
@dougneal dougneal force-pushed the aws_iam_policy_doc_validation branch from 846579b to 338c34b Compare November 10, 2016 16:32
@apparentlymart
Copy link
Contributor

Thanks for the update, @dougneal. I was planning to merge this but I'm on the road right now and I just found that my laptop has a stale version of Go that can't build Terraform to run the tests, so I'll need to leave this for someone else to look at or until I have a chance to build a new Go version. Sorry for the delay.

@stack72
Copy link
Contributor

stack72 commented Dec 8, 2016

Hi @dougneal (and @apparentlymart)

I just looked at this and tested it - LGTM! Thanks for the work here :)

% make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAWSIAMPolicyDocument'                    ✭
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2016/12/08 12:05:50 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSIAMPolicyDocument -timeout 120m
=== RUN   TestAccAWSIAMPolicyDocument
--- PASS: TestAccAWSIAMPolicyDocument (13.87s)
PASS
ok  	github.com/hashicorp/terraform/builtin/providers/aws	13.894s

Paul

@stack72 stack72 merged commit d3175f8 into hashicorp:maint-0.7 Dec 8, 2016
@dougneal
Copy link
Contributor Author

dougneal commented Dec 8, 2016

Thanks @stack72! In terms of forward-porting this to 0.8, would another PR be helpful?

@stack72
Copy link
Contributor

stack72 commented Dec 8, 2016

It will be in 0.8 by default :) 0.8 is being built from master

@dougneal
Copy link
Contributor Author

dougneal commented Dec 8, 2016

The PR was targeted at maint-0.7 tho ;)

@stack72
Copy link
Contributor

stack72 commented Dec 8, 2016

ok, I am going to revert that - can you then retarget it to master?

@dougneal
Copy link
Contributor Author

dougneal commented Dec 8, 2016

@stack72: np, done: #10608

@ghost
Copy link

ghost commented Apr 19, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants