Skip to content

Commit

Permalink
ignore assume_role_policy that is not a string
Browse files Browse the repository at this point in the history
  • Loading branch information
lhitchon committed Mar 16, 2018
1 parent d648986 commit cdb83c0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
13 changes: 7 additions & 6 deletions cli/terraform.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ func parsePolicy(resource assertion.Resource, attribute string) assertion.Resour
if resource.Properties != nil {
properties := resource.Properties.(map[string]interface{})
if policyAttribute, hasPolicyString := properties[attribute]; hasPolicyString {
policyString := policyAttribute.(string)
var policy interface{}
err := json.Unmarshal([]byte(policyString), &policy)
if err != nil {
panic(err)
if policyString, ok := policyAttribute.(string); ok {
var policy interface{}
err := json.Unmarshal([]byte(policyString), &policy)
if err != nil {
panic(err)
}
properties[attribute] = policy
}
properties[attribute] = policy
}
}
return resource
Expand Down
5 changes: 5 additions & 0 deletions example-files/config/roles.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@ resource "aws_iam_role" "test_role" {
}
EOF
}

resource "aws_iam_role" "test_role_with_invalid_policy" {
name = "role1"
assume_role_policy = [ "foo" ]
}

0 comments on commit cdb83c0

Please sign in to comment.