terraform-policymaker icon indicating copy to clipboard operation
terraform-policymaker copied to clipboard

Test is not correct

Open EduardSchwarzkopf opened this issue 1 year ago • 6 comments

I've executed the code with all defaults inside the root, but the result for the provided test seems to be wrong:

➜  terraform-policymaker git:(master) ✗ ./terraform-policymaker                              
Getting plan as JSON
######### New Policy
######### Policy created: aws_policy.json
➜  terraform-policymaker git:(master) ✗ cat aws_policy.json                                  

        {
                "Version": "2012-10-17",
                "Statement": [
                        {
                                "Effect": "Allow",
                                "Action": [],
                                "Resource": "*"
                        }
                ]
        }
        %                                                                       

Am I doing something wrong here?

EduardSchwarzkopf avatar Nov 16 '23 08:11 EduardSchwarzkopf

I'm getting the same when I try it with my configuration files.

andreburto avatar Dec 22 '23 16:12 andreburto

Hello! I found out that the newer versions of the terraform-provider-aws are not compatible with this project. There is a workaround:

  • Make sure you have run the executable at least once. There should be a terraform-provider-aws directory.
cd terraform-provider-aws
git checkout e7cd260316a08a7e071e65f8b4a326d8f452a88f # This is a commit from Jan 3, 2020
cd ..
rm aws_resource_mapping.json
go build
./terraform-policymaker

andrewlod avatar Feb 29 '24 12:02 andrewlod

  • Make sure you have run the executable at least once

Which executable exactly?

EduardSchwarzkopf avatar Feb 29 '24 12:02 EduardSchwarzkopf

Which executable exactly?

The one that is generated after running go build: ./terraform-policymaker

andrewlod avatar Feb 29 '24 12:02 andrewlod

The newer terraform-provider-aws no longer has data_source and resource prefixes on the file names that this program is looking for.

sparr avatar Apr 26 '24 18:04 sparr

Unfortunately the older provider repo is only mostly compatible. It produces some mappings with nonsense in them, like this:

"resource_aws_opsworks_stack":["opsworks:Config.Region); err != nil {\n\t\t\t\tlog.Printf","opsworks:CreateStack","opsworks:UpdateStack","opsworks:DeleteStack","opsworks:DescribeStacks","opsworks:Config.Region != nil \u0026\u0026 *client.Config.Region != \"\" {\n\t\t\tlog.Printf","opsworks:Config.Region)\n\t\t\tif err := d.Set"],

And it also produces a lot of actions that seem to exist but the IAM linter says they don't.

Invalid Action: The action s3:DeleteBucketEncryption does not exist.

sparr avatar Apr 26 '24 19:04 sparr